1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-06 16:50:09 +01:00

Merge pull request #891 from drbyte/dnsmasq-gc

Cleanup old tld refs when switching tld or uninstalling
This commit is contained in:
Matt Stauffer
2020-01-07 11:35:55 -05:00
committed by GitHub
2 changed files with 9 additions and 11 deletions

View File

@@ -2,12 +2,9 @@
namespace Valet;
use Exception;
use Symfony\Component\Process\Process;
class DnsMasq
{
var $brew, $cli, $files;
var $brew, $cli, $files, $configuration;
var $dnsmasqMasterConfigFile = '/usr/local/etc/dnsmasq.conf';
var $dnsmasqSystemConfDir = '/usr/local/etc/dnsmasq.d';
@@ -15,17 +12,13 @@ class DnsMasq
/**
* Create a new DnsMasq instance.
*
* @param Brew $brew
* @param CommandLine $cli
* @param Filesystem $files
* @return void
*/
function __construct(Brew $brew, CommandLine $cli, Filesystem $files)
function __construct(Brew $brew, CommandLine $cli, Filesystem $files, Configuration $configuration)
{
$this->cli = $cli;
$this->brew = $brew;
$this->files = $files;
$this->configuration = $configuration;
}
/**
@@ -61,6 +54,8 @@ function uninstall()
$this->brew->stopService('dnsmasq');
$this->brew->uninstallFormula('dnsmasq');
$this->cli->run('rm -rf /usr/local/etc/dnsmasq.d/dnsmasq-valet.conf');
$tld = $this->configuration->read()['tld'];
$this->files->unlink($this->resolverPath.'/'.$tld);
}
/**
@@ -145,6 +140,7 @@ function createTldResolver($tld)
function updateTld($oldTld, $newTld)
{
$this->files->unlink($this->resolverPath.'/'.$oldTld);
$this->files->unlink($this->dnsmasqUserConfigDir() . 'tld-' . $oldTld . '.conf');
$this->install($newTld);
}