added ns fix

Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
tracer 2022-01-27 15:14:14 +01:00
parent 491c26e80c
commit 283f5328df
1 changed files with 38 additions and 10 deletions

View File

@ -144,13 +144,17 @@ class BindAPI
/** /**
* @param String $domain * @param String $domain
* @param $panel
* *
* @return bool|void * @return bool|void
*/ */
function checkNS(String $domain) function checkNS(String $domain, $panel)
{ {
$nameServers = $this->nameserverController->findAll(); $nameServers = $this->nameserverController->findAll();
foreach($nameServers as $nameServer) { foreach($nameServers as $nameServer) {
if ($nameServer['name'] == 'ns1.24unix.net') {
continue;
}
echo COLOR_DEFAULT . ' ' . $nameServer['name']; echo COLOR_DEFAULT . ' ' . $nameServer['name'];
if (!empty($nameServer['aaaa'])) { if (!empty($nameServer['aaaa'])) {
$result = $this->checkController->sendCommand(serverName: $nameServer['name'], $result = $this->checkController->sendCommand(serverName: $nameServer['name'],
@ -166,9 +170,39 @@ class BindAPI
type: 'nameserver' . $domain); type: 'nameserver' . $domain);
} }
if ($result['header'] == 200) { if ($result['header'] == 200) {
return true; echo COLOR_GREEN . ' OK';
} else { } else {
return false; echo COLOR_RED . ' missing' . COLOR_DEFAULT;
$arguments = $this->parseArguments();
if (!empty($arguments['fix']) && $arguments['fix'] == 'yes') {
echo 'trying to fix …';
$body = [
'name' => $domain,
'panel_id' => $panel['id']
];
if (!empty($nameServer['aaaa'])) {
$result = $this->checkController->sendCommand(
serverName: $nameServer['name'],
versionIP: 6,
apiKey: $nameServer['apikey'],
command: 'domains',
type: 'nameserver',
post: true,
body: $body);
} else {
$result =$this->checkController->sendCommand(
serverName: $nameServer['name'],
versionIP: 4,
apiKey: $nameServer['apikey'],
command: 'domains',
type: 'nameserver',
post: true,
body: $body);
}
die();
} else {
echo 'error';
}
} }
} }
echo PHP_EOL; echo PHP_EOL;
@ -208,11 +242,7 @@ class BindAPI
foreach ($domains as $domain) { foreach ($domains as $domain) {
if ($domain->id_parent_domain == 0 && !str_contains(haystack: $domain->domain, needle: $panel['name'])) { if ($domain->id_parent_domain == 0 && !str_contains(haystack: $domain->domain, needle: $panel['name'])) {
echo PHP_EOL . COLOR_DEFAULT . "check: " . COLOR_YELLOW . str_pad(string: $domain->domain, length: $maxDomainName); echo PHP_EOL . COLOR_DEFAULT . "check: " . COLOR_YELLOW . str_pad(string: $domain->domain, length: $maxDomainName);
if ($this->checkNS(domain: $domain->domain)) { $this->checkNS(domain: $domain->domain, panel: $panel);
echo COLOR_GREEN . ' OK';
} else {
echo COLOR_RED . 'Missing';
}
} }
} }
} else { } else {
@ -794,8 +824,6 @@ class BindAPI
$id = intval(value: $this->arguments[1] ?? 0); $id = intval(value: $this->arguments[1] ?? 0);
$name = $arguments['name'] ?? ''; $name = $arguments['name'] ?? '';
print_r(value: $arguments); //findme
print("$id: id" . PHP_EOL);
$panelID = intval(value: $arguments['panel_id'] ?? 0); $panelID = intval(value: $arguments['panel_id'] ?? 0);
$a = $arguments['a'] ?? ''; $a = $arguments['a'] ?? '';
$aaaa = $arguments['aaaa'] ?? ''; $aaaa = $arguments['aaaa'] ?? '';