mirror of
https://github.com/fernwerker/ownDynDNS.git
synced 2025-07-10 14:15:14 +02:00
changed error handling
only throw stack trace if debug=true, otherwise only exit with short status message
This commit is contained in:
parent
0f13f4669c
commit
bd7d5bc672
1 changed files with 17 additions and 5 deletions
|
@ -26,20 +26,32 @@ final class Handler
|
||||||
$this->config = new Config($config);
|
$this->config = new Config($config);
|
||||||
|
|
||||||
if (!$this->config->isValid()) {
|
if (!$this->config->isValid()) {
|
||||||
throw new RuntimeException('configuration invalid');
|
if ($this->config->isDebug()) {
|
||||||
|
throw new RuntimeException('configuration invalid');
|
||||||
|
} else {
|
||||||
|
exit("configuration invalid\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->payload = new Payload($payload);
|
$this->payload = new Payload($payload);
|
||||||
|
|
||||||
if (!$this->payload->isValid()) {
|
if (!$this->payload->isValid()) {
|
||||||
throw new RuntimeException('payload invalid');
|
if ($this->config->isDebug()) {
|
||||||
|
throw new RuntimeException('payload invalid');
|
||||||
|
} else {
|
||||||
|
exit("payload invalid\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
$this->config->getUsername() !== $this->payload->getUser() ||
|
$this->config->getUsername() !== $this->payload->getUser() ||
|
||||||
$this->config->getPassword() !== $this->payload->getPassword()
|
$this->config->getPassword() !== $this->payload->getPassword()
|
||||||
) {
|
) {
|
||||||
throw new RuntimeException('credentials wrong');
|
if ($this->config->isDebug()) {
|
||||||
|
throw new RuntimeException('credentials invalid');
|
||||||
|
} else {
|
||||||
|
exit("credentials invalid\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_readable($this->config->getLogFile())) {
|
if (is_readable($this->config->getLogFile())) {
|
||||||
|
@ -152,8 +164,8 @@ final class Handler
|
||||||
$this->doLog(sprintf('IPv6 for %s set to %s', $record->hostname . '.' . $this->payload->getHostname(), $this->payload->getIpv6()));
|
$this->doLog(sprintf('IPv6 for %s set to %s', $record->hostname . '.' . $this->payload->getHostname(), $this->payload->getIpv6()));
|
||||||
$changes = true;
|
$changes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update TXT Record if exists and content has changed
|
// update TXT Record if exists and IP has changed
|
||||||
if ('TXT' === $record->type && $this->payload->getTxt() &&
|
if ('TXT' === $record->type && $this->payload->getTxt() &&
|
||||||
(
|
(
|
||||||
$this->payload->isForce()
|
$this->payload->isForce()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue