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 --- interface-definitions/https.xml | 12 ++++++++++++ src/conf_mode/https.py | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/interface-definitions/https.xml b/interface-definitions/https.xml index 403d4ecb0..d9874a1f9 100644 --- a/interface-definitions/https.xml +++ b/interface-definitions/https.xml @@ -31,6 +31,18 @@ + + + Port to listen for HTTPS requests; default 443 + + 1-65535 + Numeric IP port + + + + + + Server names: exact, wildcard, regex, or '_' (any) 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 b1cc15ab68925fb333f1e75862faefa365ac18d1 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 17 Nov 2019 13:15:40 +0100 Subject: wireless: T1627: fix interface names for list_interfaces.py The interface name was invalid, thus calling "list_interfaces.py -t wireless" won't return the actual wifi interfaces. --- data/interface-types.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/interface-types.json b/data/interface-types.json index f5820f403..f1862b882 100644 --- a/data/interface-types.json +++ b/data/interface-types.json @@ -11,7 +11,7 @@ "l2tpv3": "l2tpeth", "vxlan": "vxlan", "wireguard": "wg", - "wireless": "wireless", + "wireless": "wlan", "wirelessmodem": "wlm", "input": "ifb", "pppoe": "pppoe" -- cgit v1.2.3 From 05c9967ac3122b45dd2fe2ae48d67d5e2a3f14d7 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Tue, 12 Nov 2019 08:33:34 -0600 Subject: T1801: escape isolated backslashes before passing to ConfigTree() --- python/vyos/config.py | 6 ++++++ python/vyos/util.py | 6 ++++++ src/services/vyos-http-api-server | 2 ++ 3 files changed, 14 insertions(+) diff --git a/python/vyos/config.py b/python/vyos/config.py index 13b2c107e..e6a41a92d 100644 --- a/python/vyos/config.py +++ b/python/vyos/config.py @@ -69,6 +69,7 @@ import json import subprocess import vyos.configtree +import vyos.util class VyOSError(Exception): @@ -111,6 +112,11 @@ class Config(object): else: session_config_text = running_config_text + # The output of showConfig does not escape backslashes, as is expected + # by ConfigTree(). + session_config_text = vyos.util.escape_backslash(session_config_text) + running_config_text = vyos.util.escape_backslash(running_config_text) + self._session_config = vyos.configtree.ConfigTree(session_config_text) self._running_config = vyos.configtree.ConfigTree(running_config_text) diff --git a/python/vyos/util.py b/python/vyos/util.py index 67a602f7a..659a702fd 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -199,3 +199,9 @@ def is_admin() -> bool: current_user = getpass.getuser() (_, _, _, admin_group_members) = grp.getgrnam('sudo') return current_user in admin_group_members + +def escape_backslash(string: str) -> str: + """Escape single backslashes in string that are not in escape sequence""" + p = re.compile(r'(? Date: Sun, 17 Nov 2019 18:09:25 +0100 Subject: openvpn: fix typo in op-mode command on display rx bytes --- src/op_mode/show_openvpn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/op_mode/show_openvpn.py b/src/op_mode/show_openvpn.py index 577ed7eb7..06b90296f 100755 --- a/src/op_mode/show_openvpn.py +++ b/src/op_mode/show_openvpn.py @@ -28,7 +28,7 @@ OpenVPN status on {{ intf }} Client CN Remote Host Local Host TX bytes RX bytes Connected Since --------- ----------- ---------- -------- -------- --------------- {%- for c in clients %} -{{ "%-15s"|format(c.name) }} {{ "%-21s"|format(c.remote) }} {{ "%-21s"|format(local) }} {{ "%-9s"|format(c.tx_bytes) }} {{ "%-9s"|format(c.tx_bytes) }} {{ c.online_since }} +{{ "%-15s"|format(c.name) }} {{ "%-21s"|format(c.remote) }} {{ "%-21s"|format(local) }} {{ "%-9s"|format(c.tx_bytes) }} {{ "%-9s"|format(c.rx_bytes) }} {{ c.online_since }} {%- endfor %} {% endif %} """ -- 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(-) 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