changed call from Controller to repository
Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
parent
6466c5ed4b
commit
7dda80dcfd
|
@ -162,11 +162,11 @@ class BindAPI
|
||||||
|
|
||||||
echo COLOR_YELLOW . "domains" . COLOR_DEFAULT . " domains this server is responsible for" . PHP_EOL;
|
echo COLOR_YELLOW . "domains" . COLOR_DEFAULT . " domains this server is responsible for" . PHP_EOL;
|
||||||
echo COLOR_GREEN . "\t domains:list" . PHP_EOL;
|
echo COLOR_GREEN . "\t domains:list" . PHP_EOL;
|
||||||
echo COLOR_GREEN . "\t domains:create <name> {panel=<name>} | {A=<IPv4>} {AAAA=<IPv6>}" . PHP_EOL;
|
echo COLOR_GREEN . "\t domains:create <name> {panel=<name>}" . PHP_EOL;
|
||||||
echo COLOR_GREEN . "\t domains:update <ID> {name=<name>} {panel=<name>} | {A=<IPv4>} {AAAA=<IPv6>}" . PHP_EOL;
|
echo COLOR_GREEN . "\t domains:update <ID> {name=<name>} {panel=<name>}" . PHP_EOL;
|
||||||
echo COLOR_GREEN . "\t domains:delete <ID>" . PHP_EOL;
|
echo COLOR_GREEN . "\t domains:delete <ID>" . PHP_EOL;
|
||||||
|
|
||||||
echo COLOR_YELLOW . "apikeys" . COLOR_DEFAULT . "\t API keys for other nameservers" . PHP_EOL;
|
echo COLOR_YELLOW . "apikeys" . COLOR_DEFAULT . "\t API keys to access this server" . PHP_EOL;
|
||||||
echo COLOR_GREEN . "\t apikeys:list" . PHP_EOL;
|
echo COLOR_GREEN . "\t apikeys:list" . PHP_EOL;
|
||||||
echo COLOR_GREEN . "\t apikeys:create {name=<name>}" . PHP_EOL;
|
echo COLOR_GREEN . "\t apikeys:create {name=<name>}" . PHP_EOL;
|
||||||
echo COLOR_GREEN . "\t apikeys:update <ID> {name=<name>}" . PHP_EOL;
|
echo COLOR_GREEN . "\t apikeys:update <ID> {name=<name>}" . PHP_EOL;
|
||||||
|
@ -296,7 +296,12 @@ class BindAPI
|
||||||
foreach ($domains as $domain) {
|
foreach ($domains as $domain) {
|
||||||
if ($this->isValidSecondLevelDomain(domainName: $domain->domain, panel: $panel->getName(), parent: $domain->id_parent_domain)) {
|
if ($this->isValidSecondLevelDomain(domainName: $domain->domain, panel: $panel->getName(), parent: $domain->id_parent_domain)) {
|
||||||
echo COLOR_DEFAULT . "Domain: " . COLOR_YELLOW . str_pad(string: $domain->domain, length: $maxDomainName);
|
echo COLOR_DEFAULT . "Domain: " . COLOR_YELLOW . str_pad(string: $domain->domain, length: $maxDomainName);
|
||||||
$this->checkNS(domainName: $domain->domain, panel: $panel);
|
try {
|
||||||
|
$this->checkNS(domainName: $domain->domain, panel: $panel);
|
||||||
|
} catch (DependencyException|NotFoundException $e) {
|
||||||
|
print($e->getMessage());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
$domainCount++;
|
$domainCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -423,7 +428,8 @@ class BindAPI
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
print_r($create);
|
print_r(value: $create);
|
||||||
|
die("make error handling");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -667,9 +673,9 @@ class BindAPI
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($type == 'panel') {
|
if ($type == 'panel') {
|
||||||
$servers = $this->panelController->findAll();
|
$servers = $this->panelRepository->findAll();
|
||||||
} else {
|
} else {
|
||||||
$servers = $this->nameserverController->findAll();
|
$servers = $this->nameserverRepository->findAll();
|
||||||
}
|
}
|
||||||
foreach ($servers as $server) {
|
foreach ($servers as $server) {
|
||||||
if (!$this->checkPing(server: $server, type: $type)) {
|
if (!$this->checkPing(server: $server, type: $type)) {
|
||||||
|
@ -704,24 +710,24 @@ class BindAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $server
|
* @param \App\Entity\Panel|\App\Entity\Nameserver $server
|
||||||
* @param String $type
|
* @param String $type
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function checkPing(array $server, string $type): bool
|
public function checkPing(Panel|Nameserver $server, string $type): bool
|
||||||
{
|
{
|
||||||
$error = false;
|
$error = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($type == 'nameserver') {
|
if ($type == 'nameserver') {
|
||||||
$maxName = $this->nameserverController->getLongestEntry(field: 'name');
|
$maxName = $this->nameserverRepository->getLongestEntry(field: 'name');
|
||||||
$maxA = $this->nameserverController->getLongestEntry(field: 'a');
|
$maxA = $this->nameserverRepository->getLongestEntry(field: 'a');
|
||||||
$maxAAAA = $this->nameserverController->getLongestEntry(field: 'aaaa');
|
$maxAAAA = $this->nameserverRepository->getLongestEntry(field: 'aaaa');
|
||||||
} else {
|
} else {
|
||||||
$maxName = $this->panelController->getLongestEntry(field: 'name');
|
$maxName = $this->panelRepository->getLongestEntry(field: 'name');
|
||||||
$maxA = $this->panelController->getLongestEntry(field: 'a');
|
$maxA = $this->panelRepository->getLongestEntry(field: 'a');
|
||||||
$maxAAAA = $this->panelController->getLongestEntry(field: 'aaaa');
|
$maxAAAA = $this->panelRepository->getLongestEntry(field: 'aaaa');
|
||||||
}
|
}
|
||||||
} catch (DependencyException|NotFoundException $e) {
|
} catch (DependencyException|NotFoundException $e) {
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
|
@ -729,10 +735,10 @@ class BindAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->config['verbose']) {
|
if ($this->config['verbose']) {
|
||||||
print(COLOR_YELLOW . str_pad(string: $server['name'], length: $maxName));
|
print(COLOR_YELLOW . str_pad(string: $server->getName(), length: $maxName));
|
||||||
}
|
}
|
||||||
|
|
||||||
$a = $server['a'] ?? '';
|
$a = $server->getA() ?? '';
|
||||||
if (!empty($a)) {
|
if (!empty($a)) {
|
||||||
if ($this->config['verbose']) {
|
if ($this->config['verbose']) {
|
||||||
echo COLOR_DEFAULT . ' ' . str_pad(string: $a, length: $maxA, pad_type: STR_PAD_LEFT) . ' ';
|
echo COLOR_DEFAULT . ' ' . str_pad(string: $a, length: $maxA, pad_type: STR_PAD_LEFT) . ' ';
|
||||||
|
@ -740,9 +746,9 @@ class BindAPI
|
||||||
try {
|
try {
|
||||||
if ($result = $this->apiController->sendCommand(
|
if ($result = $this->apiController->sendCommand(
|
||||||
requestType: 'GET',
|
requestType: 'GET',
|
||||||
serverName: $server['name'],
|
serverName: $server->getName(),
|
||||||
versionIP: 4,
|
versionIP: 4,
|
||||||
apiKey: $server['apikey'],
|
apiKey: $server->getApikey(),
|
||||||
command: 'ping',
|
command: 'ping',
|
||||||
serverType: $type)) {
|
serverType: $type)) {
|
||||||
if ($this->config['verbose']) {
|
if ($this->config['verbose']) {
|
||||||
|
@ -759,7 +765,7 @@ class BindAPI
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$aaaa = $server['aaaa'] ?? '';
|
$aaaa = $server->getAaaa() ?? '';
|
||||||
if (!empty($aaaa)) {
|
if (!empty($aaaa)) {
|
||||||
if ($this->config['verbose']) {
|
if ($this->config['verbose']) {
|
||||||
echo COLOR_DEFAULT . ' ' . str_pad(string: $aaaa, length: $maxAAAA, pad_type: STR_PAD_LEFT) . ' ';
|
echo COLOR_DEFAULT . ' ' . str_pad(string: $aaaa, length: $maxAAAA, pad_type: STR_PAD_LEFT) . ' ';
|
||||||
|
@ -767,9 +773,9 @@ class BindAPI
|
||||||
try {
|
try {
|
||||||
if ($result = $this->apiController->sendCommand(
|
if ($result = $this->apiController->sendCommand(
|
||||||
requestType: 'GET',
|
requestType: 'GET',
|
||||||
serverName: $server['name'],
|
serverName: $server->getName(),
|
||||||
versionIP: 6,
|
versionIP: 6,
|
||||||
apiKey: $server['apikey'],
|
apiKey: $server->getApikey(),
|
||||||
command: 'ping',
|
command: 'ping',
|
||||||
serverType: $type)) {
|
serverType: $type)) {
|
||||||
if ($this->config['verbose']) {
|
if ($this->config['verbose']) {
|
||||||
|
@ -1083,6 +1089,7 @@ class BindAPI
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$content = [];
|
$content = [];
|
||||||
if (!empty($panel)) {
|
if (!empty($panel)) {
|
||||||
$panel = $this->panelRepository->findByName(name: $panel);
|
$panel = $this->panelRepository->findByName(name: $panel);
|
||||||
|
@ -1104,7 +1111,8 @@ class BindAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty($name) && empty($content)) {
|
if (empty($name) && empty($content)) {
|
||||||
echo 'Either a new name or new content (panel or addresses) is needed.' . PHP_EOL;
|
echo 'No name or panel given, just recreate the config file' . PHP_EOL;
|
||||||
|
$this->domainController->createSlaveZoneFile(domain: $domain);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (empty($content)) {
|
if (empty($content)) {
|
||||||
|
|
Loading…
Reference in New Issue