From 6b25ed2a44dde77f5cbfbf68fb4f5f661a34c1c0 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Thu, 14 Nov 2019 13:17:40 -0600 Subject: [service https] T1443: add setting of HTTPS listen port --- src/conf_mode/https.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/conf_mode') diff --git a/src/conf_mode/https.py b/src/conf_mode/https.py index d7fcb74de..fbd351e45 100755 --- a/src/conf_mode/https.py +++ b/src/conf_mode/https.py @@ -49,7 +49,7 @@ server { listen 443 ssl; listen [::]:443 ssl; {% else %} - listen {{ server.address }}:443 ssl; + listen {{ server.address }}:{{ server.port }} ssl; {% endif %} {% for name in server.name %} @@ -107,7 +107,11 @@ def get_config(): if conf.exists('listen-address'): for addr in conf.list_nodes('listen-address'): server_block = {'address' : addr} + server_block['port'] = '443' server_block['name'] = ['_'] + if conf.exists('listen-address {0} listen-port'.format(addr)): + port = conf.return_value('listen-address {0} listen-port'.format(addr)) + server_block['port'] = port if conf.exists('listen-address {0} server-name'.format(addr)): names = conf.return_values('listen-address {0} server-name'.format(addr)) server_block['name'] = names[:] -- cgit v1.2.3 From 4e4f1dbd745952a24d70c3e2d7dc495d675dff34 Mon Sep 17 00:00:00 2001 From: zdc Date: Sun, 17 Nov 2019 19:10:30 +0200 Subject: dns: T1786: add proper processing of 'system disable-dhcp-nameservers' --- src/conf_mode/host_name.py | 6 +++++- src/services/vyos-hostsd | 16 +++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src/conf_mode') diff --git a/src/conf_mode/host_name.py b/src/conf_mode/host_name.py index bb1ec9597..47cf232e9 100755 --- a/src/conf_mode/host_name.py +++ b/src/conf_mode/host_name.py @@ -66,7 +66,7 @@ def get_config(): hosts['nameserver'] = conf.return_values("system name-server") if conf.exists("system disable-dhcp-nameservers"): - hosts['no_dhcp_ns'] = conf.exists('system disable-dhcp-nameservers') + hosts['no_dhcp_ns'] = True # system static-host-mapping hosts['static_host_mapping'] = [] @@ -135,6 +135,10 @@ def apply(config): try: client = vyos.hostsd_client.Client() + # Check if disable-dhcp-nameservers is configured, and if yes - delete DNS servers added by DHCP + if config['no_dhcp_ns']: + client.delete_name_servers('dhcp-.+') + client.set_host_name(config['hostname'], config['domain_name'], config['domain_search']) client.delete_name_servers(tag) 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 -- cgit v1.2.3