added 404 fpr DynDNS
Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
parent
4d0be96915
commit
5a71d5efde
|
@ -13,9 +13,9 @@ use DI\ContainerBuilder;
|
||||||
use Monolog\Formatter\LineFormatter;
|
use Monolog\Formatter\LineFormatter;
|
||||||
use Monolog\Handler\StreamHandler;
|
use Monolog\Handler\StreamHandler;
|
||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
|
use OpenApi\Attributes as OAT;
|
||||||
use UnhandledMatchError;
|
use UnhandledMatchError;
|
||||||
use function DI\autowire;
|
use function DI\autowire;
|
||||||
use OpenApi\Attributes as OAT;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -499,7 +499,7 @@ class RequestController
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getDomain(String $host): string
|
private function getDomain(string $host): string
|
||||||
{
|
{
|
||||||
$host = strtolower(string: trim(string: $host));
|
$host = strtolower(string: trim(string: $host));
|
||||||
$count = substr_count(haystack: $host, needle: '.');
|
$count = substr_count(haystack: $host, needle: '.');
|
||||||
|
@ -584,8 +584,11 @@ class RequestController
|
||||||
$soa = $dnsDataDecoded->records->soa;
|
$soa = $dnsDataDecoded->records->soa;
|
||||||
$others = $dnsDataDecoded->records->other;
|
$others = $dnsDataDecoded->records->other;
|
||||||
|
|
||||||
$updateHost = function(object $host) use ($hostName, $a, $aaaa) {
|
$hostFound = false;
|
||||||
|
|
||||||
|
$updateHost = function (object $host) use ($hostName, $a, $aaaa, &$hostFound) {
|
||||||
if ($host->host == $hostName) {
|
if ($host->host == $hostName) {
|
||||||
|
$hostFound = true;
|
||||||
if ($host->type == 'A') {
|
if ($host->type == 'A') {
|
||||||
if (!empty($a)) {
|
if (!empty($a)) {
|
||||||
$host->value = $a;
|
$host->value = $a;
|
||||||
|
@ -600,6 +603,7 @@ class RequestController
|
||||||
|
|
||||||
array_map(callback: $updateHost, array: $others);
|
array_map(callback: $updateHost, array: $others);
|
||||||
|
|
||||||
|
if ($hostFound) {
|
||||||
$newDnsData = json_encode(value: [
|
$newDnsData = json_encode(value: [
|
||||||
'records' => [
|
'records' => [
|
||||||
'soa' => $soa,
|
'soa' => $soa,
|
||||||
|
@ -630,12 +634,14 @@ class RequestController
|
||||||
}
|
}
|
||||||
if ($result['header'] == 200) {
|
if ($result['header'] == 200) {
|
||||||
$this->header = '200 OK';
|
$this->header = '200 OK';
|
||||||
$this->status = json_encode(value: ['message' => 'Domain successfully updated']);
|
$this->status = json_encode(value: ['message' => 'DynDNS host successfully updated']);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->header = '404 Not Found';
|
||||||
|
$this->status = 'Host ' . COLOR_YELLOW . $hostName . ' not found';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue