summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-04-10 19:32:24 +0200
committerChristian Poessinger <christian@poessinger.com>2020-04-11 11:25:13 +0200
commit6a2e75dbe4003c6987c6932296e68c486ff7b380 (patch)
tree020236a6a5cbf98832c0dcfd3dac682a95db2bce /src/conf_mode
parentc2ae1ca3be86abfdba418a738785c8a217f6245f (diff)
downloadvyos-1x-6a2e75dbe4003c6987c6932296e68c486ff7b380.tar.gz
vyos-1x-6a2e75dbe4003c6987c6932296e68c486ff7b380.zip
vpn: l2tp: T2264: combine IPv4/IPv6 name-server CLI syntax
There is no reason to distinguish between an IPv4 and IPv6 name-server node on the CLI - this can be done in the underlaying Python scripts.
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/vpn_l2tp.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/conf_mode/vpn_l2tp.py b/src/conf_mode/vpn_l2tp.py
index d5274a6bc..93ee9edf9 100755
--- a/src/conf_mode/vpn_l2tp.py
+++ b/src/conf_mode/vpn_l2tp.py
@@ -26,9 +26,9 @@ from jinja2 import FileSystemLoader, Environment
from vyos.config import Config
from vyos.defaults import directories as vyos_data_dir
-from vyos import ConfigError
from vyos.util import run
-
+from vyos.validate import is_ipv4
+from vyos import ConfigError
pidfile = r'/var/run/accel_l2tp.pid'
l2tp_cnf_dir = r'/etc/accel-ppp/l2tp'
@@ -53,7 +53,7 @@ default_config_data = {
},
'outside_addr': '',
'gateway_address': '10.255.255.0',
- 'dns': [],
+ 'dnsv4': [],
'dnsv6': [],
'wins': [],
'client_ip_pool': None,
@@ -91,7 +91,7 @@ def _accel_cmd(command):
def get_config():
c = Config()
- base = ['vpn', 'l2tp' 'remote-access']
+ base = ['vpn', 'l2tp', 'remote-access']
if not c.exists(base):
return None
@@ -99,17 +99,19 @@ def get_config():
config_data = deepcopy(default_config_data)
### general options ###
- if c.exists('dns-servers server-1'):
- config_data['dns'].append(c.return_value('dns-servers server-1'))
- if c.exists('dns-servers server-2'):
- config_data['dns'].append(c.return_value('dns-servers server-2'))
- if c.exists('dnsv6-servers'):
- for dns6_server in c.return_values('dnsv6-servers'):
- config_data['dnsv6'].append(dns6_server)
+ if c.exists(['name-server']):
+ for name_server in c.return_values(['name-server']):
+ if is_ipv4(name_server):
+ config_data['dnsv4'].append(name_server)
+ else:
+ config_data['dnsv6'].append(name_server)
+
if c.exists('wins-servers server-1'):
config_data['wins'].append(c.return_value('wins-servers server-1'))
+
if c.exists('wins-servers server-2'):
config_data['wins'].append(c.return_value('wins-servers server-2'))
+
if c.exists('outside-address'):
config_data['outside_addr'] = c.return_value('outside-address')
@@ -324,8 +326,11 @@ def verify(c):
raise ConfigError(
"\"set vpn l2tp remote-access client-ipv6-pool prefix\" required for delegate-prefix ")
+ if len(c['dnsv4']) > 2:
+ raise ConfigError('Not more then two IPv4 DNS name-servers can be configured')
+
if len(c['dnsv6']) > 3:
- raise ConfigError("Maximum allowed dnsv6-servers addresses is 3")
+ raise ConfigError('Not more then three IPv6 DNS name-servers can be configured')
def generate(c):