summaryrefslogtreecommitdiff
path: root/src/services
diff options
context:
space:
mode:
authorkroy-the-rabbit <kroy@kroy.io>2020-05-28 00:39:45 -0500
committerGitHub <noreply@github.com>2020-05-28 07:39:45 +0200
commit5b1ac79562bd60494c9ec31723b27b0affe7fe5c (patch)
tree6bc442bb106f39995f2170b5c3198a594faf61f4 /src/services
parent47a08a610e13648074392b981af7d52f0c5506d0 (diff)
downloadvyos-1x-5b1ac79562bd60494c9ec31723b27b0affe7fe5c.tar.gz
vyos-1x-5b1ac79562bd60494c9ec31723b27b0affe7fe5c.zip
dhcp: T2465: T2483: fix DNS resolution (pdns restatt)
Diffstat (limited to 'src/services')
-rwxr-xr-xsrc/services/vyos-hostsd14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/services/vyos-hostsd b/src/services/vyos-hostsd
index 6017cea82..bf5d67cfa 100755
--- a/src/services/vyos-hostsd
+++ b/src/services/vyos-hostsd
@@ -28,6 +28,7 @@ import zmq
import collections
import jinja2
+from vyos.util import popen, process_named_running
debug = True
@@ -212,13 +213,17 @@ def handle_message(msg_json):
op = get_option(msg, 'op')
_type = get_option(msg, 'type')
+ changes = 0
+
if op == 'delete':
tag = get_option(msg, 'tag')
if _type == 'name_servers':
delete_name_servers(STATE, tag)
+ changes += 1
elif _type == 'hosts':
delete_hosts(STATE, tag)
+ changes += 1
else:
raise ValueError("Unknown message type {0}".format(_type))
elif op == 'add':
@@ -226,8 +231,10 @@ def handle_message(msg_json):
entries = get_option(msg, 'data')
if _type == 'name_servers':
add_name_servers(STATE, entries, tag)
+ changes += 1
elif _type == 'hosts':
add_hosts(STATE, entries, tag)
+ changes += 1
else:
raise ValueError("Unknown message type {0}".format(_type))
elif op == 'set':
@@ -236,6 +243,7 @@ def handle_message(msg_json):
data = get_option(msg, 'data')
if _type == 'host_name':
set_host_name(STATE, data)
+ changes += 1
else:
raise ValueError("Unknown message type {0}".format(_type))
elif op == 'get':
@@ -255,6 +263,12 @@ def handle_message(msg_json):
with open(STATE_FILE, 'w') as f:
json.dump(STATE, f)
+ if changes > 0:
+ if process_named_running("pdns_recursor"):
+ (ret,return_code) = popen("sudo rec_control --socket-dir=/run/powerdns reload-zones")
+ if return_code > 0:
+ logger.exception("PowerDNS rec_control failed to reload")
+
def exit_handler(sig, frame):
""" Clean up the state when shutdown correctly """
logger.info("Cleaning up state")