From db59d0e4f606a856f4e8264bdd67efc7df752640 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Fri, 18 Nov 2022 11:32:34 +0100 Subject: [PATCH] Checking given timeout --- lib/pp_admintools/app/pdns.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/pp_admintools/app/pdns.py b/lib/pp_admintools/app/pdns.py index f588fde..06429ae 100644 --- a/lib/pp_admintools/app/pdns.py +++ b/lib/pp_admintools/app/pdns.py @@ -43,7 +43,7 @@ from ..config.pdns import PdnsConfiguration from ..xlate import XLATOR -__version__ = '0.9.9' +__version__ = '0.9.10' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -279,7 +279,7 @@ class PpPDNSApplication(BaseMailApplication): PdnsConfiguration.default_pdns_api_port), ) - help_msg=_( + help_msg = _( "The timeout in seconds for the communication with the PowerDNS-API. " "Default: {} seconds.").format(PdnsConfiguration.default_pdns_timeout) pdns_group.add_argument( @@ -375,6 +375,13 @@ class PpPDNSApplication(BaseMailApplication): self.api_port = self.args.api_port if self.args.timeout: + if self.args.timeout > MAX_TIMEOUT: + msg = _("Timeout of {t} seconds too big, at most {m} seconds are allowed.") + msg = msg.format(t=self.args.timeout, m=MAX_TIMEOUT) + self.exit(1, msg) + if self.args.timeout < 0: + msg = _("A tomeout may not be negative.") + self.exit(1, msg) self.cfg.pdns_timeout = self.args.timeout self.pdns = PowerDNSServer( -- 2.39.5