diff options
author | zdc <zdc@users.noreply.github.com> | 2019-11-17 19:10:30 +0200 |
---|---|---|
committer | John Estabrook <jestabro@sentrium.io> | 2019-11-19 13:37:15 -0600 |
commit | 509ce7571a4617b2e8e1f5fc75e99689769c3997 (patch) | |
tree | 8ab3706efaeba844e2fb2765153a5c0a25d66dcd /src/services/vyos-hostsd | |
parent | 87411adf066d36685b0f53cc38610505590cd5a5 (diff) | |
download | vyos-1x-509ce7571a4617b2e8e1f5fc75e99689769c3997.tar.gz vyos-1x-509ce7571a4617b2e8e1f5fc75e99689769c3997.zip |
dns: T1786: add proper processing of 'system disable-dhcp-nameservers'
(cherry picked from commit 4e4f1dbd745952a24d70c3e2d7dc495d675dff34)
Diffstat (limited to 'src/services/vyos-hostsd')
-rwxr-xr-x | src/services/vyos-hostsd | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/services/vyos-hostsd b/src/services/vyos-hostsd index 5c2ea71c8..5fb7a68ab 100755 --- a/src/services/vyos-hostsd +++ b/src/services/vyos-hostsd @@ -22,6 +22,7 @@ import time import json import signal import traceback +import re import zmq @@ -154,14 +155,10 @@ def add_name_servers(data, entries, tag): def delete_name_servers(data, tag): name_servers = data['name_servers'] - keys_for_deletion = [] - - for ns in name_servers: - if name_servers[ns]['tag'] == tag: - keys_for_deletion.append(ns) - - for k in keys_for_deletion: - del name_servers[k] + regex_filter = re.compile(tag) + for ns in list(name_servers.keys()): + if regex_filter.match(name_servers[ns]['tag']): + del name_servers[ns] def set_host_name(state, data): if data['host_name']: @@ -174,8 +171,9 @@ def set_host_name(state, data): def get_name_servers(state, tag): ns = [] data = state['name_servers'] + regex_filter = re.compile(tag) for n in data: - if data[n]['tag'] == tag: + if regex_filter.match(data[n]['tag']): ns.append(n) return ns |