summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/accel_pppoe.py6
-rwxr-xr-xsrc/conf_mode/host_name.py6
-rwxr-xr-xsrc/migration-scripts/l2tp/0-to-119
-rwxr-xr-xsrc/op_mode/show_openvpn.py2
-rwxr-xr-xsrc/services/vyos-hostsd16
-rwxr-xr-xsrc/services/vyos-http-api-server2
-rwxr-xr-xsrc/system/on-dhcp-event.sh2
7 files changed, 30 insertions, 23 deletions
diff --git a/src/conf_mode/accel_pppoe.py b/src/conf_mode/accel_pppoe.py
index 9c879502a..6aec9be98 100755
--- a/src/conf_mode/accel_pppoe.py
+++ b/src/conf_mode/accel_pppoe.py
@@ -44,6 +44,9 @@ pppoe_config = '''
[modules]
log_syslog
pppoe
+{% if authentication['mode'] == 'radius' %}
+radius
+{% endif %}
ippool
{% if client_ipv6_pool %}
ipv6pool
@@ -63,9 +66,6 @@ net-snmp
{% if limits %}
connlimit
{% endif %}
-{% if authentication['mode'] == 'radius' %}
-radius
-{% endif %}
[core]
thread-count={{thread_cnt}}
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/migration-scripts/l2tp/0-to-1 b/src/migration-scripts/l2tp/0-to-1
index f6c716df1..686ebc655 100755
--- a/src/migration-scripts/l2tp/0-to-1
+++ b/src/migration-scripts/l2tp/0-to-1
@@ -35,17 +35,18 @@ else:
# Migrate "vpn l2tp authentication radius-server" tag node to new
# "vpn l2tp authentication radius server" tag node
- for server in config.list_nodes(cfg_base + ['radius-server']):
- base_server = cfg_base + ['radius-server', server]
- key = config.return_value(base_server + ['key'])
+ if config.exists(cfg_base + ['radius-server']):
+ for server in config.list_nodes(cfg_base + ['radius-server']):
+ base_server = cfg_base + ['radius-server', server]
+ key = config.return_value(base_server + ['key'])
- # delete old configuration node
- config.delete(base_server)
- # write new configuration node
- config.set(cfg_base + ['radius', 'server', server, 'key'], value=key)
+ # delete old configuration node
+ config.delete(base_server)
+ # write new configuration node
+ config.set(cfg_base + ['radius', 'server', server, 'key'], value=key)
- # format as tag node
- config.set_tag(cfg_base + ['radius', 'server'])
+ # format as tag node
+ config.set_tag(cfg_base + ['radius', 'server'])
# delete top level tag node
if config.exists(cfg_base + ['radius-server']):
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 %}
"""
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
diff --git a/src/services/vyos-http-api-server b/src/services/vyos-http-api-server
index 1abaed873..9b6d7e979 100755
--- a/src/services/vyos-http-api-server
+++ b/src/services/vyos-http-api-server
@@ -24,6 +24,7 @@ import traceback
import threading
import vyos.config
+import vyos.util
import bottle
@@ -212,6 +213,7 @@ def get_value():
config_format = command['configFormat']
res = session.show_config(path=command['path'])
+ res = vyos.util.escape_backslash(res)
if config_format == 'json':
config_tree = vyos.configtree.ConfigTree(res)
res = json.loads(config_tree.to_json())
diff --git a/src/system/on-dhcp-event.sh b/src/system/on-dhcp-event.sh
index 70a563d4c..5046912a6 100755
--- a/src/system/on-dhcp-event.sh
+++ b/src/system/on-dhcp-event.sh
@@ -44,11 +44,13 @@ case "$action" in
fi
# add host
/usr/bin/vyos-hostsd-client --add-hosts --tag "DHCP-$client_ip" --host "$client_fqdn_name,$client_ip"
+ ((changes++))
;;
release) # delete mapping for released address
# delete host
/usr/bin/vyos-hostsd-client --delete-hosts --tag "DHCP-$client_ip"
+ ((changes++))
;;
*)