Compare commits

...

2 Commits

Author SHA1 Message Date
tracer c8cb2049a0 moved debug output to logger
Signed-off-by: tracer <tracer@24unix.net>
2022-04-06 17:14:23 +02:00
tracer 92e0bf6d02 added 204 if ip was not changed
Signed-off-by: tracer <tracer@24unix.net>
2022-04-06 17:13:48 +02:00
2 changed files with 108 additions and 100 deletions

View File

@ -94,6 +94,9 @@
"200": {
"description": "OK"
},
"204": {
"description": "No Content"
},
"401": {
"description": "API key is missing or invalid."
},

View File

@ -57,7 +57,7 @@ class RequestController
private DomainController $domainController;
private DomainRepository $domainRepository;
private PanelRepository $panelRepository;
private DynDNSRepository $DynDNSRepository;
private DynDNSRepository $dynDNSRepository;
private Container $container;
private string $header;
private array $result;
@ -561,20 +561,21 @@ class RequestController
$this->header = '404 Not Found';
$this->message = 'Domain ' . $domainName . ' not found';
} else {
// check if address has changed
if ($dynDNS = $this->dynDNSRepository->findByName(name: $host)) {
echo 'found host';
print_r($dynDNS);
print("a: $a");
print("aaaa: $aaaa");
if ($this->config['debug']) {
$this->log->debug(message: 'found host: ' . $host);
$this->log->debug(message: "a: $a");
$this->log->debug(message: "aaaa: $aaaa");
}
$ipChanged = false;
if (!empty($a)) {
if ($a != $dynDNS->getA()) {
echo $a . '!=' . $dynDNS->getA();
if ($this->config['debug']) {
$this->log->debug(message: $a . ' != ' . $dynDNS->getA());
}
$dynDNS->setA(a: $a);
$ipChanged = true;
}
@ -582,25 +583,25 @@ class RequestController
if (!empty($aaaa)) {
if ($aaaa != $dynDNS->getAaaa()) {
if ($this->config['debug']) {
$this->log->debug(message: $aaaa . ' != ' . $dynDNS->getAaaa());
}
$dynDNS->setAaaa(aaaa: $aaaa);
$ipChanged = true;
}
}
if (!$ipChanged) {
$this->header = '304 Not Modified';
$this->message = 'Not modified';
} else {
if ($ipChanged) {
$this->dynDNSRepository->update(dynDNS: $dynDNS);
}
} else {
$dynDNS = new DynDNS(name: $host, a: $a, aaaa: $aaaa);
$this->dynDNSRepository->insert(dynDNS: $dynDNS);
$ipChanged = true;
}
if ($ipChanged) {
$panel = $this->panelRepository->findByName(name: $domain->getPanel());
if (!empty($panel->getAaaa())) {
@ -702,6 +703,10 @@ class RequestController
$this->header = '404 Not Found';
$this->message = 'Host ' . $hostName . ' not found';
}
} else {
$this->header = '204 No content';
$this->message = 'No content';
}
}
}
}