summaryrefslogtreecommitdiff
path: root/src/conf_mode/service_dns_dynamic.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-01-11 08:18:21 +0100
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2024-01-11 15:18:19 +0000
commit900289cf5d94cfc2dbb59cad548efb126389bbf9 (patch)
tree7011f65a1de9b35c9ba2bfd5783dcc2f2a67fef5 /src/conf_mode/service_dns_dynamic.py
parentaa90d124d772efee6c4c5f3a9ccc734fe20ae03b (diff)
downloadvyos-1x-900289cf5d94cfc2dbb59cad548efb126389bbf9.tar.gz
vyos-1x-900289cf5d94cfc2dbb59cad548efb126389bbf9.zip
dns: T5791: use common pattern for exclude check of dynamic interfaces
This uses a more common pattern froma base class while the original code from 0a1c9bc38 ("T5791: DNS dynamic exclude check for dynamic interfaces PPPoE") is still retained. (cherry picked from commit e5ce4222c6e9b24d276625678db7339ada0c54ef)
Diffstat (limited to 'src/conf_mode/service_dns_dynamic.py')
-rwxr-xr-xsrc/conf_mode/service_dns_dynamic.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/conf_mode/service_dns_dynamic.py b/src/conf_mode/service_dns_dynamic.py
index 99fa8feee..845aaa1b5 100755
--- a/src/conf_mode/service_dns_dynamic.py
+++ b/src/conf_mode/service_dns_dynamic.py
@@ -21,8 +21,10 @@ from sys import exit
from vyos.base import Warning
from vyos.config import Config
from vyos.configverify import verify_interface_exists
+from vyos.configverify import dynamic_interface_pattern
from vyos.template import render
from vyos.utils.process import call
+from vyos.utils.network import interface_exists
from vyos import ConfigError
from vyos import airbag
airbag.enable()
@@ -30,9 +32,6 @@ airbag.enable()
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 = ('pppoe', 'sstpc')
-
# Protocols that require zone
zone_necessary = ['cloudflare', 'digitalocean', 'godaddy', 'hetzner', 'gandi',
'nfsn', 'nsupdate']
@@ -81,7 +80,6 @@ def verify(dyndns):
# Dynamic DNS service provider - configuration validation
for service, config in dyndns['name'].items():
-
error_msg_req = f'is required for Dynamic DNS service "{service}"'
error_msg_uns = f'is not supported for Dynamic DNS service "{service}"'
@@ -93,10 +91,12 @@ def verify(dyndns):
# that the interface exists (or just warn if dynamic interface)
# and that web-options are not set
if config['address'] != 'web':
+ tmp = re.compile(dynamic_interface_pattern)
# exclude check interface for dynamic interfaces
- if config['address'].startswith(dynamic_interfaces):
- Warning(f'Interface "{config["address"]}" does not exist yet and cannot '
- f'be used for Dynamic DNS service "{service}" until it is up!')
+ if tmp.match(config["address"]):
+ if not interface_exists(config["address"]):
+ Warning(f'Interface "{config["address"]}" does not exist yet and cannot '
+ f'be used for Dynamic DNS service "{service}" until it is up!')
else:
verify_interface_exists(config['address'])
if 'web_options' in config: