Compare commits

..

No commits in common. "c8cb2049a07c9817a682825aeb74669c578e1694" and "0a67c168628698c4121fcec11872c3ec8534ecf6" have entirely different histories.

2 changed files with 108 additions and 116 deletions

View File

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

View File

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