Skip to content

Commit

Permalink
ddclient: T5791: Exclude availablity check for pseudo-interface
Browse files Browse the repository at this point in the history
Also, adjust the warning messages to clarify further.
  • Loading branch information
indrajitr committed Dec 11, 2023
1 parent e7cf5af commit 120a641
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/conf_mode/dns_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
config_file = r'/run/ddclient/ddclient.conf'
systemd_override = r'/run/systemd/system/ddclient.service.d/override.conf'

# Dynamic interfaces that might not exist when the configuration is loaded
dynamic_interfaces = ('peth', 'pppoe', 'sstpc')

# Protocols that require zone
zone_necessary = ['cloudflare', 'digitalocean', 'godaddy', 'hetzner', 'gandi',
'nfsn', 'nsupdate']
Expand Down Expand Up @@ -86,17 +89,20 @@ def verify(dyndns):
if field not in config:
raise ConfigError(f'"{field.replace("_", "-")}" {error_msg_req}')

# If dyndns address is an interface, ensure that it exists
# If dyndns address is an interface, ensure
# that the interface exists (or just warn if dynamic interface)
# and that web-options are not set
if config['address'] != 'web':
# exclude check interface for dynamic interfaces
interface_filter = ('pppoe', 'sstpc')
if config['address'].startswith(interface_filter):
Warning(f'interface {config["address"]} does not exist!')
if config['address'].startswith(dynamic_interfaces):
Warning(f'Interface "{config["address"]}" does not exist for Dynamic DNS '
f'service "{service}" yet! The service will not operate correctly '
f'till the interface is configured.')
else:
verify_interface_exists(config['address'])
if 'web_options' in config:
raise ConfigError(f'"web-options" is applicable only when using HTTP(S) web request to obtain the IP address')
raise ConfigError(f'"web-options" is applicable only when using HTTP(S) '
f'web request to obtain the IP address')

# RFC2136 uses 'key' instead of 'password'
if config['protocol'] != 'nsupdate' and 'password' not in config:
Expand Down Expand Up @@ -124,13 +130,16 @@ def verify(dyndns):

if config['ip_version'] == 'both':
if config['protocol'] not in dualstack_supported:
raise ConfigError(f'Both IPv4 and IPv6 at the same time {error_msg_uns} with protocol "{config["protocol"]}"')
raise ConfigError(f'Both IPv4 and IPv6 at the same time {error_msg_uns} '
f'with protocol "{config["protocol"]}"')
# dyndns2 protocol in ddclient honors dual stack only for dyn.com (dyndns.org)
if config['protocol'] == 'dyndns2' and 'server' in config and config['server'] not in dyndns_dualstack_servers:
raise ConfigError(f'Both IPv4 and IPv6 at the same time {error_msg_uns} for "{config["server"]}" with protocol "{config["protocol"]}"')
raise ConfigError(f'Both IPv4 and IPv6 at the same time {error_msg_uns} '
f'for "{config["server"]}" with protocol "{config["protocol"]}"')

if {'wait_time', 'expiry_time'} <= config.keys() and int(config['expiry_time']) < int(config['wait_time']):
raise ConfigError(f'"expiry-time" must be greater than "wait-time" for Dynamic DNS service "{service}"')
raise ConfigError(f'"expiry-time" must be greater than "wait-time" for '
f'Dynamic DNS service "{service}"')

return None

Expand Down

0 comments on commit 120a641

Please sign in to comment.