summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2023-04-22 07:50:44 +0100
committerGitHub <noreply@github.com>2023-04-22 07:50:44 +0100
commitc907058015293947fb60231fed1df55e7969e85f (patch)
treefd19bcaa50df95e35aa834a61ab8ccec277fb6a5 /src
parentfcfd07ef80209e489d836f9c82d8779ccce0a137 (diff)
parent84e9b48405017f718daa35a0e8b5d5c07d40ae3f (diff)
downloadvyos-1x-c907058015293947fb60231fed1df55e7969e85f.tar.gz
vyos-1x-c907058015293947fb60231fed1df55e7969e85f.zip
Merge pull request #1962 from indrajitr/ddclient-opmode-2
dns: T5144: Make dns dynamic status output legacy format compatible
Diffstat (limited to 'src')
-rwxr-xr-xsrc/op_mode/dynamic_dns.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/op_mode/dynamic_dns.py b/src/op_mode/dynamic_dns.py
index 2cba33cc8..d41a74db3 100755
--- a/src/op_mode/dynamic_dns.py
+++ b/src/op_mode/dynamic_dns.py
@@ -21,6 +21,7 @@ import time
from tabulate import tabulate
from vyos.config import Config
+from vyos.template import is_ipv4, is_ipv6
from vyos.util import call
cache_file = r'/run/ddclient/ddclient.cache'
@@ -46,7 +47,7 @@ def _get_formatted_host_records(host_data):
def show_status():
- # A ddclient status file must not always exist
+ # A ddclient status file might not always exist
if not os.path.exists(cache_file):
sys.exit(0)
@@ -62,9 +63,20 @@ def show_status():
# we pick up the ones we are interested in
for kvraw in line.split(' ')[0].split(','):
k, v = kvraw.split('=')
- if k in columns.keys():
+ if k in list(columns.keys()) + ['ip', 'status']: # ip and status are legacy keys
props[k] = v
+ # Extract IPv4 and IPv6 address and status from legacy keys
+ # Dual-stack isn't supported in legacy format, 'ip' and 'status' are for one of IPv4 or IPv6
+ if 'ip' in props:
+ if is_ipv4(props['ip']):
+ props['ipv4'] = props['ip']
+ props['status-ipv4'] = props['status']
+ elif is_ipv6(props['ip']):
+ props['ipv6'] = props['ip']
+ props['status-ipv6'] = props['status']
+ del props['ip']
+
# Convert mtime to human readable format
if 'mtime' in props:
props['mtime'] = time.strftime(