adapted createSlaveZone to new config

Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
tracer 2022-02-12 20:41:59 +01:00
parent 879feb9044
commit 28bf7c0c0b
1 changed files with 12 additions and 4 deletions

View File

@ -5,6 +5,7 @@ namespace App\Controller;
use App\Entity\Domain;
use App\Repository\DomainRepository;
use App\Repository\NameserverRepository;
use App\Repository\PanelRepository;
use Monolog\Logger;
error_reporting(error_level: E_ALL);
@ -21,7 +22,7 @@ class DomainController
private string $namedConfLocalFile;
private string $zoneCachePath;
public function __construct(private NameserverRepository $nameserverRepository, private ApiController $checkController, private DomainRepository $domainRepository, private array $config, private Logger $log)
public function __construct(private NameserverRepository $nameserverRepository, private ApiController $checkController, private DomainRepository $domainRepository, private PanelRepository $panelRepository, private array $config, private Logger $log)
{
if ($this->config['debug']) {
@ -71,6 +72,8 @@ class DomainController
fputs(stream: $oFile, data: 'include "' . $this->localZonesDir . $domain->getName() . '";' . PHP_EOL);
}
fclose(stream: $oFile);
// TODO rndc reload
}
@ -224,15 +227,20 @@ class DomainController
if ($zonefile = fopen(filename: $this->localZonesDir . $domain->getName(), mode: 'w')) {
// TODO fixme soon
//fputs(stream: $zonefile, data: 'zone \"' . $domain->getA() . '"' . ' IN {' . PHP_EOL);
$content = json_decode(json: $domain->getContent());
$panelName = $content->panel;
$panel = $this->panelRepository->findByName(name: $panelName);
$a = $panel->getA();
$aaaa = $panel->getAaaa();
fputs(stream: $zonefile, data: 'zone "' . $domain->getName() . '"' . ' IN {' . PHP_EOL);
fputs(stream: $zonefile, data: "\ttype slave;" . PHP_EOL);
fputs(stream: $zonefile, data: "\tfile \"" . $this->zoneCachePath . $domain->getName() . '.db";' . PHP_EOL);
fputs(stream: $zonefile, data: "\tmasters {" . PHP_EOL);
if (!empty($a)) {
// fputs(stream: $zonefile, data: "\t\t" . $domain->getA() . ';' . PHP_EOL);
fputs(stream: $zonefile, data: "\t\t" . $a . ';' . PHP_EOL);
}
if (!empty($aaaa)) {
// fputs(stream: $zonefile, data: "\t\t" . $domain->getAaaa() . ';' . PHP_EOL);
fputs(stream: $zonefile, data: "\t\t" . $aaaa . ';' . PHP_EOL);
}
fputs(stream: $zonefile, data: "\t};" . PHP_EOL);
fputs(stream: $zonefile, data: "};" . PHP_EOL);