diff options
110 files changed, 1778 insertions, 1875 deletions
diff --git a/data/templates/accel-ppp/chap-secrets.config_dict.tmpl b/data/templates/accel-ppp/chap-secrets.config_dict.tmpl new file mode 100644 index 000000000..da64b64d5 --- /dev/null +++ b/data/templates/accel-ppp/chap-secrets.config_dict.tmpl @@ -0,0 +1,12 @@ +# username server password acceptable local IP addresses shaper +{% if authentication is defined and authentication.local_users is defined and authentication.local_users.username is defined %} +{% for user, user_config in authentication.local_users.username.items() %} +{% if user_config.disabled is not defined %} +{% if user_config.rate_limit is defined %} +{{ "%-12s" | format(user) }} * {{ "%-16s" | format(user_config.password) }} {{ "%-16s" | format(user_config.static_ip) }} {{ user_config.rate_limit.download }}/{{ user_config.rate_limit.upload }} +{% else %} +{{ "%-12s" | format(user) }} * {{ "%-16s" | format(user_config.password) }} {{ "%-16s" | format(user_config.static_ip) }} +{% endif %} +{% endif %} +{% endfor %} +{% endif %} diff --git a/data/templates/accel-ppp/chap-secrets.tmpl b/data/templates/accel-ppp/chap-secrets.tmpl index dd00d7bd0..6cace5401 100644 --- a/data/templates/accel-ppp/chap-secrets.tmpl +++ b/data/templates/accel-ppp/chap-secrets.tmpl @@ -2,7 +2,7 @@ {% for user in local_users %} {% if user.state == 'enabled' %} {% if user.upload and user.download %} -{{ "%-12s" | format(user.name) }} * {{ "%-16s" | format(user.password) }} {{ "%-16s" | format(user.ip) }} {{ user.download }} / {{ user.upload }} +{{ "%-12s" | format(user.name) }} * {{ "%-16s" | format(user.password) }} {{ "%-16s" | format(user.ip) }} {{ user.download }}/{{ user.upload }} {% else %} {{ "%-12s" | format(user.name) }} * {{ "%-16s" | format(user.password) }} {{ "%-16s" | format(user.ip) }} {% endif %} diff --git a/data/templates/accel-ppp/config_chap_secrets_radius.j2 b/data/templates/accel-ppp/config_chap_secrets_radius.j2 new file mode 100644 index 000000000..c94e75a23 --- /dev/null +++ b/data/templates/accel-ppp/config_chap_secrets_radius.j2 @@ -0,0 +1,36 @@ +{% if authentication.mode is defined and authentication.mode == 'local' %}
+[chap-secrets]
+chap-secrets={{ chap_secrets_file }}
+{% elif authentication.mode is defined and authentication.mode == 'radius' %}
+[radius]
+verbose=1
+{% for server, options in authentication.radius.server.items() if not options.disable is defined %}
+server={{ server }},{{ options.key }},auth-port={{ options.port }},acct-port={{ options.acct_port }},req-limit=0,fail-time={{ options.fail_time }}
+{% endfor %}
+{% if authentication.radius.acct_interim_jitter is defined and authentication.radius.acct_interim_jitter is not none %}
+acct-interim-jitter={{ authentication.radius.acct_interim_jitter }}
+{% endif %}
+acct-timeout={{ authentication.radius.acct_timeout }}
+timeout={{ authentication.radius.timeout }}
+max-try={{ authentication.radius.max_try }}
+{% if authentication.radius.nas_identifier is defined and authentication.radius.nas_identifier is not none %}
+nas-identifier={{ authentication.radius.nas_identifier }}
+{% endif %}
+{% if authentication.radius.nas_ip_address is defined and authentication.radius.nas_ip_address is not none %}
+nas-ip-address={{ authentication.radius.nas_ip_address }}
+{% endif %}
+{% if authentication.radius.source_address is defined and authentication.radius.source_address is not none %}
+bind={{ authentication.radius.source_address }}
+{% endif %}
+{% if authentication.radius.called_sid_format is defined and authentication.radius.called_sid_format is not none %}
+called-sid={{ authentication.radius.called_sid_format }}
+{% endif %}
+{% if authentication.radius.dynamic_author.server is defined and authentication.radius.dynamic_author.server is not none %}
+dae-server={{ authentication.radius.dynamic_author.server }}:{{ authentication.radius.dynamic_author.port }},{{ authentication.radius.dynamic_author.key }}
+{% endif -%}
+{% endif %}
+{# Both chap-secrets and radius block required the gw-ip-address #}
+{% if gateway_address is defined and gateway_address is not none %}
+gw-ip-address={{ gateway_address }}
+{% endif %}
+
diff --git a/data/templates/accel-ppp/config_ip_pool.j2 b/data/templates/accel-ppp/config_ip_pool.j2 new file mode 100644 index 000000000..973bc0071 --- /dev/null +++ b/data/templates/accel-ppp/config_ip_pool.j2 @@ -0,0 +1,14 @@ +{% if client_ip_pool is defined and client_ip_pool is not none %} +[ip-pool] +{% if gateway_address is defined and gateway_address is not none %} +gw-ip-address={{ gateway_address }} +{% endif %} +{% if client_ip_pool.start is defined and client_ip_pool.stop is defined and client_ip_pool.start is not none and client_ip_pool.stop is not none %} +{{ client_ip_pool.start }}-{{ client_ip_pool.stop }} +{% endif %} +{% if client_ip_pool.subnet is defined and client_ip_pool.subnet is not none %} +{% for subnet in client_ip_pool.subnet %} +{{ subnet }} +{% endfor %} +{% endif %} +{% endif %} diff --git a/data/templates/accel-ppp/config_ipv6_pool.j2 b/data/templates/accel-ppp/config_ipv6_pool.j2 new file mode 100644 index 000000000..f45bf9442 --- /dev/null +++ b/data/templates/accel-ppp/config_ipv6_pool.j2 @@ -0,0 +1,20 @@ +{% if client_ipv6_pool is defined and client_ipv6_pool is not none %} +[ipv6-nd] +AdvAutonomousFlag=1 + +{% if client_ipv6_pool.prefix is defined and client_ipv6_pool.prefix is not none %} +[ipv6-pool] +{% for prefix, options in client_ipv6_pool.prefix.items() %} +{{ prefix }},{{ options.mask }} +{% endfor %} +{% if client_ipv6_pool.delegate is defined and client_ipv6_pool.delegate is not none %} +{% for prefix, options in client_ipv6_pool.delegate.items() %} +delegate={{ prefix }},{{ options.delegation_prefix }} +{% endfor %} +{% endif %} +{% endif %} +{% if client_ipv6_pool.delegate is defined and client_ipv6_pool.delegate is not none %} +[ipv6-dhcp] +verbose=1 +{% endif %} +{% endif %} diff --git a/data/templates/accel-ppp/config_modules_auth_mode.j2 b/data/templates/accel-ppp/config_modules_auth_mode.j2 new file mode 100644 index 000000000..5eca76f91 --- /dev/null +++ b/data/templates/accel-ppp/config_modules_auth_mode.j2 @@ -0,0 +1,5 @@ +{% if authentication is defined and authentication.mode is defined and authentication.mode == 'local' %}
+chap-secrets
+{% elif authentication is defined and authentication.mode is defined and authentication.mode == 'radius' %}
+radius
+{% endif %}
diff --git a/data/templates/accel-ppp/config_modules_auth_protocols.j2 b/data/templates/accel-ppp/config_modules_auth_protocols.j2 new file mode 100644 index 000000000..e122d6c48 --- /dev/null +++ b/data/templates/accel-ppp/config_modules_auth_protocols.j2 @@ -0,0 +1,10 @@ +{% for protocol in authentication.protocols %}
+{# this should be fixed in the CLI by a migrator #}
+{% if protocol == 'chap' %}
+auth_chap_md5
+{% elif protocol == 'mschap' %}
+auth_mschap_v1
+{% else %}
+auth_{{ protocol.replace('-', '_') }}
+{% endif %}
+{% endfor %}
diff --git a/data/templates/accel-ppp/config_modules_ipv6.j2 b/data/templates/accel-ppp/config_modules_ipv6.j2 new file mode 100644 index 000000000..e9ea4924b --- /dev/null +++ b/data/templates/accel-ppp/config_modules_ipv6.j2 @@ -0,0 +1,5 @@ +{% if ppp_options.ipv6 is defined and ppp_options.ipv6 != 'deny' %}
+ipv6pool
+ipv6_nd
+ipv6_dhcp
+{% endif %}
diff --git a/data/templates/accel-ppp/config_name_server.j2 b/data/templates/accel-ppp/config_name_server.j2 new file mode 100644 index 000000000..2bf064f92 --- /dev/null +++ b/data/templates/accel-ppp/config_name_server.j2 @@ -0,0 +1,13 @@ +{% if name_server_ipv4 is defined and name_server_ipv4 is not none %} +[dns] +{% for ns in name_server_ipv4 %} +dns{{ loop.index }}={{ ns }} +{% endfor %} +{% endif %} + +{% if name_server_ipv6 is defined and name_server_ipv6 is not none %} +[ipv6-dns] +{% for ns in name_server_ipv6 %} +{{ ns }} +{% endfor %} +{% endif %} diff --git a/data/templates/accel-ppp/config_shaper_radius.j2 b/data/templates/accel-ppp/config_shaper_radius.j2 new file mode 100644 index 000000000..2a6641245 --- /dev/null +++ b/data/templates/accel-ppp/config_shaper_radius.j2 @@ -0,0 +1,10 @@ +{% if authentication is defined and authentication.mode is defined and authentication.mode == 'radius' %}
+{% if authentication is defined and authentication.radius is defined and authentication.radius.rate_limit is defined and authentication.radius.rate_limit.enable is defined %}
+[shaper]
+verbose=1
+attr={{ authentication.radius.rate_limit.attribute }}
+{% if authentication.radius.rate_limit.vendor is defined and authentication.radius.rate_limit.vendor is not none %}
+vendor={{ authentication.radius.rate_limit.vendor }}
+{% endif %}
+{% endif %}
+{% endif %}
diff --git a/data/templates/accel-ppp/pppoe.config.tmpl b/data/templates/accel-ppp/pppoe.config.tmpl index 4af0d9365..19adbc890 100644 --- a/data/templates/accel-ppp/pppoe.config.tmpl +++ b/data/templates/accel-ppp/pppoe.config.tmpl @@ -2,36 +2,31 @@ [modules] log_syslog pppoe -{% if auth_mode == 'radius' %} -radius -{% endif %} -chap-secrets -ippool -{% if ppp_ipv6 != 'deny' %} -ipv6pool -ipv6_nd -ipv6_dhcp -{% endif %} -{% for proto in auth_proto: %} -{{proto}} -{% endfor%} shaper -{% if snmp %} +{# Common authentication backend definitions #} +{% include 'accel-ppp/config_modules_auth_mode.j2' %} +ippool +{# Common IPv6 definitions #} +{% include 'accel-ppp/config_modules_ipv6.j2' %} +{# Common authentication protocols (pap, chap ...) #} +{% include 'accel-ppp/config_modules_auth_protocols.j2' %} + +{% if snmp is defined %} net-snmp {% endif %} -{% if limits %} +{% if limits is defined %} connlimit {% endif %} [core] -thread-count={{ thread_cnt }} +thread-count={{ thread_count }} [log] syslog=accel-pppoe,daemon copy=1 level=5 -{% if snmp == 'enable-ma' %} +{% if snmp is defined and snmp.master_agent is defined %} [snmp] master=1 {% endif %} @@ -39,175 +34,101 @@ master=1 [client-ip-range] disable -{% if ppp_gw %} -[ip-pool] -gw-ip-address={{ ppp_gw }} -{% if client_ip_pool %} -{{ client_ip_pool }} -{% endif -%} -{% if client_ip_subnets %} -{% for subnet in client_ip_subnets %} -{{ subnet }} -{% endfor %} -{% endif %} -{% endif %} +{# Common IP pool definitions #} +{% include 'accel-ppp/config_ip_pool.j2' %} -{% if client_ipv6_pool %} -[ipv6-nd] -AdvAutonomousFlag=1 - -[ipv6-pool] -{% for p in client_ipv6_pool %} -{{ p.prefix }},{{ p.mask }} -{% endfor %} -{% for p in client_ipv6_delegate_prefix %} -delegate={{ p.prefix }},{{ p.mask }} -{% endfor %} -{% endif %} +{# Common IPv6 pool definitions #} +{% include 'accel-ppp/config_ipv6_pool.j2' %} -{% if dnsv4 %} -[dns] -{% for dns in dnsv4 -%} -dns{{ loop.index }}={{ dns }} -{% endfor -%} -{% endif %} +{# Common DNS name-server definition #} +{% include 'accel-ppp/config_name_server.j2' %} -{% if dnsv6 %} -[ipv6-dns] -{% for dns in dnsv6 -%} -{{ dns }} -{% endfor -%} -{% endif %} - -{% if wins %} +{% if wins_server is defined and wins_server is not none %} [wins] -{% for server in wins -%} +{% for server in wins_server %} wins{{ loop.index }}={{ server }} -{% endfor -%} -{% endif %} - -{% if auth_mode == 'local' %} -[chap-secrets] -chap-secrets={{ chap_secrets_file }} -{% elif auth_mode == 'radius' %} -[radius] -verbose=1 -{% for r in radius_server %} -server={{ r.server }},{{ r.key }},auth-port={{ r.port }},acct-port={{ r.acct_port }},req-limit=0,fail-time={{ r.fail_time }} -{% endfor -%} - -{% if radius_acct_inter_jitter %} -acct-interim-jitter={{ radius_acct_inter_jitter }} +{% endfor %} {% endif %} -acct-timeout={{ radius_acct_tmo }} -timeout={{ radius_timeout }} -max-try={{ radius_max_try }} - -{% if radius_nas_id %} -nas-identifier={{ radius_nas_id }} -{% endif -%} -{% if radius_nas_ip %} -nas-ip-address={{ radius_nas_ip }} -{% endif -%} -{% if radius_source_address %} -bind={{ radius_source_address }} -{% endif -%} - +{# Common chap-secrets and RADIUS server/option definitions #} +{% include 'accel-ppp/config_chap_secrets_radius.j2' %} -{% if radius_dynamic_author %} -dae-server={{ radius_dynamic_author.server }}:{{ radius_dynamic_author.port }},{{ radius_dynamic_author.key }} -{% endif -%} -{% endif %} -{% if ppp_gw %} -gw-ip-address={{ ppp_gw }} -{% endif %} - -{% if sesscrtl != 'disable' %} +{% if session_control is defined and session_control != 'disable' %} [common] -single-session={{ sesscrtl }} +single-session={{ session_control }} {% endif %} [ppp] verbose=1 check-ip=1 -{% if ppp_ccp %} -ccp=1 -{% else %} -ccp=0 -{% endif %} -{% if ppp_preallocate_vif %} -unit-preallocate=1 -{% else %} -unit-preallocate=0 -{% endif %} -{% if ppp_min_mtu %} -min-mtu={{ ppp_min_mtu }} +ccp={{ "1" if ppp_options.ccp is defined else "0" }} +unit-preallocate={{ "1" if authentication.radius.preallocate_vif is defined else "0" }} +{% if ppp_options.min_mtu is defined and ppp_options.min_mtu is not none %} +min-mtu={{ ppp_options.min_mtu }} {% else %} min-mtu={{ mtu }} {% endif %} -{% if ppp_mru %} -mru={{ ppp_mru }} -{% endif %} -mppe={{ ppp_mppe }} -lcp-echo-interval={{ ppp_echo_interval }} -lcp-echo-timeout={{ ppp_echo_timeout }} -lcp-echo-failure={{ ppp_echo_failure }} -{% if ppp_ipv4 %} -ipv4={{ ppp_ipv4 }} -{% endif %} -{% if client_ipv6_pool %} -ipv6=allow -{% endif %} - -{% if ppp_ipv6 %} -ipv6={{ ppp_ipv6 }} -{% if ppp_ipv6_intf_id %} -ipv6-intf-id={{ ppp_ipv6_intf_id }} -{% endif %} -{% if ppp_ipv6_peer_intf_id %} -ipv6-peer-intf-id={{ ppp_ipv6_peer_intf_id }} -{% endif %} -{% if ppp_ipv6_accept_peer_intf_id %} -ipv6-accept-peer-intf-id={{ ppp_ipv6_accept_peer_intf_id }} -{% endif %} -{% endif %} +{% if ppp_options.mru is defined and ppp_options.mru is not none %} +mru={{ ppp_options.mru }} +{% endif %} +mppe={{ ppp_options.mppe }} +lcp-echo-interval={{ ppp_options.lcp_echo_interval }} +lcp-echo-timeout={{ ppp_options.lcp_echo_timeout }} +lcp-echo-failure={{ ppp_options.lcp_echo_failure }} +{% if ppp_options.ipv4 is defined and ppp_options.ipv4 is not none %} +ipv4={{ ppp_options.ipv4 }} +{% endif %} +{# IPv6 #} +{% if ppp_options.ipv6 is defined and ppp_options.ipv6 is not none %} +ipv6={{ ppp_options.ipv6 }} +{% if ppp_options.ipv6_intf_id is defined and ppp_options.ipv6_intf_id is not none %} +ipv6-intf-id={{ ppp_options.ipv6_intf_id }} +{% endif %} +{% if ppp_options.ipv6_peer_intf_id is defined and ppp_options.ipv6_peer_intf_id is not none %} +ipv6-peer-intf-id={{ ppp_options.ipv6_peer_intf_id }} +{% endif %} +ipv6-accept-peer-intf-id={{ "1" if ppp_options.ipv6_accept_peer_intf_id is defined else "0" }} +{% endif %} +{# MTU #} mtu={{ mtu }} [pppoe] verbose=1 -ac-name={{ concentrator }} +ac-name={{ access_concentrator }} -{% if interfaces %} -{% for interface in interfaces %} -interface={{ interface.name }} -{% if interface.vlans %} -vlan-mon={{ interface.name }},{{ interface.vlans | join(',') }} +{% if interface %} +{% for iface in interface %} +interface={{ iface }} +{% if interface[iface].vlan_id is defined or interface[iface].vlan_range is defined %} +vlan-mon={{ iface }},{{ interface[iface].vlan_id | join(',') }},{{ interface[iface].vlan_range | join(',') }} interface=re:{{ interface.name }}\.\d+ +{% endif %} +{% endfor %} {% endif %} -{% endfor -%} -{% endif -%} -{% if svc_name %} -service-name={{ svc_name|join(',') }} +{% if service_name %} +service-name={{ service_name | join(',') }} {% endif -%} {% if pado_delay %} pado-delay={{ pado_delay }} {% endif %} -{% if limits_burst or limits_connections or limits_connections %} +{% if limits is defined %} [connlimit] -{% if limits_connections %} -limit={{ limits_connections }} -{% endif %} -{% if limits_burst %} -burst={{ limits_burst }} -{% endif %} -{% if limits_timeout %} -timeout={{ limits_timeout }} -{% endif %} -{% endif %} +{% if limits.connection_limit is defined and limits.connection_limit is not none %} +limit={{ limits.connection_limit }} +{% endif %} +{% if limits.burst is defined and limits.burst %} +burst={{ limits.burst }} +{% endif %} +{% if limits.timeout is defined and limits.timeout is not none %} +timeout={{ limits.timeout }} +{% endif %} +{% endif %} + +{# Common RADIUS shaper configuration #} +{% include 'accel-ppp/config_shaper_radius.j2' %} [cli] tcp=127.0.0.1:2001 diff --git a/data/templates/accel-ppp/sstp.config.tmpl b/data/templates/accel-ppp/sstp.config.tmpl index c9e4a1d7d..7ca7b1c1e 100644 --- a/data/templates/accel-ppp/sstp.config.tmpl +++ b/data/templates/accel-ppp/sstp.config.tmpl @@ -3,22 +3,16 @@ log_syslog sstp shaper -{% if auth_mode == 'local' %} -chap-secrets -{% elif auth_mode == 'radius' %} -radius -{% endif -%} +{# Common authentication backend definitions #} +{% include 'accel-ppp/config_modules_auth_mode.j2' %} ippool -ipv6pool -ipv6_nd -ipv6_dhcp - -{% for proto in auth_proto %} -{{proto}} -{% endfor %} +{# Common IPv6 definitions #} +{% include 'accel-ppp/config_modules_ipv6.j2' %} +{# Common authentication protocols (pap, chap ...) #} +{% include 'accel-ppp/config_modules_auth_protocols.j2' %} [core] -thread-count={{thread_cnt}} +thread-count={{ thread_count }} [common] single-session=replace @@ -35,112 +29,37 @@ disable verbose=1 ifname=sstp%d accept=ssl -ssl-ca-file={{ ssl_ca }} -ssl-pemfile={{ ssl_cert }} -ssl-keyfile={{ ssl_key }} - -{% if client_ip_pool %} -[ip-pool] -gw-ip-address={{ client_gateway }} -{% for subnet in client_ip_pool %} -{{ subnet }} -{% endfor %} -{% endif %} +ssl-ca-file={{ ssl.ca_cert_file }} +ssl-pemfile={{ ssl.cert_file }} +ssl-keyfile={{ ssl.key_file }} -{% if dnsv4 %} -[dns] -{% for dns in dnsv4 -%} -dns{{ loop.index }}={{ dns }} -{% endfor -%} -{% endif %} +{# Common IP pool definitions #} +{% include 'accel-ppp/config_ip_pool.j2' %} -{% if dnsv6 %} -[ipv6-dns] -{% for dns in dnsv6 -%} -{{ dns }} -{% endfor -%} -{% endif %} +{# Common IPv6 pool definitions #} +{% include 'accel-ppp/config_ipv6_pool.j2' %} +{# Common DNS name-server definition #} +{% include 'accel-ppp/config_name_server.j2' %} -{% if auth_mode == 'local' %} -[chap-secrets] -chap-secrets={{ chap_secrets_file }} -{% elif auth_mode == 'radius' %} -[radius] -verbose=1 -{% for r in radius_server %} -server={{ r.server }},{{ r.key }},auth-port={{ r.port }},acct-port={{ r.acct_port }},req-limit=0,fail-time={{ r.fail_time }} -{% endfor -%} - -acct-timeout={{ radius_acct_tmo }} -timeout={{ radius_timeout }} -max-try={{ radius_max_try }} - -{% if radius_nas_id %} -nas-identifier={{ radius_nas_id }} -{% endif -%} -{% if radius_nas_ip %} -nas-ip-address={{ radius_nas_ip }} -{% endif -%} -{% if radius_source_address %} -bind={{ radius_source_address }} -{% endif -%} - - -{% if radius_dynamic_author %} -dae-server={{ radius_dynamic_author.server }}:{{ radius_dynamic_author.port }},{{ radius_dynamic_author.key }} -{% endif -%} -{% endif %} -{% if client_gateway %} -gw-ip-address={{ client_gateway }} -{% endif %} +{# Common chap-secrets and RADIUS server/option definitions #} +{% include 'accel-ppp/config_chap_secrets_radius.j2' %} [ppp] verbose=1 check-ip=1 -{% if mtu %} +{# MTU #} mtu={{ mtu }} -{% endif -%} -{% if client_ipv6_pool %} +{% if client_ipv6_pool is defined %} ipv6=allow {% endif %} +mppe={{ ppp_options.mppe }} +lcp-echo-interval={{ ppp_options.lcp_echo_interval }} +lcp-echo-timeout={{ ppp_options.lcp_echo_timeout }} +lcp-echo-failure={{ ppp_options.lcp_echo_failure }} -{% if ppp_mppe %} -mppe={{ ppp_mppe }} -{% endif -%} -{% if ppp_echo_interval %} -lcp-echo-interval={{ ppp_echo_interval }} -{% endif -%} -{% if ppp_echo_failure %} -lcp-echo-failure={{ ppp_echo_failure }} -{% endif -%} -{% if ppp_echo_timeout %} -lcp-echo-timeout={{ ppp_echo_timeout }} -{% endif %} - -{% if client_ipv6_pool %} -[ipv6-pool] -{% for p in client_ipv6_pool %} -{{ p.prefix }},{{ p.mask }} -{% endfor %} -{% for p in client_ipv6_delegate_prefix %} -delegate={{ p.prefix }},{{ p.mask }} -{% endfor %} -{% endif %} - -{% if client_ipv6_delegate_prefix %} -[ipv6-dhcp] -verbose=1 -{% endif %} - -{% if radius_shaper_attr %} -[shaper] -verbose=1 -attr={{ radius_shaper_attr }} -{% if radius_shaper_vendor %} -vendor={{ radius_shaper_vendor }} -{% endif -%} -{% endif %} +{# Common RADIUS shaper configuration #} +{% include 'accel-ppp/config_shaper_radius.j2' %} [cli] tcp=127.0.0.1:2005 diff --git a/data/templates/firewall/nftables-nat.tmpl b/data/templates/firewall/nftables-nat.tmpl index 0c29f536b..286c21859 100644 --- a/data/templates/firewall/nftables-nat.tmpl +++ b/data/templates/firewall/nftables-nat.tmpl @@ -28,6 +28,9 @@ add rule ip raw NAT_CONNTRACK counter accept {% endif %} {% macro nat_rule(rule, chain) %} +{% set comment = "" %} +{% set base_log = "" %} + {% set src_addr = "ip saddr " + rule.source_address if rule.source_address %} {% set dst_addr = "ip daddr " + rule.dest_address if rule.dest_address %} @@ -45,13 +48,15 @@ add rule ip raw NAT_CONNTRACK counter accept {% set dst_port = "dport { " + rule.dest_port +" }" if rule.dest_port %} {% endif %} -{% set comment = "DST-NAT-" + rule.number %} - {% if chain == "PREROUTING" %} +{% set comment = "DST-NAT-" + rule.number %} +{% set base_log = "[NAT-DST-" + rule.number %} {% set interface = " iifname \"" + rule.interface_in + "\"" if rule.interface_in is defined and rule.interface_in != 'any' else '' %} {% set trns_addr = "dnat to " + rule.translation_address %} {% elif chain == "POSTROUTING" %} +{% set comment = "SRC-NAT-" + rule.number %} +{% set base_log = "[NAT-SRC-" + rule.number %} {% set interface = " oifname \"" + rule.interface_out + "\"" if rule.interface_out is defined and rule.interface_out != 'any' else '' %} {% if rule.translation_address == 'masquerade' %} {% set trns_addr = rule.translation_address %} @@ -72,7 +77,6 @@ add rule ip raw NAT_CONNTRACK counter accept {% endif %} {% if rule.log %} -{% set base_log = "[NAT-DST-" + rule.number %} {% if rule.exclude %} {% set log = base_log + "-EXCL]" %} {% elif rule.translation_address == 'masquerade' %} diff --git a/data/templates/ntp/ntp.conf.tmpl b/data/templates/ntp/ntp.conf.tmpl index df8157a41..bb0067bfb 100644 --- a/data/templates/ntp/ntp.conf.tmpl +++ b/data/templates/ntp/ntp.conf.tmpl @@ -36,4 +36,10 @@ interface ignore wildcard {% for address in listen_address %} interface listen {{ address }} {% endfor %} +interface listen 127.0.0.1 +interface listen ::1 +{% else %} +interface ignore wildcard +interface listen 127.0.0.1 +interface listen ::1 {% endif %} diff --git a/data/templates/vrrp/keepalived.conf.tmpl b/data/templates/vrrp/keepalived.conf.tmpl index 08b821f70..210621681 100644 --- a/data/templates/vrrp/keepalived.conf.tmpl +++ b/data/templates/vrrp/keepalived.conf.tmpl @@ -70,6 +70,14 @@ vrrp_instance {{ group.name }} { {% endfor -%} } + {% if group.virtual_addresses_excluded -%} + virtual_ipaddress_excluded { + {% for addr in group.virtual_addresses_excluded -%} + {{ addr }} + {% endfor -%} + } + {% endif -%} + {% if group.health_check_script -%} track_script { healthcheck_{{ group.name }} diff --git a/interface-definitions/include/accel-auth-local-users.xml.i b/interface-definitions/include/accel-auth-local-users.xml.i new file mode 100644 index 000000000..4dc6c6dff --- /dev/null +++ b/interface-definitions/include/accel-auth-local-users.xml.i @@ -0,0 +1,56 @@ +<!-- included start from accel-auth-local-users.xml.i --> +<node name="local-users"> + <properties> + <help>Local user authentication for PPPoE server</help> + </properties> + <children> + <tagNode name="username"> + <properties> + <help>User name for authentication</help> + </properties> + <children> + <leafNode name="disable"> + <properties> + <help>Option to disable a PPPoE Server user</help> + <valueless/> + </properties> + </leafNode> + <leafNode name="password"> + <properties> + <help>Password for authentication</help> + </properties> + </leafNode> + <leafNode name="static-ip"> + <properties> + <help>Static client IP address</help> + </properties> + <defaultValue>*</defaultValue> + </leafNode> + <node name="rate-limit"> + <properties> + <help>Upload/Download speed limits</help> + </properties> + <children> + <leafNode name="upload"> + <properties> + <help>Upload bandwidth limit in kbits/sec</help> + <constraint> + <validator name="numeric" argument="--range 1-65535"/> + </constraint> + </properties> + </leafNode> + <leafNode name="download"> + <properties> + <help>Download bandwidth limit in kbits/sec</help> + <constraint> + <validator name="numeric" argument="--range 1-65535"/> + </constraint> + </properties> + </leafNode> + </children> + </node> + </children> + </tagNode> + </children> +</node> +<!-- included end --> diff --git a/interface-definitions/include/accel-auth-mode.xml.i b/interface-definitions/include/accel-auth-mode.xml.i index e719112db..85c3c5e82 100644 --- a/interface-definitions/include/accel-auth-mode.xml.i +++ b/interface-definitions/include/accel-auth-mode.xml.i @@ -1,3 +1,4 @@ +<!-- included start from accel-auth-mode.xml.i --> <leafNode name="mode"> <properties> <help>Authentication mode used by this server</help> @@ -16,4 +17,6 @@ <list>local radius</list> </completionHelp> </properties> + <defaultValue>local</defaultValue> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/accel-auth-protocols.xml.i b/interface-definitions/include/accel-auth-protocols.xml.i new file mode 100644 index 000000000..a6899a4d8 --- /dev/null +++ b/interface-definitions/include/accel-auth-protocols.xml.i @@ -0,0 +1,31 @@ +<!-- included start from accel-auth-protocols.xml.i --> +<leafNode name="protocols"> + <properties> + <help>Authentication protocol for remote access peer SSTP VPN</help> + <completionHelp> + <list>pap chap mschap mschap-v2</list> + </completionHelp> + <valueHelp> + <format>pap</format> + <description>Authentication via PAP (Password Authentication Protocol)</description> + </valueHelp> + <valueHelp> + <format>chap</format> + <description>Authentication via CHAP (Challenge Handshake Authentication Protocol)</description> + </valueHelp> + <valueHelp> + <format>mschap</format> + <description>Authentication via MS-CHAP (Microsoft Challenge Handshake Authentication Protocol)</description> + </valueHelp> + <valueHelp> + <format>mschap-v2</format> + <description>Authentication via MS-CHAPv2 (Microsoft Challenge Handshake Authentication Protocol, version 2)</description> + </valueHelp> + <constraint> + <regex>(pap|chap|mschap|mschap-v2)</regex> + </constraint> + <multi/> + </properties> + <defaultValue>pap chap mschap mschap-v2</defaultValue> +</leafNode> +<!-- included end --> diff --git a/interface-definitions/include/accel-client-ip-pool-start-stop.xml.i b/interface-definitions/include/accel-client-ip-pool-start-stop.xml.i new file mode 100644 index 000000000..a92c315f1 --- /dev/null +++ b/interface-definitions/include/accel-client-ip-pool-start-stop.xml.i @@ -0,0 +1,18 @@ +<!-- included start from accel-client-ip-pool-start-stop.xml.i -->
+<leafNode name="start">
+ <properties>
+ <help>First IP address in the pool</help>
+ <constraint>
+ <validator name="ipv4-address"/>
+ </constraint>
+ </properties>
+</leafNode>
+<leafNode name="stop">
+ <properties>
+ <help>Last IP address in the pool</help>
+ <constraint>
+ <validator name="ipv4-address"/>
+ </constraint>
+ </properties>
+</leafNode>
+<!-- included end -->
diff --git a/interface-definitions/include/accel-client-ip-pool-subnet.xml.i b/interface-definitions/include/accel-client-ip-pool-subnet.xml.i new file mode 100644 index 000000000..8e9ca0e92 --- /dev/null +++ b/interface-definitions/include/accel-client-ip-pool-subnet.xml.i @@ -0,0 +1,16 @@ +<!-- included start from accel-client-ip-pool-subnet.xml.i --> +<leafNode name="subnet"> + <properties> + <help>Client IP subnet (CIDR notation)</help> + <valueHelp> + <format>ipv4net</format> + <description>IPv4 address and prefix length</description> + </valueHelp> + <constraint> + <validator name="ipv4-prefix"/> + </constraint> + <constraintErrorMessage>Not a valid CIDR formatted prefix</constraintErrorMessage> + <multi /> + </properties> +</leafNode> +<!-- included end --> diff --git a/interface-definitions/include/accel-client-ipv6-pool.xml.i b/interface-definitions/include/accel-client-ipv6-pool.xml.i index 455ada6ef..471ff714c 100644 --- a/interface-definitions/include/accel-client-ipv6-pool.xml.i +++ b/interface-definitions/include/accel-client-ipv6-pool.xml.i @@ -1,3 +1,4 @@ +<!-- included start from accel-client-ipv6-pool.xml.i --> <node name="client-ipv6-pool"> <properties> <help>Pool of client IPv6 addresses</help> @@ -57,3 +58,4 @@ </tagNode> </children> </node> +<!-- included end --> diff --git a/interface-definitions/include/accel-gateway-address.xml.i b/interface-definitions/include/accel-gateway-address.xml.i new file mode 100644 index 000000000..c45c8b532 --- /dev/null +++ b/interface-definitions/include/accel-gateway-address.xml.i @@ -0,0 +1,15 @@ +<!-- included start from accel-gateway-address.xml.i --> +<leafNode name="gateway-address"> + <properties> + <help>Gateway IP address</help> + <constraint> + <validator name="ipv4-address"/> + </constraint> + <constraintErrorMessage>invalid IPv4 address</constraintErrorMessage> + <valueHelp> + <format>ipv4</format> + <description>Default Gateway send to the client</description> + </valueHelp> + </properties> +</leafNode> +<!-- included end --> diff --git a/interface-definitions/include/accel-lcp-echo-interval-failure.xml.i b/interface-definitions/include/accel-lcp-echo-interval-failure.xml.i new file mode 100644 index 000000000..cccf4b4f2 --- /dev/null +++ b/interface-definitions/include/accel-lcp-echo-interval-failure.xml.i @@ -0,0 +1,20 @@ +<!-- included start from accel-lcp-echo-interval-failure.xml.i --> +<leafNode name="lcp-echo-interval"> + <properties> + <help>LCP echo-requests/sec</help> + <constraint> + <validator name="numeric" argument="--positive"/> + </constraint> + </properties> + <defaultValue>30</defaultValue> +</leafNode> +<leafNode name="lcp-echo-failure"> + <properties> + <help>Maximum number of Echo-Requests may be sent without valid reply</help> + <constraint> + <validator name="numeric" argument="--positive"/> + </constraint> + </properties> + <defaultValue>3</defaultValue> +</leafNode> +<!-- included end --> diff --git a/interface-definitions/include/accel-lcp-echo-timeout.xml.i b/interface-definitions/include/accel-lcp-echo-timeout.xml.i new file mode 100644 index 000000000..888fa9d41 --- /dev/null +++ b/interface-definitions/include/accel-lcp-echo-timeout.xml.i @@ -0,0 +1,11 @@ +<!-- included start from accel-lcp-echo-timeout.xml.i --> +<leafNode name="lcp-echo-timeout"> + <properties> + <help>Timeout in seconds to wait for any peer activity. If this option specified it turns on adaptive lcp echo functionality and "lcp-echo-failure" is not used.</help> + <constraint> + <validator name="numeric" argument="--positive"/> + </constraint> + </properties> + <defaultValue>0</defaultValue> +</leafNode> +<!-- included end --> diff --git a/interface-definitions/include/accel-mtu-128-16384.xml.i b/interface-definitions/include/accel-mtu-128-16384.xml.i new file mode 100644 index 000000000..72ab550f9 --- /dev/null +++ b/interface-definitions/include/accel-mtu-128-16384.xml.i @@ -0,0 +1,9 @@ + <leafNode name="mtu">
+ <properties>
+ <help>Maximum Transmission Unit (MTU) - default 1492</help>
+ <constraint>
+ <validator name="numeric" argument="--range 128-16384"/>
+ </constraint>
+ </properties>
+ <defaultValue>1492</defaultValue>
+ </leafNode>
diff --git a/interface-definitions/include/accel-name-server.xml.i b/interface-definitions/include/accel-name-server.xml.i index 82ed6771d..e46c75b52 100644 --- a/interface-definitions/include/accel-name-server.xml.i +++ b/interface-definitions/include/accel-name-server.xml.i @@ -1,3 +1,4 @@ +<!-- included start from accel-name-server.xml.i --> <leafNode name="name-server"> <properties> <help>Domain Name Server (DNS) propagated to client</help> @@ -16,3 +17,4 @@ <multi/> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/accel-ppp-mppe.xml.i b/interface-definitions/include/accel-ppp-mppe.xml.i new file mode 100644 index 000000000..b7f9cfd92 --- /dev/null +++ b/interface-definitions/include/accel-ppp-mppe.xml.i @@ -0,0 +1,26 @@ +<!-- included start from accel-ppp-mppe.xml.i --> +<leafNode name="mppe"> + <properties> + <help>Specifies mppe negotiation preferences</help> + <completionHelp> + <list>require prefer deny</list> + </completionHelp> + <valueHelp> + <format>require</format> + <description>send mppe request, if client rejects, drop the connection</description> + </valueHelp> + <valueHelp> + <format>prefer</format> + <description>send mppe request, if client rejects continue</description> + </valueHelp> + <valueHelp> + <format>deny</format> + <description>drop all mppe</description> + </valueHelp> + <constraint> + <regex>^(require|prefer|deny)$</regex> + </constraint> + </properties> + <defaultValue>prefer</defaultValue> +</leafNode> +<!-- included end --> diff --git a/interface-definitions/include/accel-radius-additions-rate-limit.xml.i b/interface-definitions/include/accel-radius-additions-rate-limit.xml.i new file mode 100644 index 000000000..23a4a51cf --- /dev/null +++ b/interface-definitions/include/accel-radius-additions-rate-limit.xml.i @@ -0,0 +1,26 @@ +<!-- included start from accel-radius-additions-rate-limit.xml.i --> +<node name="rate-limit"> + <properties> + <help>Upload/Download speed limits</help> + </properties> + <children> + <leafNode name="attribute"> + <properties> + <help>Specifies which radius attribute contains rate information. (default is Filter-Id)</help> + </properties> + <defaultValue>Filter-Id</defaultValue> + </leafNode> + <leafNode name="vendor"> + <properties> + <help>Specifies the vendor dictionary. (dictionary needs to be in /usr/share/accel-ppp/radius)</help> + </properties> + </leafNode> + <leafNode name="enable"> + <properties> + <help>Enables Bandwidth shaping via RADIUS</help> + <valueless /> + </properties> + </leafNode> + </children> +</node> +<!-- included end --> diff --git a/interface-definitions/include/accel-radius-additions.xml.i b/interface-definitions/include/accel-radius-additions.xml.i index f4db51b97..598fb73f8 100644 --- a/interface-definitions/include/accel-radius-additions.xml.i +++ b/interface-definitions/include/accel-radius-additions.xml.i @@ -1,3 +1,4 @@ +<!-- included start from accel-radius-additions.xml.i --> <node name="radius"> <children> <leafNode name="acct-interim-jitter"> @@ -26,6 +27,7 @@ <validator name="numeric" argument="--range 1-65535"/> </constraint> </properties> + <defaultValue>1813</defaultValue> </leafNode> <leafNode name="fail-time"> <properties> @@ -39,6 +41,7 @@ </constraint> <constraintErrorMessage>Fail time must be between 0 and 600 seconds</constraintErrorMessage> </properties> + <defaultValue>0</defaultValue> </leafNode> </children> </tagNode> @@ -54,6 +57,7 @@ </constraint> <constraintErrorMessage>Timeout must be between 1 and 60 seconds</constraintErrorMessage> </properties> + <defaultValue>3</defaultValue> </leafNode> <leafNode name="acct-timeout"> <properties> @@ -67,6 +71,7 @@ </constraint> <constraintErrorMessage>Timeout must be between 0 and 60 seconds</constraintErrorMessage> </properties> + <defaultValue>3</defaultValue> </leafNode> <leafNode name="max-try"> <properties> @@ -80,6 +85,7 @@ </constraint> <constraintErrorMessage>Maximum tries must be between 1 and 20</constraintErrorMessage> </properties> + <defaultValue>3</defaultValue> </leafNode> <leafNode name="nas-identifier"> <properties> @@ -123,7 +129,7 @@ </leafNode> <leafNode name="port"> <properties> - <help>Port for Dynamic Authorization Extension server (DM/CoA)</help> + <help>Port for Dynamic Authorization Extension server (DM/CoA) (default: 1700)</help> <valueHelp> <format>number</format> <description>TCP port</description> @@ -132,6 +138,7 @@ <validator name="numeric" argument="--range 1-65535"/> </constraint> </properties> + <defaultValue>1700</defaultValue> </leafNode> <leafNode name="key"> <properties> @@ -142,3 +149,4 @@ </node> </children> </node> +<!-- included end --> diff --git a/interface-definitions/include/accel-wins-server.xml.i b/interface-definitions/include/accel-wins-server.xml.i index 461a65ddf..6de032981 100644 --- a/interface-definitions/include/accel-wins-server.xml.i +++ b/interface-definitions/include/accel-wins-server.xml.i @@ -1,3 +1,4 @@ +<!-- included start from accel-wins-server.xml.i --> <leafNode name="wins-server"> <properties> <help>Windows Internet Name Service (WINS) servers propagated to client</help> @@ -11,3 +12,4 @@ <multi/> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/address-ipv4-ipv6-dhcp.xml.i b/interface-definitions/include/address-ipv4-ipv6-dhcp.xml.i index cca824d89..7805110bc 100644 --- a/interface-definitions/include/address-ipv4-ipv6-dhcp.xml.i +++ b/interface-definitions/include/address-ipv4-ipv6-dhcp.xml.i @@ -1,3 +1,4 @@ +<!-- included start from address-ipv4-ipv6-dhcp.xml.i --> <leafNode name="address"> <properties> <help>IP address</help> @@ -27,3 +28,4 @@ <multi/> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/address-ipv4-ipv6.xml.i b/interface-definitions/include/address-ipv4-ipv6.xml.i index a891085bd..b11610104 100644 --- a/interface-definitions/include/address-ipv4-ipv6.xml.i +++ b/interface-definitions/include/address-ipv4-ipv6.xml.i @@ -1,3 +1,4 @@ +<!-- included start from address-ipv4-ipv6.xml.i --> <leafNode name="address"> <properties> <help>IP address</help> @@ -15,3 +16,4 @@ <multi/> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/bgp-afi-aggregate-address.xml.i b/interface-definitions/include/bgp-afi-aggregate-address.xml.i index 050ee0074..c33d1097c 100644 --- a/interface-definitions/include/bgp-afi-aggregate-address.xml.i +++ b/interface-definitions/include/bgp-afi-aggregate-address.xml.i @@ -1,3 +1,4 @@ +<!-- included start from bgp-afi-aggregate-address.xml.i --> <leafNode name="as-set"> <properties> <help>Generate AS-set path information for this aggregate address</help> @@ -10,3 +11,4 @@ <valueless/> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/bgp-afi-redistribute-metric-route-map.xml.i b/interface-definitions/include/bgp-afi-redistribute-metric-route-map.xml.i index 9b3f7a008..f35f13e8d 100644 --- a/interface-definitions/include/bgp-afi-redistribute-metric-route-map.xml.i +++ b/interface-definitions/include/bgp-afi-redistribute-metric-route-map.xml.i @@ -1,3 +1,4 @@ +<!-- included start from bgp-afi-redistribute-metric-route-map.xml.i --> <leafNode name="metric"> <properties> <help>Metric for redistributed routes</help> @@ -15,3 +16,4 @@ </completionHelp> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/bgp-neighbor-afi-ipv4-unicast.xml.i b/interface-definitions/include/bgp-neighbor-afi-ipv4-unicast.xml.i index 74afb8851..f1a61d669 100644 --- a/interface-definitions/include/bgp-neighbor-afi-ipv4-unicast.xml.i +++ b/interface-definitions/include/bgp-neighbor-afi-ipv4-unicast.xml.i @@ -1,3 +1,4 @@ +<!-- included start from bgp-neighbor-afi-ipv4-unicast.xml.i --> <node name="ipv4-unicast"> <properties> <help>IPv4 BGP neighbor parameters</help> @@ -283,3 +284,4 @@ </leafNode> </children> </node> +<!-- included end --> diff --git a/interface-definitions/include/bgp-neighbor-afi-ipv6-unicast.xml.i b/interface-definitions/include/bgp-neighbor-afi-ipv6-unicast.xml.i index e95cb6dd8..dcdc0eb66 100644 --- a/interface-definitions/include/bgp-neighbor-afi-ipv6-unicast.xml.i +++ b/interface-definitions/include/bgp-neighbor-afi-ipv6-unicast.xml.i @@ -1,3 +1,4 @@ +<!-- included start from bgp-neighbor-afi-ipv6-unicast.xml.i --> <node name="ipv6-unicast"> <properties> <help>IPv6 BGP neighbor parameters</help> @@ -320,3 +321,4 @@ </leafNode> </children> </node> +<!-- included end --> diff --git a/interface-definitions/include/bgp-peer-group-afi-ipv4-unicast.xml.i b/interface-definitions/include/bgp-peer-group-afi-ipv4-unicast.xml.i index df051ace5..c6ba2630f 100644 --- a/interface-definitions/include/bgp-peer-group-afi-ipv4-unicast.xml.i +++ b/interface-definitions/include/bgp-peer-group-afi-ipv4-unicast.xml.i @@ -1,3 +1,4 @@ +<!-- included start from bgp-peer-group-afi-ipv4-unicast.xml.i --> <node name="ipv4-unicast"> <properties> <help>IPv4 BGP peer group parameters</help> @@ -299,3 +300,4 @@ </leafNode> </children> </node> +<!-- included end --> diff --git a/interface-definitions/include/bgp-peer-group-afi-ipv6-unicast.xml.i b/interface-definitions/include/bgp-peer-group-afi-ipv6-unicast.xml.i index a381e02f0..933065dde 100644 --- a/interface-definitions/include/bgp-peer-group-afi-ipv6-unicast.xml.i +++ b/interface-definitions/include/bgp-peer-group-afi-ipv6-unicast.xml.i @@ -1,3 +1,4 @@ +<!-- included start from bgp-peer-group-afi-ipv6-unicast.xml.i --> <node name="ipv6-unicast"> <properties> <help>IPv6 BGP neighbor parameters</help> @@ -315,3 +316,4 @@ </leafNode> </children> </node> +<!-- included end --> diff --git a/interface-definitions/include/dhcp-options.xml.i b/interface-definitions/include/dhcp-options.xml.i index 9989291fc..e33022361 100644 --- a/interface-definitions/include/dhcp-options.xml.i +++ b/interface-definitions/include/dhcp-options.xml.i @@ -1,3 +1,4 @@ +<!-- included start from dhcp-options.xml.i --> <node name="dhcp-options"> <properties> <help>DHCP client settings/options</help> @@ -20,3 +21,4 @@ </leafNode> </children> </node> +<!-- included end --> diff --git a/interface-definitions/include/dhcpv6-options.xml.i b/interface-definitions/include/dhcpv6-options.xml.i index b0a806806..9a1016956 100644 --- a/interface-definitions/include/dhcpv6-options.xml.i +++ b/interface-definitions/include/dhcpv6-options.xml.i @@ -1,3 +1,4 @@ +<!-- included start from dhcpv6-options.xml.i --> <node name="dhcpv6-options"> <properties> <help>DHCPv6 client settings/options</help> @@ -84,3 +85,4 @@ </leafNode> </children> </node> +<!-- included end --> diff --git a/interface-definitions/include/interface-arp-cache-timeout.xml.i b/interface-definitions/include/interface-arp-cache-timeout.xml.i index e65321158..6dfebfee4 100644 --- a/interface-definitions/include/interface-arp-cache-timeout.xml.i +++ b/interface-definitions/include/interface-arp-cache-timeout.xml.i @@ -1,3 +1,4 @@ +<!-- included start from interface-arp-cache-timeout.xml.i --> <leafNode name="arp-cache-timeout"> <properties> <help>ARP cache entry timeout in seconds</help> @@ -12,3 +13,4 @@ </properties> <defaultValue>30</defaultValue> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/interface-description.xml.i b/interface-definitions/include/interface-description.xml.i index 961533e26..daf09d8bc 100644 --- a/interface-definitions/include/interface-description.xml.i +++ b/interface-definitions/include/interface-description.xml.i @@ -1,3 +1,4 @@ +<!-- included start from interface-description.xml.i --> <leafNode name="description"> <properties> <help>Interface specific description</help> @@ -7,3 +8,4 @@ <constraintErrorMessage>Description too long (limit 256 characters)</constraintErrorMessage> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/interface-dial-on-demand.xml.i b/interface-definitions/include/interface-dial-on-demand.xml.i index c14ddf6f5..8fba8099d 100644 --- a/interface-definitions/include/interface-dial-on-demand.xml.i +++ b/interface-definitions/include/interface-dial-on-demand.xml.i @@ -1,6 +1,8 @@ +<!-- included start from interface-dial-on-demand.xml.i --> <leafNode name="connect-on-demand"> <properties> <help>Establishment connection automatically when traffic is sent</help> <valueless/> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/interface-disable-arp-filter.xml.i b/interface-definitions/include/interface-disable-arp-filter.xml.i index ec3f51b2d..4de3ca893 100644 --- a/interface-definitions/include/interface-disable-arp-filter.xml.i +++ b/interface-definitions/include/interface-disable-arp-filter.xml.i @@ -1,6 +1,8 @@ +<!-- included start from interface-disable-arp-filter.xml.i --> <leafNode name="disable-arp-filter"> <properties> <help>Disable ARP filter on this interface</help> <valueless/> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/interface-disable-link-detect.xml.i b/interface-definitions/include/interface-disable-link-detect.xml.i index 619cd03b0..4298b4b5d 100644 --- a/interface-definitions/include/interface-disable-link-detect.xml.i +++ b/interface-definitions/include/interface-disable-link-detect.xml.i @@ -1,6 +1,8 @@ +<!-- included start from interface-disable-link-detect.xml.i --> <leafNode name="disable-link-detect"> <properties> <help>Ignore link state changes</help> <valueless/> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/interface-disable.xml.i b/interface-definitions/include/interface-disable.xml.i index 7bd3df5da..5d73d54ba 100644 --- a/interface-definitions/include/interface-disable.xml.i +++ b/interface-definitions/include/interface-disable.xml.i @@ -1,6 +1,8 @@ +<!-- included start from interface-disable.xml.i --> <leafNode name="disable"> <properties> <help>Administratively disable interface</help> <valueless/> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/interface-enable-arp-accept.xml.i b/interface-definitions/include/interface-enable-arp-accept.xml.i index 69f26b322..688b3572e 100644 --- a/interface-definitions/include/interface-enable-arp-accept.xml.i +++ b/interface-definitions/include/interface-enable-arp-accept.xml.i @@ -1,6 +1,8 @@ +<!-- included start from interface-enable-arp-accept.xml.i --> <leafNode name="enable-arp-accept"> <properties> <help>Enable ARP accept on this interface</help> <valueless/> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/interface-enable-arp-announce.xml.i b/interface-definitions/include/interface-enable-arp-announce.xml.i index 8d51874c1..c84bb7ea9 100644 --- a/interface-definitions/include/interface-enable-arp-announce.xml.i +++ b/interface-definitions/include/interface-enable-arp-announce.xml.i @@ -1,6 +1,8 @@ +<!-- included start from interface-enable-arp-announce.xml.i --> <leafNode name="enable-arp-announce"> <properties> <help>Enable ARP announce on this interface</help> <valueless/> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/interface-enable-arp-ignore.xml.i b/interface-definitions/include/interface-enable-arp-ignore.xml.i index 9adc0f17e..741771a89 100644 --- a/interface-definitions/include/interface-enable-arp-ignore.xml.i +++ b/interface-definitions/include/interface-enable-arp-ignore.xml.i @@ -1,6 +1,8 @@ +<!-- included start from interface-enable-arp-ignore.xml.i --> <leafNode name="enable-arp-ignore"> <properties> <help>Enable ARP ignore on this interface</help> <valueless/> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/interface-enable-proxy-arp.xml.i b/interface-definitions/include/interface-enable-proxy-arp.xml.i index 14ab08875..08351e673 100644 --- a/interface-definitions/include/interface-enable-proxy-arp.xml.i +++ b/interface-definitions/include/interface-enable-proxy-arp.xml.i @@ -1,6 +1,8 @@ +<!-- included start from interface-enable-proxy-arp.xml.i --> <leafNode name="enable-proxy-arp"> <properties> <help>Enable proxy-arp on this interface</help> <valueless/> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/interface-hw-id.xml.i b/interface-definitions/include/interface-hw-id.xml.i index 318ddd1c4..af58fae3c 100644 --- a/interface-definitions/include/interface-hw-id.xml.i +++ b/interface-definitions/include/interface-hw-id.xml.i @@ -1,3 +1,4 @@ +<!-- included start from interface-hw-id.xml.i --> <leafNode name="hw-id"> <properties> <help>Associate Ethernet Interface with given Media Access Control (MAC) address</help> @@ -10,3 +11,4 @@ </constraint> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/interface-ipv4.xml.i b/interface-definitions/include/interface-ipv4.xml.i index 15932a9d3..551059247 100644 --- a/interface-definitions/include/interface-ipv4.xml.i +++ b/interface-definitions/include/interface-ipv4.xml.i @@ -1,3 +1,4 @@ +<!-- included start from interface-ipv4.xml.i --> <node name="ip"> <properties> <help>IPv4 routing parameters</help> @@ -9,3 +10,4 @@ #include <include/interface-enable-arp-ignore.xml.i> </children> </node> +<!-- included end --> diff --git a/interface-definitions/include/interface-ipv6.xml.i b/interface-definitions/include/interface-ipv6.xml.i index 23362f75a..c9299890b 100644 --- a/interface-definitions/include/interface-ipv6.xml.i +++ b/interface-definitions/include/interface-ipv6.xml.i @@ -1,3 +1,4 @@ +<!-- included start from interface-ipv6.xml.i --> <node name="ipv6"> <properties> <help>IPv6 routing parameters</help> @@ -8,3 +9,4 @@ #include <include/ipv6-dup-addr-detect-transmits.xml.i> </children> </node> +<!-- included end --> diff --git a/interface-definitions/include/interface-mac.xml.i b/interface-definitions/include/interface-mac.xml.i index 7b2456236..e277de85c 100644 --- a/interface-definitions/include/interface-mac.xml.i +++ b/interface-definitions/include/interface-mac.xml.i @@ -1,3 +1,4 @@ +<!-- included start from mac.xml.i --> <leafNode name="mac"> <properties> <help>Media Access Control (MAC) address</help> @@ -10,3 +11,4 @@ </constraint> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/interface-mtu-1200-9000.xml.i b/interface-definitions/include/interface-mtu-1200-9000.xml.i index de48db65e..387e60fa5 100644 --- a/interface-definitions/include/interface-mtu-1200-9000.xml.i +++ b/interface-definitions/include/interface-mtu-1200-9000.xml.i @@ -1,3 +1,4 @@ +<!-- included start from interface-mtu-1200-9000.xml.i --> <leafNode name="mtu"> <properties> <help>Maximum Transmission Unit (MTU)</help> @@ -12,3 +13,4 @@ </properties> <defaultValue>1500</defaultValue> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/interface-mtu-1450-9000.xml.i b/interface-definitions/include/interface-mtu-1450-9000.xml.i index d15987394..3fc961051 100644 --- a/interface-definitions/include/interface-mtu-1450-9000.xml.i +++ b/interface-definitions/include/interface-mtu-1450-9000.xml.i @@ -1,3 +1,4 @@ +<!-- included start from interface-mtu-1450-9000.xml.i --> <leafNode name="mtu"> <properties> <help>Maximum Transmission Unit (MTU)</help> @@ -12,3 +13,4 @@ </properties> <defaultValue>1500</defaultValue> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/interface-mtu-64-8024.xml.i b/interface-definitions/include/interface-mtu-64-8024.xml.i index e60867e35..f51e098c1 100644 --- a/interface-definitions/include/interface-mtu-64-8024.xml.i +++ b/interface-definitions/include/interface-mtu-64-8024.xml.i @@ -1,3 +1,4 @@ +<!-- included start from interface-mtu-68-8024.xml.i --> <leafNode name="mtu"> <properties> <help>Maximum Transmission Unit (MTU)</help> @@ -12,3 +13,4 @@ </properties> <defaultValue>1500</defaultValue> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/interface-mtu-68-1500.xml.i b/interface-definitions/include/interface-mtu-68-1500.xml.i index d47efd2c9..0563e0023 100644 --- a/interface-definitions/include/interface-mtu-68-1500.xml.i +++ b/interface-definitions/include/interface-mtu-68-1500.xml.i @@ -1,3 +1,4 @@ +<!-- included start from interface-mtu-68-1500.xml.i --> <leafNode name="mtu"> <properties> <help>Maximum Transmission Unit (MTU)</help> @@ -12,3 +13,4 @@ </properties> <defaultValue>1500</defaultValue> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/interface-mtu-68-9000.xml.i b/interface-definitions/include/interface-mtu-68-9000.xml.i index 8fae2043c..82d0ed82b 100644 --- a/interface-definitions/include/interface-mtu-68-9000.xml.i +++ b/interface-definitions/include/interface-mtu-68-9000.xml.i @@ -1,3 +1,4 @@ +<!-- included start from interface-mtu-68-9000.xml.i --> <leafNode name="mtu"> <properties> <help>Maximum Transmission Unit (MTU)</help> @@ -12,3 +13,4 @@ </properties> <defaultValue>1500</defaultValue> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/interface-proxy-arp-pvlan.xml.i b/interface-definitions/include/interface-proxy-arp-pvlan.xml.i index 7e72b3800..02b96e353 100644 --- a/interface-definitions/include/interface-proxy-arp-pvlan.xml.i +++ b/interface-definitions/include/interface-proxy-arp-pvlan.xml.i @@ -1,6 +1,8 @@ +<!-- included start from interface-proxy-arp-pvlan.xml.i --> <leafNode name="proxy-arp-pvlan"> <properties> <help>Enable private VLAN proxy ARP on this interface</help> <valueless/> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/interface-vrf.xml.i b/interface-definitions/include/interface-vrf.xml.i index 355e7f0f3..e3d6b53e0 100644 --- a/interface-definitions/include/interface-vrf.xml.i +++ b/interface-definitions/include/interface-vrf.xml.i @@ -1,3 +1,4 @@ +<!-- included start from interface-vrf.xml.i --> <leafNode name="vrf"> <properties> <help>VRF instance name</help> @@ -10,3 +11,4 @@ </completionHelp> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/ipv6-address.xml.i b/interface-definitions/include/ipv6-address.xml.i index 34f54e4c1..26ac1d374 100644 --- a/interface-definitions/include/ipv6-address.xml.i +++ b/interface-definitions/include/ipv6-address.xml.i @@ -1,3 +1,4 @@ +<!-- included start from ipv6-address.xml.i --> <node name="address"> <children> <leafNode name="autoconf"> @@ -27,3 +28,4 @@ </leafNode> </children> </node> +<!-- included end --> diff --git a/interface-definitions/include/ipv6-disable-forwarding.xml.i b/interface-definitions/include/ipv6-disable-forwarding.xml.i index 3f90c7e34..14d9eada9 100644 --- a/interface-definitions/include/ipv6-disable-forwarding.xml.i +++ b/interface-definitions/include/ipv6-disable-forwarding.xml.i @@ -1,6 +1,8 @@ +<!-- included start from ipv6-disable-forwarding.xml.i --> <leafNode name="disable-forwarding"> <properties> <help>Disable IPv6 forwarding on this interface</help> <valueless/> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/ipv6-dup-addr-detect-transmits.xml.i b/interface-definitions/include/ipv6-dup-addr-detect-transmits.xml.i index 728187560..61e6669c4 100644 --- a/interface-definitions/include/ipv6-dup-addr-detect-transmits.xml.i +++ b/interface-definitions/include/ipv6-dup-addr-detect-transmits.xml.i @@ -1,3 +1,4 @@ +<!-- included start from ipv6-dup-addr-detect-transmits.xml.i --> <leafNode name="dup-addr-detect-transmits"> <properties> <help>Number of NS messages to send while performing DAD (default: 1)</help> @@ -14,3 +15,4 @@ </constraint> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/isis-redistribute-ipv4.xml.i b/interface-definitions/include/isis-redistribute-ipv4.xml.i index f90900da1..a40d8dfc2 100644 --- a/interface-definitions/include/isis-redistribute-ipv4.xml.i +++ b/interface-definitions/include/isis-redistribute-ipv4.xml.i @@ -1,3 +1,4 @@ +<!-- included start from isis-redistribute-ipv4.xml.i --> <node name="level-1"> <properties> <help>Redistribute into level-1</help> @@ -80,3 +81,4 @@ </tagNode> </children> </node> +<!-- included end --> diff --git a/interface-definitions/include/nat-address.xml.i b/interface-definitions/include/nat-address.xml.i index 933dae07b..846ef3dec 100644 --- a/interface-definitions/include/nat-address.xml.i +++ b/interface-definitions/include/nat-address.xml.i @@ -1,3 +1,4 @@ +<!-- included start from nat-address.xml.i --> <leafNode name="address"> <properties> <help>IP address, subnet, or range</help> @@ -35,3 +36,4 @@ </constraint> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/nat-interface.xml.i b/interface-definitions/include/nat-interface.xml.i index c49483297..e42003530 100644 --- a/interface-definitions/include/nat-interface.xml.i +++ b/interface-definitions/include/nat-interface.xml.i @@ -1,3 +1,4 @@ +<!-- included start from nat-interface.xml.i --> <leafNode name="outbound-interface"> <properties> <help>Outbound interface of NAT traffic</help> @@ -7,3 +8,4 @@ </completionHelp> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/nat-port.xml.i b/interface-definitions/include/nat-port.xml.i index 24803ae05..e417d13cc 100644 --- a/interface-definitions/include/nat-port.xml.i +++ b/interface-definitions/include/nat-port.xml.i @@ -1,3 +1,4 @@ +<!-- included start from nat-port.xml.i --> <leafNode name="port"> <properties> <help>Port number</help> @@ -15,3 +16,4 @@ </valueHelp> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/nat-rule.xml.i b/interface-definitions/include/nat-rule.xml.i index a2d058479..f91834ae0 100644 --- a/interface-definitions/include/nat-rule.xml.i +++ b/interface-definitions/include/nat-rule.xml.i @@ -1,3 +1,4 @@ +<!-- included start from nat-rule.xml.i --> <tagNode name="rule"> <properties> <help>Rule number for NAT</help> @@ -301,3 +302,4 @@ </node> </children> </tagNode> +<!-- included end --> diff --git a/interface-definitions/include/nat-translation-port.xml.i b/interface-definitions/include/nat-translation-port.xml.i index 93de471e3..db8803dac 100644 --- a/interface-definitions/include/nat-translation-port.xml.i +++ b/interface-definitions/include/nat-translation-port.xml.i @@ -1,3 +1,4 @@ +<!-- included start from nat-translation-port.xml.i --> <leafNode name="port"> <properties> <help>Port number</help> @@ -11,3 +12,4 @@ </valueHelp> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/port-number.xml.i b/interface-definitions/include/port-number.xml.i index 29d2f55fd..d94523e1e 100644 --- a/interface-definitions/include/port-number.xml.i +++ b/interface-definitions/include/port-number.xml.i @@ -1,3 +1,4 @@ +<!-- included start from port-number.xml.i --> <leafNode name="port"> <properties> <help>Port number used to establish connection</help> @@ -10,3 +11,4 @@ </constraint> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/radius-server.xml.i b/interface-definitions/include/radius-server.xml.i index 047728233..b78ebb306 100644 --- a/interface-definitions/include/radius-server.xml.i +++ b/interface-definitions/include/radius-server.xml.i @@ -1,3 +1,4 @@ +<!-- included start from radius-server.xml.i --> <node name="radius"> <properties> <help>RADIUS based user authentication</help> @@ -49,8 +50,10 @@ <validator name="numeric" argument="--range 1-65535"/> </constraint> </properties> + <defaultValue>1812</defaultValue> </leafNode> </children> </tagNode> </children> </node> +<!-- included end --> diff --git a/interface-definitions/include/rip-redistribute.xml.i b/interface-definitions/include/rip-redistribute.xml.i index d94dfa5a8..d287c1c2b 100644 --- a/interface-definitions/include/rip-redistribute.xml.i +++ b/interface-definitions/include/rip-redistribute.xml.i @@ -1,3 +1,4 @@ +<!-- included start from rip-redistribute.xml.i --> <leafNode name="metric"> <properties> <help>Metric for redistributed routes</help> @@ -22,3 +23,4 @@ </completionHelp> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/source-address-ipv4-ipv6.xml.i b/interface-definitions/include/source-address-ipv4-ipv6.xml.i index 6d2d77c95..6716e0ae4 100644 --- a/interface-definitions/include/source-address-ipv4-ipv6.xml.i +++ b/interface-definitions/include/source-address-ipv4-ipv6.xml.i @@ -1,3 +1,4 @@ +<!-- included start from source-address-ipv4-ipv6.xml.i --> <leafNode name="source-address"> <properties> <help>IPv4/IPv6 source address</help> @@ -15,3 +16,4 @@ </constraint> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/source-interface-ethernet.xml.i b/interface-definitions/include/source-interface-ethernet.xml.i index ad90bc4ac..d641f3cb1 100644 --- a/interface-definitions/include/source-interface-ethernet.xml.i +++ b/interface-definitions/include/source-interface-ethernet.xml.i @@ -1,3 +1,4 @@ +<!-- included start from source-interface-ethernet.xml.i --> <leafNode name="source-interface"> <properties> <help>Physical interface the traffic will go through</help> @@ -10,3 +11,4 @@ </completionHelp> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/source-interface.xml.i b/interface-definitions/include/source-interface.xml.i index ae579c2a6..e6f0b69a1 100644 --- a/interface-definitions/include/source-interface.xml.i +++ b/interface-definitions/include/source-interface.xml.i @@ -1,3 +1,4 @@ +<!-- included start from source-interface.xml.i --> <leafNode name="source-interface"> <properties> <help>Physical interface used for connection</help> @@ -10,3 +11,4 @@ </completionHelp> </properties> </leafNode> +<!-- included end --> diff --git a/interface-definitions/include/vif-s.xml.i b/interface-definitions/include/vif-s.xml.i index cd0afe742..3a04b10d9 100644 --- a/interface-definitions/include/vif-s.xml.i +++ b/interface-definitions/include/vif-s.xml.i @@ -1,3 +1,4 @@ +<!-- included start from vif-s.xml.i --> <tagNode name="vif-s"> <properties> <help>QinQ TAG-S Virtual Local Area Network (VLAN) ID</help> @@ -66,3 +67,4 @@ </tagNode> </children> </tagNode> +<!-- included end --> diff --git a/interface-definitions/include/vif.xml.i b/interface-definitions/include/vif.xml.i index 919e4d493..15c453fcc 100644 --- a/interface-definitions/include/vif.xml.i +++ b/interface-definitions/include/vif.xml.i @@ -1,3 +1,4 @@ +<!-- included start from vif.xml.i --> <tagNode name="vif"> <properties> <help>Virtual Local Area Network (VLAN) ID</help> @@ -64,3 +65,4 @@ #include <include/interface-mtu-68-9000.xml.i> </children> </tagNode> +<!-- included end --> diff --git a/interface-definitions/service_pppoe-server.xml.in b/interface-definitions/service_pppoe-server.xml.in index 64fd6e4ef..6d11f41a0 100644 --- a/interface-definitions/service_pppoe-server.xml.in +++ b/interface-definitions/service_pppoe-server.xml.in @@ -8,19 +8,6 @@ <priority>900</priority> </properties> <children> - <node name="snmp"> - <properties> - <help>Enable SNMP</help> - </properties> - <children> - <leafNode name="master-agent"> - <properties> - <help>enable SNMP master agent mode</help> - <valueless /> - </properties> - </leafNode> - </children> - </node> <leafNode name="access-concentrator"> <properties> <help>Access concentrator name</help> @@ -29,142 +16,43 @@ </constraint> <constraintErrorMessage>access-concentrator name limited to alphanumerical characters only (max. 100)</constraintErrorMessage> </properties> - </leafNode> - <leafNode name="session-control"> - <properties> - <help>control sessions count</help> - <constraint> - <regex>(deny|disable)</regex> - </constraint> - <constraintErrorMessage>Invalid value</constraintErrorMessage> - <valueHelp> - <format>disable</format> - <description>Disables session control</description> - </valueHelp> - <valueHelp> - <format>deny</format> - <description>Deny second session authorization</description> - </valueHelp> - <completionHelp> - <list>deny disable</list> - </completionHelp> - </properties> + <defaultValue>vyos-ac</defaultValue> </leafNode> <node name="authentication"> <properties> <help>Authentication for remote access PPPoE Server</help> </properties> <children> - <node name="local-users"> - <properties> - <help>Local user authentication for PPPoE server</help> - </properties> - <children> - <tagNode name="username"> - <properties> - <help>User name for authentication</help> - </properties> - <children> - <leafNode name="disable"> - <properties> - <help>Option to disable a PPPoE Server user</help> - </properties> - </leafNode> - <leafNode name="password"> - <properties> - <help>Password for authentication</help> - </properties> - </leafNode> - <leafNode name="static-ip"> - <properties> - <help>Static client IP address</help> - </properties> - </leafNode> - <node name="rate-limit"> - <properties> - <help>Upload/Download speed limits</help> - </properties> - <children> - <leafNode name="upload"> - <properties> - <help>Upload bandwidth limit in kbits/sec</help> - <constraint> - <validator name="numeric" argument="--range 1-65535"/> - </constraint> - </properties> - </leafNode> - <leafNode name="download"> - <properties> - <help>Download bandwidth limit in kbits/sec</help> - <constraint> - <validator name="numeric" argument="--range 1-65535"/> - </constraint> - </properties> - </leafNode> - </children> - </node> - </children> - </tagNode> - </children> - </node> + #include <include/accel-auth-local-users.xml.i> #include <include/accel-auth-mode.xml.i> + #include <include/accel-auth-protocols.xml.i> #include <include/radius-server.xml.i> #include <include/accel-radius-additions.xml.i> <node name="radius"> <children> - <node name="rate-limit"> + #include <include/accel-radius-additions-rate-limit.xml.i> + <leafNode name="called-sid-format"> <properties> - <help>Upload/Download speed limits</help> + <help>Format of Called-Station-Id attribute</help> + <completionHelp> + <list>ifname ifname:mac</list> + </completionHelp> + <constraint> + <regex>(ifname|ifname:mac)</regex> + </constraint> + <constraintErrorMessage>Invalid Called-Station-Id format</constraintErrorMessage> + <valueHelp> + <format>ifname</format> + <description>NAS-Port-Id - should contain root interface name (NAS-Port-Id=eth1)</description> + </valueHelp> + <valueHelp> + <format>ifname:mac</format> + <description>NAS-Port-Id - should contain root interface name and mac address (NAS-Port-Id=eth1:00:00:00:00:00:00)</description> + </valueHelp> </properties> - <children> - <leafNode name="attribute"> - <properties> - <help>Specifies which radius attribute contains rate information. (default is Filter-Id)</help> - </properties> - </leafNode> - <leafNode name="vendor"> - <properties> - <help>Specifies the vendor dictionary. (dictionary needs to be in /usr/share/accel-ppp/radius)</help> - </properties> - </leafNode> - <leafNode name="enable"> - <properties> - <help>Enables Bandwidth shaping via RADIUS</help> - <valueless /> - </properties> - </leafNode> - </children> - </node> + </leafNode> </children> </node> - <leafNode name="protocols"> - <properties> - <help>Authentication protocol</help> - <valueHelp> - <format>pap</format> - <description>Allow PAP authentication [Password Authentication Protocol]</description> - </valueHelp> - <valueHelp> - <format>chap</format> - <description>Allow CHAP authentication [Challenge Handshake Authentication Protocol]</description> - </valueHelp> - <valueHelp> - <format>mschap</format> - <description>Allow MS-CHAP authentication [Microsoft Challenge Handshake Authentication Protocol, Version 1]</description> - </valueHelp> - <valueHelp> - <format>mschap-v2</format> - <description>Allow MS-CHAPv2 authentication [Microsoft Challenge Handshake Authentication Protocol, Version 2]</description> - </valueHelp> - <constraint> - <regex>(pap|chap|mschap|mschap-v2)</regex> - </constraint> - <completionHelp> - <list>pap chap mschap mschap-v2</list> - </completionHelp> - <multi /> - </properties> - </leafNode> </children> </node> <node name="client-ip-pool"> @@ -172,32 +60,8 @@ <help>Pool of client IP addresses (must be within a /24)</help> </properties> <children> - <leafNode name="start"> - <properties> - <help>First IP address in the pool</help> - <constraint> - <validator name="ipv4-address"/> - </constraint> - </properties> - </leafNode> - <leafNode name="stop"> - <properties> - <help>Last IP address in the pool</help> - <constraint> - <validator name="ipv4-address"/> - </constraint> - </properties> - </leafNode> - <leafNode name="subnet"> - <properties> - <help>Client IP subnet (CIDR notation)</help> - <constraint> - <validator name="ipv4-prefix"/> - </constraint> - <constraintErrorMessage>Not a valid CIDR formatted prefix</constraintErrorMessage> - <multi /> - </properties> - </leafNode> + #include <include/accel-client-ip-pool-start-stop.xml.i> + #include <include/accel-client-ip-pool-subnet.xml.i> </children> </node> #include <include/accel-client-ipv6-pool.xml.i> @@ -214,10 +78,10 @@ <properties> <help>VLAN monitor for the automatic creation of vlans (user per vlan)</help> <constraint> - <validator name="numeric" argument="--range 1-4096"/> - </constraint> - <constraintErrorMessage>VLAN ID needs to be between 1 and 4096</constraintErrorMessage> - <multi /> + <validator name="numeric" argument="--range 1-4096"/> + </constraint> + <constraintErrorMessage>VLAN ID needs to be between 1 and 4096</constraintErrorMessage> + <multi/> </properties> </leafNode> <leafNode name="vlan-range"> @@ -226,27 +90,13 @@ <constraint> <regex>(409[0-6]|40[0-8][0-9]|[1-3][0-9]{3}|[1-9][0-9]{0,2})-(409[0-6]|40[0-8][0-9]|[1-3][0-9]{3}|[1-9][0-9]{0,2})</regex> </constraint> - <multi /> + <multi/> </properties> </leafNode> </children> </tagNode> - <leafNode name="local-ip"> - <properties> - <help>local gateway address</help> - <constraint> - <validator name="ipv4-address"/> - </constraint> - </properties> - </leafNode> - <leafNode name="mtu"> - <properties> - <help>Maximum Transmission Unit (MTU) - default 1492</help> - <constraint> - <validator name="numeric" argument="--range 128-16384"/> - </constraint> - </properties> - </leafNode> + #include <include/accel-gateway-address.xml.i> + #include <include/accel-mtu-128-16384.xml.i> <node name="limits"> <properties> <help>Limits the connection rate from a single source</help> @@ -311,53 +161,9 @@ <valueless /> </properties> </leafNode> - <leafNode name="mppe"> - <properties> - <help>Specifies MPPE negotiation preference. (default prefer mppe)</help> - <completionHelp> - <list>deny prefer require</list> - </completionHelp> - <valueHelp> - <format>deny</format> - <description>Deny MPPE</description> - </valueHelp> - <valueHelp> - <format>prefer</format> - <description>Ask client for MPPE - do not fail on reject</description> - </valueHelp> - <valueHelp> - <format>require</format> - <description>Ask client for MPPE - drop connection on reject</description> - </valueHelp> - <constraint> - <regex>^(deny|prefer|require)$</regex> - </constraint> - </properties> - </leafNode> - <leafNode name="lcp-echo-interval"> - <properties> - <help>LCP echo-requests/sec</help> - <constraint> - <validator name="numeric" argument="--positive"/> - </constraint> - </properties> - </leafNode> - <leafNode name="lcp-echo-failure"> - <properties> - <help>Maximum number of Echo-Requests may be sent without valid reply</help> - <constraint> - <validator name="numeric" argument="--positive"/> - </constraint> - </properties> - </leafNode> - <leafNode name="lcp-echo-timeout"> - <properties> - <help>Timeout in seconds to wait for any peer activity. If this option specified it turns on adaptive lcp echo functionality and "lcp-echo-failure" is not used.</help> - <constraint> - <validator name="numeric" argument="--positive"/> - </constraint> - </properties> - </leafNode> + #include <include/accel-ppp-mppe.xml.i> + #include <include/accel-lcp-echo-interval-failure.xml.i> + #include <include/accel-lcp-echo-timeout.xml.i> <leafNode name="ipv4"> <properties> <help>IPv4 (IPCP) negotiation algorithm</help> @@ -417,6 +223,9 @@ <leafNode name="ipv6-intf-id"> <properties> <help>Fixed or random interface identifier for IPv6</help> + <completionHelp> + <list>random</list> + </completionHelp> <valueHelp> <format>random</format> <description>Random interface identifier for IPv6</description> @@ -430,6 +239,9 @@ <leafNode name="ipv6-peer-intf-id"> <properties> <help>Peer interface identifier for IPv6</help> + <completionHelp> + <list>random calling-sid ipv4</list> + </completionHelp> <valueHelp> <format>x:x:x:x</format> <description>Interface identifier for IPv6</description> @@ -484,6 +296,44 @@ </leafNode> </children> </tagNode> + <leafNode name="session-control"> + <properties> + <help>control sessions count</help> + <constraint> + <regex>^(deny|disable|replace)$</regex> + </constraint> + <constraintErrorMessage>Invalid value</constraintErrorMessage> + <valueHelp> + <format>disable</format> + <description>Disables session control</description> + </valueHelp> + <valueHelp> + <format>deny</format> + <description>Deny second session authorization</description> + </valueHelp> + <valueHelp> + <format>replace</format> + <description>Terminate first session when second is authorized</description> + </valueHelp> + <completionHelp> + <list>deny disable replace</list> + </completionHelp> + </properties> + <defaultValue>replace</defaultValue> + </leafNode> + <node name="snmp"> + <properties> + <help>Enable SNMP</help> + </properties> + <children> + <leafNode name="master-agent"> + <properties> + <help>enable SNMP master agent mode</help> + <valueless /> + </properties> + </leafNode> + </children> + </node> </children> </node> </children> diff --git a/interface-definitions/vpn_l2tp.xml.in b/interface-definitions/vpn_l2tp.xml.in index 4de28d2bd..8802c0564 100644 --- a/interface-definitions/vpn_l2tp.xml.in +++ b/interface-definitions/vpn_l2tp.xml.in @@ -12,14 +12,7 @@ <help>Remote access L2TP VPN</help> </properties> <children> - <leafNode name="mtu"> - <properties> - <help>Maximum Transmission Unit (MTU)</help> - <constraint> - <validator name="numeric" argument="--range 128-16384"/> - </constraint> - </properties> - </leafNode> + #include <include/accel-mtu-128-16384.xml.i> <leafNode name="outside-address"> <properties> <help>External IP address to which VPN clients will connect</help> @@ -28,14 +21,7 @@ </constraint> </properties> </leafNode> - <leafNode name="gateway-address"> - <properties> - <help>Gatway address uses as client tunnel termination point</help> - <constraint> - <validator name="ipv4-address"/> - </constraint> - </properties> - </leafNode> + #include <include/accel-gateway-address.xml.i> #include <include/accel-name-server.xml.i> <node name="lns"> <properties> @@ -171,36 +157,8 @@ <help>Pool of client IP addresses (must be within a /24)</help> </properties> <children> - <leafNode name="start"> - <properties> - <help>First IP address in the pool (will be used as gateway address)</help> - <constraint> - <validator name="ipv4-address"/> - </constraint> - </properties> - </leafNode> - <leafNode name="stop"> - <properties> - <help>Last IP address in the pool</help> - <constraint> - <validator name="ipv4-address"/> - </constraint> - </properties> - </leafNode> - <leafNode name="subnet"> - <properties> - <help>Client IP subnet (CIDR notation)</help> - <constraint> - <validator name="ipv4-prefix"/> - </constraint> - <constraintErrorMessage>Not a valid CIDR formatted prefix</constraintErrorMessage> - <valueHelp> - <format>ipv4net</format> - <description>IPv4 subnet address</description> - </valueHelp> - <multi /> - </properties> - </leafNode> + #include <include/accel-client-ip-pool-start-stop.xml.i> + #include <include/accel-client-ip-pool-subnet.xml.i> </children> </node> #include <include/accel-client-ipv6-pool.xml.i> @@ -259,83 +217,9 @@ <multi /> </properties> </leafNode> - <leafNode name="mppe"> - <properties> - <help>Specifies mppe negotioation preference. (default require mppe 128-bit stateless</help> - <valueHelp> - <format>deny</format> - <description>deny mppe</description> - </valueHelp> - <valueHelp> - <format>prefer</format> - <description>Ask client for mppe, if it rejects do not fail</description> - </valueHelp> - <valueHelp> - <format>require</format> - <description>ask client for mppe, if it rejects drop connection</description> - </valueHelp> - <constraint> - <regex>(deny|prefer|require)</regex> - </constraint> - <completionHelp> - <list>deny prefer require</list> - </completionHelp> - </properties> - </leafNode> + #include <include/accel-ppp-mppe.xml.i> #include <include/accel-auth-mode.xml.i> - <node name="local-users"> - <properties> - <help>Local user authentication for remote access L2TP VPN</help> - </properties> - <children> - <tagNode name="username"> - <properties> - <help>User name for authentication</help> - </properties> - <children> - <leafNode name="disable"> - <properties> - <help>Option to disable a L2TP Server user</help> - <valueless/> - </properties> - </leafNode> - <leafNode name="password"> - <properties> - <help>Password for authentication</help> - </properties> - </leafNode> - <leafNode name="static-ip"> - <properties> - <help>Static client IP address</help> - </properties> - </leafNode> - <node name="rate-limit"> - <properties> - <help>Upload/Download speed limits</help> - </properties> - <children> - <leafNode name="upload"> - <properties> - <help>Upload bandwidth limit in kbits/sec</help> - <constraint> - <validator name="numeric" argument="--range 1-65535"/> - </constraint> - </properties> - </leafNode> - <leafNode name="download"> - <properties> - <help>Download bandwidth limit in kbits/sec</help> - <constraint> - <validator name="numeric" argument="--range 1-65535"/> - </constraint> - </properties> - </leafNode> - </children> - </node> - </children> - </tagNode> - </children> - </node> + #include <include/accel-auth-local-users.xml.i> #include <include/radius-server.xml.i> <node name="radius"> <children> @@ -430,22 +314,7 @@ <help>Advanced protocol options</help> </properties> <children> - <leafNode name="lcp-echo-interval"> - <properties> - <help>LCP echo-requests/sec</help> - <constraint> - <validator name="numeric" argument="--positive"/> - </constraint> - </properties> - </leafNode> - <leafNode name="lcp-echo-failure"> - <properties> - <help>Maximum number of Echo-Requests may be sent without valid reply</help> - <constraint> - <validator name="numeric" argument="--positive"/> - </constraint> - </properties> - </leafNode> + #include <include/accel-lcp-echo-interval-failure.xml.i> </children> </node> </children> diff --git a/interface-definitions/vpn_pptp.xml.in b/interface-definitions/vpn_pptp.xml.in index f37c9bd01..b17138e33 100644 --- a/interface-definitions/vpn_pptp.xml.in +++ b/interface-definitions/vpn_pptp.xml.in @@ -12,14 +12,7 @@ <help>Remote access PPTP VPN</help> </properties> <children> - <leafNode name="mtu"> - <properties> - <help>Maximum Transmission Unit (MTU)</help> - <constraint> - <validator name="numeric" argument="--range 128-16384"/> - </constraint> - </properties> - </leafNode> + #include <include/accel-mtu-128-16384.xml.i> <leafNode name="outside-address"> <properties> <help>External IP address to which VPN clients will connect</help> @@ -47,32 +40,10 @@ <help>Pool of client IP addresses (must be within a /24)</help> </properties> <children> - <leafNode name="start"> - <properties> - <help>First IP address in the pool (will be used as gateway address)</help> - <constraint> - <validator name="ipv4-address"/> - </constraint> - </properties> - </leafNode> - <leafNode name="stop"> - <properties> - <help>Last IP address in the pool</help> - <constraint> - <validator name="ipv4-address"/> - </constraint> - </properties> - </leafNode> + #include <include/accel-client-ip-pool-start-stop.xml.i> </children> </node> - <leafNode name="gateway-address"> - <properties> - <help>Gatway address uses as client tunnel termination point</help> - <constraint> - <validator name="ipv4-address"/> - </constraint> - </properties> - </leafNode> + #include <include/accel-gateway-address.xml.i> <node name="authentication"> <properties> <help>Authentication for remote access PPTP VPN</help> diff --git a/interface-definitions/vpn_sstp.xml.in b/interface-definitions/vpn_sstp.xml.in index 5da2f8f24..77b1c1ec1 100644 --- a/interface-definitions/vpn_sstp.xml.in +++ b/interface-definitions/vpn_sstp.xml.in @@ -13,119 +13,40 @@ <help>Authentication for remote access SSTP Server</help> </properties> <children> - <node name="local-users"> - <properties> - <help>Local user authentication for SSTP server</help> - </properties> - <children> - <tagNode name="username"> - <properties> - <help>User name for authentication</help> - </properties> - <children> - <leafNode name="disable"> - <properties> - <help>Option to disable a SSTP Server user</help> - <valueless /> - </properties> - </leafNode> - <leafNode name="password"> - <properties> - <help>Password for authentication</help> - </properties> - </leafNode> - <leafNode name="static-ip"> - <properties> - <help>Static client IP address</help> - </properties> - </leafNode> - <node name="rate-limit"> - <properties> - <help>Upload/Download speed limits</help> - </properties> - <children> - <leafNode name="upload"> - <properties> - <help>Upload bandwidth limit in kbits/sec</help> - <constraint> - <validator name="numeric" argument="--range 1-65535"/> - </constraint> - </properties> - </leafNode> - <leafNode name="download"> - <properties> - <help>Download bandwidth limit in kbits/sec</help> - <constraint> - <validator name="numeric" argument="--range 1-65535"/> - </constraint> - </properties> - </leafNode> - </children> - </node> - </children> - </tagNode> - </children> - </node> + #include <include/accel-auth-local-users.xml.i> #include <include/accel-auth-mode.xml.i> - <leafNode name="protocols"> - <properties> - <help>Authentication protocol for remote access peer SSTP VPN</help> - <completionHelp> - <list>pap chap mschap mschap-v2</list> - </completionHelp> - <valueHelp> - <format>pap</format> - <description>Authentication via PAP (Password Authentication Protocol)</description> - </valueHelp> - <valueHelp> - <format>chap</format> - <description>Authentication via CHAP (Challenge Handshake Authentication Protocol)</description> - </valueHelp> - <valueHelp> - <format>mschap</format> - <description>Authentication via MS-CHAP (Microsoft Challenge Handshake Authentication Protocol)</description> - </valueHelp> - <valueHelp> - <format>mschap-v2</format> - <description>Authentication via MS-CHAPv2 (Microsoft Challenge Handshake Authentication Protocol, version 2)</description> - </valueHelp> - <constraint> - <regex>(pap|chap|mschap|mschap-v2)</regex> - </constraint> - <multi /> - </properties> - </leafNode> + #include <include/accel-auth-protocols.xml.i> #include <include/radius-server.xml.i> #include <include/accel-radius-additions.xml.i> <node name="radius"> <children> - <node name="rate-limit"> - <properties> - <help>Upload/Download speed limits</help> - </properties> - <children> - <leafNode name="attribute"> - <properties> - <help>Specifies RADIUS attribute containing rate information (default 'Filter-Id')</help> - </properties> - </leafNode> - <leafNode name="vendor"> - <properties> - <help>Specifies vendor dictionary (needs to be in /usr/share/accel-ppp/radius)</help> - </properties> - </leafNode> - <leafNode name="enable"> - <properties> - <help>Enable RADIUS bandwidth shaping</help> - <valueless /> - </properties> - </leafNode> - </children> - </node> + #include <include/accel-radius-additions-rate-limit.xml.i> </children> </node> </children> </node> + #include <include/interface-mtu-68-1500.xml.i> + #include <include/accel-gateway-address.xml.i> + #include <include/accel-name-server.xml.i> + <node name="client-ip-pool"> + <properties> + <help>Client IP pools and gateway setting</help> + </properties> + <children> + #include <include/accel-client-ip-pool-subnet.xml.i> + </children> + </node> + #include <include/accel-client-ipv6-pool.xml.i> + <node name="ppp-options"> + <properties> + <help>PPP (Point-to-Point Protocol) settings</help> + </properties> + <children> + #include <include/accel-ppp-mppe.xml.i> + #include <include/accel-lcp-echo-interval-failure.xml.i> + #include <include/accel-lcp-echo-timeout.xml.i> + </children> + </node> <node name="ssl"> <properties> <help>SSL Certificate, SSL Key and CA (/config/user-data/sstp)</help> @@ -168,106 +89,8 @@ </leafNode> </children> </node> - <node name="network-settings"> - <properties> - <help>Network settings</help> - </properties> - <children> - <node name="client-ip-settings"> - <properties> - <help>Client IP pools and gateway setting</help> - </properties> - <children> - <leafNode name="subnet"> - <properties> - <help>Client IP subnet (CIDR notation)</help> - <valueHelp> - <format>ipv4net</format> - <description>IPv4 address and prefix length</description> - </valueHelp> - <constraint> - <validator name="ipv4-prefix"/> - </constraint> - <constraintErrorMessage>Not a valid CIDR formatted prefix</constraintErrorMessage> - <multi /> - </properties> - </leafNode> - <leafNode name="gateway-address"> - <properties> - <help>Gateway IP address</help> - <constraint> - <validator name="ipv4-address"/> - </constraint> - <constraintErrorMessage>invalid IPv4 address</constraintErrorMessage> - <valueHelp> - <format>ipv4</format> - <description>Default Gateway send to the client</description> - </valueHelp> - </properties> - </leafNode> - </children> - </node> - #include <include/accel-client-ipv6-pool.xml.i> - #include <include/accel-name-server.xml.i> - #include <include/interface-mtu-68-1500.xml.i> - </children> - </node> - <node name="ppp-settings"> - <properties> - <help>PPP (Point-to-Point Protocol) settings</help> - </properties> - <children> - <leafNode name="mppe"> - <properties> - <help>Specifies mppe negotiation preferences</help> - <completionHelp> - <list>require prefer deny</list> - </completionHelp> - <constraint> - <regex>(^require|prefer|deny)</regex> - </constraint> - <valueHelp> - <format>require</format> - <description>send mppe request, if client rejects, drop the connection</description> - </valueHelp> - <valueHelp> - <format>prefer</format> - <description>send mppe request, if client rejects continue</description> - </valueHelp> - <valueHelp> - <format>deny</format> - <description>drop all mppe</description> - </valueHelp> - </properties> - </leafNode> - <leafNode name="lcp-echo-interval"> - <properties> - <help>LCP echo-requests/sec</help> - <constraint> - <validator name="numeric" argument="--positive"/> - </constraint> - </properties> - </leafNode> - <leafNode name="lcp-echo-failure"> - <properties> - <help>Maximum number of Echo-Requests may be sent without valid reply</help> - <constraint> - <validator name="numeric" argument="--positive"/> - </constraint> - </properties> - </leafNode> - <leafNode name="lcp-echo-timeout"> - <properties> - <help>Timeout in seconds to wait for any peer activity. If this option specified it turns on adaptive lcp echo functionality and "lcp-echo-failure" is not used.</help> - <constraint> - <validator name="numeric" argument="--positive"/> - </constraint> - </properties> - </leafNode> - </children> - </node> - </children> - </node> - </children> -</node> + </children> + </node> + </children> + </node> </interfaceDefinition> diff --git a/interface-definitions/vrrp.xml.in b/interface-definitions/vrrp.xml.in index 120c7d218..ec0a71a95 100644 --- a/interface-definitions/vrrp.xml.in +++ b/interface-definitions/vrrp.xml.in @@ -222,6 +222,25 @@ </valueHelp> </properties> </leafNode> + <leafNode name="virtual-address-excluded"> + <properties> + <help>Virtual address (If you need additional IPv4 and IPv6 in same group)</help> + <valueHelp> + <format>ipv4</format> + <description>IP address</description> + </valueHelp> + <valueHelp> + <format>ipv6</format> + <description>IPv6 address</description> + </valueHelp> + <multi/> + <constraint> + <validator name="ipv4-host"/> + <validator name="ipv6-host"/> + </constraint> + <constraintErrorMessage>Virtual address must be a valid IPv4 or IPv6 address with prefix length (e.g. 192.0.2.3/24 or 2001:db8:ff::10/64)</constraintErrorMessage> + </properties> + </leafNode> <leafNode name="vrid"> <properties> <help>Virtual router identifier</help> diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index 58ecd3f17..99072a1b9 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -18,12 +18,8 @@ A library for retrieving value dicts from VyOS configs in a declarative fashion. """ import os -from copy import deepcopy - from vyos.util import vyos_dict_search from vyos.xml import defaults -from vyos.xml import is_tag -from vyos.xml import is_leaf from vyos import ConfigError def retrieve_config(path_hash, base_path, config): @@ -198,6 +194,9 @@ def is_member(conf, interface, intftype=None): interface name -> Interface is a member of this interface False -> interface type cannot have members """ + from vyos.xml import is_tag + from vyos.xml import is_leaf + ret_val = None intftypes = ['bonding', 'bridge'] if intftype not in intftypes + [None]: @@ -265,11 +264,12 @@ def is_source_interface(conf, interface, intftype=None): def get_interface_dict(config, base, ifname=''): """ - Common utility function to retrieve and mandgle the interfaces available - in CLI configuration. All interfaces have a common base ground where the - value retrival is identical - so it can and should be reused + Common utility function to retrieve and mangle the interfaces configuration + from the CLI input nodes. All interfaces have a common base where value + retrival is identical. This function must be used whenever possible when + working on the interfaces node! - Will return a dictionary with the necessary interface configuration + Return a dictionary with the necessary interface config keys. """ if not ifname: # determine tagNode instance @@ -290,8 +290,12 @@ def get_interface_dict(config, base, ifname=''): config.set_level(base + [ifname]) dict = config.get_config_dict([], key_mangling=('-', '_'), get_first_key=True) - # Check if interface has been removed - if dict == {}: + # Check if interface has been removed. We must use exists() as get_config_dict() + # will always return {} - even when an empty interface node like + # +macsec macsec1 { + # +} + # exists. + if not config.exists([]): dict.update({'deleted' : ''}) # Add interface instance name into dictionary @@ -356,6 +360,10 @@ def get_interface_dict(config, base, ifname=''): # XXX: T2665: blend in proper DHCPv6-PD default values dict['vif'][vif] = T2665_set_dhcpv6pd_defaults(dict['vif'][vif]) + # Check if we are a member of a bridge device + bridge = is_member(config, f'{ifname}.{vif}', 'bridge') + if bridge: dict['vif'][vif].update({'is_bridge_member' : bridge}) + for vif_s, vif_s_config in dict.get('vif_s', {}).items(): default_vif_s_values = defaults(base + ['vif-s']) # XXX: T2665: we only wan't the vif-s defaults - do not care about vif-c @@ -371,6 +379,10 @@ def get_interface_dict(config, base, ifname=''): dict['vif_s'][vif_s] = T2665_set_dhcpv6pd_defaults( dict['vif_s'][vif_s]) + # Check if we are a member of a bridge device + bridge = is_member(config, f'{ifname}.{vif_s}', 'bridge') + if bridge: dict['vif_s'][vif_s].update({'is_bridge_member' : bridge}) + for vif_c, vif_c_config in vif_s_config.get('vif_c', {}).items(): default_vif_c_values = defaults(base + ['vif-s', 'vif-c']) @@ -385,6 +397,78 @@ def get_interface_dict(config, base, ifname=''): dict['vif_s'][vif_s]['vif_c'][vif_c] = T2665_set_dhcpv6pd_defaults( dict['vif_s'][vif_s]['vif_c'][vif_c]) + # Check if we are a member of a bridge device + bridge = is_member(config, f'{ifname}.{vif_s}.{vif_c}', 'bridge') + if bridge: dict['vif_s'][vif_s]['vif_c'][vif_c].update( + {'is_bridge_member' : bridge}) + # Check vif, vif-s/vif-c VLAN interfaces for removal dict = get_removed_vlans(config, dict) return dict + + +def get_accel_dict(config, base, chap_secrets): + """ + Common utility function to retrieve and mangle the Accel-PPP configuration + from different CLI input nodes. All Accel-PPP services have a common base + where value retrival is identical. This function must be used whenever + possible when working with Accel-PPP services! + + Return a dictionary with the necessary interface config keys. + """ + from vyos.util import get_half_cpus + from vyos.validate import is_ipv4 + + dict = config.get_config_dict(base, key_mangling=('-', '_'), get_first_key=True) + + # We have gathered the dict representation of the CLI, but there are default + # options which we need to update into the dictionary retrived. + default_values = defaults(base) + + # defaults include RADIUS server specifics per TAG node which need to be + # added to individual RADIUS servers instead - so we can simply delete them + if vyos_dict_search('authentication.radius.server', default_values): + del default_values['authentication']['radius']['server'] + + # defaults include static-ip address per TAG node which need to be added to + # individual local users instead - so we can simply delete them + if vyos_dict_search('authentication.local_users.username', default_values): + del default_values['authentication']['local_users']['username'] + + dict = dict_merge(default_values, dict) + + # set CPUs cores to process requests + dict.update({'thread_count' : get_half_cpus()}) + # we need to store the path to the secrets file + dict.update({'chap_secrets_file' : chap_secrets}) + + # We can only have two IPv4 and three IPv6 nameservers - also they are + # configured in a different way in the configuration, this is why we split + # the configuration + if 'name_server' in dict: + ns_v4 = [] + ns_v6 = [] + for ns in dict['name_server']: + if is_ipv4(ns): ns_v4.append(ns) + else: ns_v6.append(ns) + + dict.update({'name_server_ipv4' : ns_v4, 'name_server_ipv6' : ns_v6}) + del dict['name_server'] + + # Add individual RADIUS server default values + if vyos_dict_search('authentication.radius.server', dict): + default_values = defaults(base + ['authentication', 'radius', 'server']) + + for server in vyos_dict_search('authentication.radius.server', dict): + dict['authentication']['radius']['server'][server] = dict_merge( + default_values, dict['authentication']['radius']['server'][server]) + + # Add individual local-user default values + if vyos_dict_search('authentication.local_users.username', dict): + default_values = defaults(base + ['authentication', 'local_users', 'username']) + + for username in vyos_dict_search('authentication.local_users.username', dict): + dict['authentication']['local_users']['username'][username] = dict_merge( + default_values, dict['authentication']['local_users']['username'][username]) + + return dict diff --git a/python/vyos/configverify.py b/python/vyos/configverify.py index 944fc4294..f970ca6de 100644 --- a/python/vyos/configverify.py +++ b/python/vyos/configverify.py @@ -22,6 +22,7 @@ # makes use of it! from vyos import ConfigError +from vyos.util import vyos_dict_search def verify_mtu(config): """ @@ -51,7 +52,6 @@ def verify_mtu_ipv6(config): configured on the interface. IPv6 requires a 1280 bytes MTU. """ from vyos.validate import is_ipv6 - from vyos.util import vyos_dict_search # IPv6 minimum required link mtu min_mtu = 1280 @@ -204,3 +204,58 @@ def verify_vlan_config(config): verify_dhcpv6(vlan) verify_address(vlan) verify_vrf(vlan) + +def verify_accel_ppp_base_service(config): + """ + Common helper function which must be used by all Accel-PPP services based + on get_config_dict() + """ + # vertify auth settings + if vyos_dict_search('authentication.mode', config) == 'local': + if not vyos_dict_search('authentication.local_users', config): + raise ConfigError('PPPoE local auth mode requires local users to be configured!') + + for user in vyos_dict_search('authentication.local_users.username', config): + user_config = config['authentication']['local_users']['username'][user] + + if 'password' not in user_config: + raise ConfigError(f'Password required for local user "{user}"') + + if 'rate_limit' in user_config: + # if up/download is set, check that both have a value + if not {'upload', 'download'} <= set(user_config['rate_limit']): + raise ConfigError(f'User "{user}" has rate-limit configured for only one ' \ + 'direction but both upload and download must be given!') + + elif vyos_dict_search('authentication.mode', config) == 'radius': + if not vyos_dict_search('authentication.radius.server', config): + raise ConfigError('RADIUS authentication requires at least one server') + + for server in vyos_dict_search('authentication.radius.server', config): + radius_config = config['authentication']['radius']['server'][server] + if 'key' not in radius_config: + raise ConfigError(f'Missing RADIUS secret key for server "{server}"') + + if 'gateway_address' not in config: + raise ConfigError('PPPoE server requires gateway-address to be configured!') + + if 'name_server_ipv4' in config: + if len(config['name_server_ipv4']) > 2: + raise ConfigError('Not more then two IPv4 DNS name-servers ' \ + 'can be configured') + + if 'name_server_ipv6' in config: + if len(config['name_server_ipv6']) > 3: + raise ConfigError('Not more then three IPv6 DNS name-servers ' \ + 'can be configured') + + if 'client_ipv6_pool' in config: + ipv6_pool = config['client_ipv6_pool'] + if 'delegate' in ipv6_pool: + if 'prefix' not in ipv6_pool: + raise ConfigError('IPv6 "delegate" also requires "prefix" to be defined!') + + for delegate in ipv6_pool['delegate']: + if 'delegation_prefix' not in ipv6_pool['delegate'][delegate]: + raise ConfigError('delegation-prefix length required!') + diff --git a/python/vyos/xml/definition.py b/python/vyos/xml/definition.py index a25fc50c5..7831af4d2 100644 --- a/python/vyos/xml/definition.py +++ b/python/vyos/xml/definition.py @@ -297,7 +297,7 @@ class XML(dict): continue value = conf[k] if self.is_multi(fpath) and not isinstance(value, list): - value = [value] + value = value.split(' ') r[under] = value return r diff --git a/smoketest/scripts/cli/base_accel_ppp_test.py b/smoketest/scripts/cli/base_accel_ppp_test.py new file mode 100644 index 000000000..cf401b0d8 --- /dev/null +++ b/smoketest/scripts/cli/base_accel_ppp_test.py @@ -0,0 +1,177 @@ +# Copyright (C) 2020 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +import os +import re +import unittest + +from configparser import ConfigParser + +from vyos.configsession import ConfigSession +from vyos.configsession import ConfigSessionError +from vyos.util import cmd +from vyos.util import get_half_cpus +from vyos.util import process_named_running +from vyos.validate import is_ipv4 + +class BasicAccelPPPTest: + class BaseTest(unittest.TestCase): + + def setUp(self): + self.session = ConfigSession(os.getpid()) + self._gateway = '192.0.2.1' + + # ensure we can also run this test on a live system - so lets clean + # out the current configuration :) + self.session.delete(self._base_path) + + def tearDown(self): + self.session.delete(self._base_path) + self.session.commit() + del self.session + + def set(self, path): + self.session.set(self._base_path + path) + + def basic_config(self): + # PPPoE local auth mode requires local users to be configured! + self.set(['authentication', 'local-users', 'username', 'vyos', 'password', 'vyos']) + self.set(['authentication', 'mode', 'local']) + self.set(['gateway-address', self._gateway]) + + def verify(self, conf): + self.assertEqual(conf['core']['thread-count'], str(get_half_cpus())) + + def test_name_servers(self): + """ Verify proper Name-Server configuration for IPv4 and IPv6 """ + self.basic_config() + + nameserver = ['192.0.2.1', '192.0.2.2', '2001:db8::1'] + for ns in nameserver: + self.set(['name-server', ns]) + + # commit changes + self.session.commit() + + # Validate configuration values + conf = ConfigParser(allow_no_value=True, delimiters='=') + conf.read(self._config_file) + + # IPv4 and IPv6 nameservers must be checked individually + for ns in nameserver: + if is_ipv4(ns): + self.assertIn(ns, [conf['dns']['dns1'], conf['dns']['dns2']]) + else: + self.assertEqual(conf['ipv6-dns'][ns], None) + + def test_authentication_local(self): + """ Test configuration of local authentication """ + self.basic_config() + + # upload / download limit + user = 'test' + password = 'test2' + static_ip = '100.100.100.101' + upload = '5000' + download = '10000' + + self.set(['authentication', 'local-users', 'username', user, 'password', password]) + self.set(['authentication', 'local-users', 'username', user, 'static-ip', static_ip]) + self.set(['authentication', 'local-users', 'username', user, 'rate-limit', 'upload', upload]) + + # upload rate-limit requires also download rate-limit + with self.assertRaises(ConfigSessionError): + self.session.commit() + self.set(['authentication', 'local-users', 'username', user, 'rate-limit', 'download', download]) + + # commit changes + self.session.commit() + + # Validate configuration values + conf = ConfigParser(allow_no_value=True, delimiters='=') + conf.read(self._config_file) + + # check proper path to chap-secrets file + self.assertEqual(conf['chap-secrets']['chap-secrets'], self._chap_secrets) + + # basic verification + self.verify(conf) + + # check local users + tmp = cmd(f'sudo cat {self._chap_secrets}') + regex = f'{user}\s+\*\s+{password}\s+{static_ip}\s+{download}/{upload}' + tmp = re.findall(regex, tmp) + self.assertTrue(tmp) + + # Check for running process + self.assertTrue(process_named_running(self._process_name)) + + def test_authentication_radius(self): + """ Test configuration of RADIUS authentication for PPPoE server """ + self.basic_config() + + radius_server = '192.0.2.22' + radius_key = 'secretVyOS' + radius_port = '2000' + radius_port_acc = '3000' + + self.set(['authentication', 'mode', 'radius']) + self.set(['authentication', 'radius', 'server', radius_server, 'key', radius_key]) + self.set(['authentication', 'radius', 'server', radius_server, 'port', radius_port]) + self.set(['authentication', 'radius', 'server', radius_server, 'acct-port', radius_port_acc]) + + coa_server = '4.4.4.4' + coa_key = 'testCoA' + self.set(['authentication', 'radius', 'dynamic-author', 'server', coa_server]) + self.set(['authentication', 'radius', 'dynamic-author', 'key', coa_key]) + + nas_id = 'VyOS-PPPoE' + nas_ip = '7.7.7.7' + self.set(['authentication', 'radius', 'nas-identifier', nas_id]) + self.set(['authentication', 'radius', 'nas-ip-address', nas_ip]) + + source_address = '1.2.3.4' + self.set(['authentication', 'radius', 'source-address', source_address]) + + # commit changes + self.session.commit() + + # Validate configuration values + conf = ConfigParser(allow_no_value=True, delimiters='=') + conf.read(self._config_file) + + # basic verification + self.verify(conf) + + # check auth + self.assertTrue(conf['radius'].getboolean('verbose')) + self.assertEqual(conf['radius']['acct-timeout'], '3') + self.assertEqual(conf['radius']['timeout'], '3') + self.assertEqual(conf['radius']['max-try'], '3') + + self.assertEqual(conf['radius']['dae-server'], f'{coa_server}:1700,{coa_key}') + self.assertEqual(conf['radius']['nas-identifier'], nas_id) + self.assertEqual(conf['radius']['nas-ip-address'], nas_ip) + self.assertEqual(conf['radius']['bind'], source_address) + + server = conf['radius']['server'].split(',') + self.assertEqual(radius_server, server[0]) + self.assertEqual(radius_key, server[1]) + self.assertEqual(f'auth-port={radius_port}', server[2]) + self.assertEqual(f'acct-port={radius_port_acc}', server[3]) + self.assertEqual(f'req-limit=0', server[4]) + self.assertEqual(f'fail-time=0', server[5]) + + # Check for running process + self.assertTrue(process_named_running(self._process_name)) diff --git a/smoketest/scripts/cli/test_interfaces_bridge.py b/smoketest/scripts/cli/test_interfaces_bridge.py index bc0bb69c6..a1359680b 100755 --- a/smoketest/scripts/cli/test_interfaces_bridge.py +++ b/smoketest/scripts/cli/test_interfaces_bridge.py @@ -18,6 +18,8 @@ import os import unittest from base_interfaces_test import BasicInterfaceTest +from glob import glob +from netifaces import interfaces from vyos.ifconfig import Section class BridgeInterfaceTest(BasicInterfaceTest.BaseTest): @@ -44,6 +46,7 @@ class BridgeInterfaceTest(BasicInterfaceTest.BaseTest): self._options['br0'].append(f'member interface {member}') def test_add_remove_member(self): + """ Add member interfaces to bridge and set STP cost/priority """ for interface in self._interfaces: base = self._base_path + [interface] self.session.set(base + ['stp']) @@ -59,12 +62,46 @@ class BridgeInterfaceTest(BasicInterfaceTest.BaseTest): cost += 1 priority += 1 + # commit config self.session.commit() + # check member interfaces are added on the bridge + bridge_members = [] + for tmp in glob(f'/sys/class/net/{interface}/lower_*'): + bridge_members.append(os.path.basename(tmp).replace('lower_', '')) + + for member in self._members: + self.assertIn(member, bridge_members) + + # delete all members for interface in self._interfaces: self.session.delete(self._base_path + [interface, 'member']) self.session.commit() + def test_vlan_members(self): + """ T2945: ensure that VIFs are not dropped from bridge """ + + self.session.set(['interfaces', 'ethernet', 'eth0', 'vif', '300']) + self.session.set(['interfaces', 'bridge', 'br0', 'member', 'interface', 'eth0.300']) + self.session.commit() + + # member interface must be assigned to the bridge + self.assertTrue(os.path.exists('/sys/class/net/br0/lower_eth0.300')) + + # add second bridge member + self.session.set(['interfaces', 'ethernet', 'eth0', 'vif', '400']) + self.session.commit() + + # member interface must still be assigned to the bridge + self.assertTrue(os.path.exists('/sys/class/net/br0/lower_eth0.300')) + + # remove VLAN interfaces + self.session.delete(['interfaces', 'ethernet', 'eth0', 'vif', '300']) + self.session.delete(['interfaces', 'ethernet', 'eth0', 'vif', '400']) + self.session.commit() + + if __name__ == '__main__': unittest.main() + diff --git a/smoketest/scripts/cli/test_interfaces_macsec.py b/smoketest/scripts/cli/test_interfaces_macsec.py index 6d1be86ba..177d2b946 100755 --- a/smoketest/scripts/cli/test_interfaces_macsec.py +++ b/smoketest/scripts/cli/test_interfaces_macsec.py @@ -105,7 +105,7 @@ class MACsecInterfaceTest(BasicInterfaceTest.BaseTest): # Check for running process self.assertTrue(process_named_running('wpa_supplicant')) - def test_mandatory_toptions(self): + def test_mandatory_options(self): interface = 'macsec1' self.session.set(self._base_path + [interface]) diff --git a/smoketest/scripts/cli/test_interfaces_wireguard.py b/smoketest/scripts/cli/test_interfaces_wireguard.py index 0c32a4696..726405780 100755 --- a/smoketest/scripts/cli/test_interfaces_wireguard.py +++ b/smoketest/scripts/cli/test_interfaces_wireguard.py @@ -38,10 +38,8 @@ class WireGuardInterfaceTest(unittest.TestCase): self.session.commit() del self.session - def test_peer_setup(self): - """ - Create WireGuard interfaces with associated peers - """ + def test_peer(self): + """ Create WireGuard interfaces with associated peers """ for intf in self._interfaces: peer = 'foo-' + intf psk = 'u2xdA70hkz0S1CG0dZlOh0aq2orwFXRIVrKo4DCvHgM=' @@ -64,5 +62,37 @@ class WireGuardInterfaceTest(unittest.TestCase): self.assertTrue(os.path.isdir(f'/sys/class/net/{intf}')) + + def test_add_remove_peer(self): + """ Create WireGuard interfaces with associated peers. Remove one of + the configured peers. Bug reported as T2939 """ + interface = 'wg0' + port = '12345' + pubkey_1 = 'n1CUsmR0M2LUUsyicBd6blZICwUqqWWHbu4ifZ2/9gk=' + pubkey_2 = 'ebFx/1G0ti8tvuZd94sEIosAZZIznX+dBAKG/8DFm0I=' + + self.session.set(base_path + [interface, 'address', '172.16.0.1/24']) + + self.session.set(base_path + [interface, 'peer', 'PEER01', 'pubkey', pubkey_1]) + self.session.set(base_path + [interface, 'peer', 'PEER01', 'port', port]) + self.session.set(base_path + [interface, 'peer', 'PEER01', 'allowed-ips', '10.205.212.10/32']) + self.session.set(base_path + [interface, 'peer', 'PEER01', 'address', '192.0.2.1']) + + self.session.set(base_path + [interface, 'peer', 'PEER02', 'pubkey', pubkey_2]) + self.session.set(base_path + [interface, 'peer', 'PEER02', 'port', port]) + self.session.set(base_path + [interface, 'peer', 'PEER02', 'allowed-ips', '10.205.212.11/32']) + self.session.set(base_path + [interface, 'peer', 'PEER02', 'address', '192.0.2.2']) + + # Commit peers + self.session.commit() + + self.assertTrue(os.path.isdir(f'/sys/class/net/{interface}')) + + # Delete second peer + self.session.delete(base_path + [interface, 'peer', 'PEER01']) + self.session.commit() + + + if __name__ == '__main__': unittest.main() diff --git a/smoketest/scripts/cli/test_nat.py b/smoketest/scripts/cli/test_nat.py index b06fa239d..5c7c66840 100755 --- a/smoketest/scripts/cli/test_nat.py +++ b/smoketest/scripts/cli/test_nat.py @@ -56,11 +56,10 @@ class TestNAT(unittest.TestCase): nftable_json = json.loads(tmp) condensed_json = jmespath.search(snat_pattern, nftable_json)[0] - self.assertEqual(condensed_json['comment'], 'DST-NAT-1') + self.assertEqual(condensed_json['comment'], 'SRC-NAT-1') self.assertEqual(condensed_json['address']['network'], network.split('/')[0]) self.assertEqual(str(condensed_json['address']['prefix']), network.split('/')[1]) - def test_validation(self): """ T2813: Ensure translation address is specified """ self.session.set(source_path + ['rule', '100', 'outbound-interface', 'eth0']) diff --git a/smoketest/scripts/cli/test_service_pppoe-server.py b/smoketest/scripts/cli/test_service_pppoe-server.py index 3a6b12ef4..f0c71e2de 100755 --- a/smoketest/scripts/cli/test_service_pppoe-server.py +++ b/smoketest/scripts/cli/test_service_pppoe-server.py @@ -17,41 +17,39 @@ import os import unittest +from base_accel_ppp_test import BasicAccelPPPTest + from configparser import ConfigParser -from vyos.configsession import ConfigSession from vyos.configsession import ConfigSessionError from vyos.util import process_named_running +from vyos.util import cmd -process_name = 'accel-pppd' -base_path = ['service', 'pppoe-server'] local_if = ['interfaces', 'dummy', 'dum667'] -pppoe_conf = '/run/accel-pppd/pppoe.conf' ac_name = 'ACN' -subnet = '172.18.0.0/24' -gateway = '192.0.2.1' -nameserver = '9.9.9.9' -mtu = '1492' + interface = 'eth0' -class TestServicePPPoEServer(unittest.TestCase): +class TestServicePPPoEServer(BasicAccelPPPTest.BaseTest): def setUp(self): - self.session = ConfigSession(os.getpid()) - # ensure we can also run this test on a live system - so lets clean - # out the current configuration :) - self.session.delete(base_path) + self._base_path = ['service', 'pppoe-server'] + self._process_name = 'accel-pppd' + self._config_file = '/run/accel-pppd/pppoe.conf' + self._chap_secrets = '/run/accel-pppd/pppoe.chap-secrets' + + super().setUp() def tearDown(self): - self.session.delete(base_path) self.session.delete(local_if) - self.session.commit() - del self.session + super().tearDown() def verify(self, conf): + mtu = '1492' + # validate some common values in the configuration - for tmp in ['log_syslog', 'pppoe', 'chap-secrets', 'ippool', 'ipv6pool', - 'ipv6_nd', 'ipv6_dhcp', 'auth_mschap_v2', 'auth_mschap_v1', - 'auth_chap_md5', 'auth_pap', 'shaper']: + for tmp in ['log_syslog', 'pppoe', 'ippool', + 'auth_mschap_v2', 'auth_mschap_v1', 'auth_chap_md5', + 'auth_pap', 'shaper']: # Settings without values provide None self.assertEqual(conf['modules'][tmp], None) @@ -60,108 +58,176 @@ class TestServicePPPoEServer(unittest.TestCase): self.assertTrue(conf['pppoe'].getboolean('verbose')) self.assertTrue(conf['pppoe']['interface'], interface) - # check configured subnet - self.assertEqual(conf['ip-pool'][subnet], None) - self.assertEqual(conf['ip-pool']['gw-ip-address'], gateway) - # check ppp self.assertTrue(conf['ppp'].getboolean('verbose')) self.assertTrue(conf['ppp'].getboolean('check-ip')) - self.assertEqual(conf['ppp']['min-mtu'], mtu) self.assertEqual(conf['ppp']['mtu'], mtu) self.assertEqual(conf['ppp']['lcp-echo-interval'], '30') self.assertEqual(conf['ppp']['lcp-echo-timeout'], '0') self.assertEqual(conf['ppp']['lcp-echo-failure'], '3') + super().verify(conf) + def basic_config(self): self.session.set(local_if + ['address', '192.0.2.1/32']) - self.session.set(base_path + ['access-concentrator', ac_name]) - self.session.set(base_path + ['authentication', 'mode', 'local']) - self.session.set(base_path + ['client-ip-pool', 'subnet', subnet]) - self.session.set(base_path + ['name-server', nameserver]) - self.session.set(base_path + ['interface', interface]) - self.session.set(base_path + ['local-ip', gateway]) + self.set(['access-concentrator', ac_name]) + self.set(['interface', interface]) + + super().basic_config() - def test_local_auth(self): + def test_ppp_options(self): """ Test configuration of local authentication for PPPoE server """ self.basic_config() - # authentication - self.session.set(base_path + ['authentication', 'local-users', 'username', 'vyos', 'password', 'vyos']) - self.session.set(base_path + ['authentication', 'mode', 'local']) + # other settings - self.session.set(base_path + ['ppp-options', 'ccp']) - self.session.set(base_path + ['ppp-options', 'mppe', 'require']) - self.session.set(base_path + ['limits', 'connection-limit', '20/min']) + mppe = 'require' + self.set(['ppp-options', 'ccp']) + self.set(['ppp-options', 'mppe', mppe]) + self.set(['limits', 'connection-limit', '20/min']) + + # min-mtu + min_mtu = '1400' + self.set(['ppp-options', 'min-mtu', min_mtu]) + + # mru + mru = '9000' + self.set(['ppp-options', 'mru', mru]) # commit changes self.session.commit() # Validate configuration values - conf = ConfigParser(allow_no_value=True) - conf.read(pppoe_conf) + conf = ConfigParser(allow_no_value=True, delimiters='=') + conf.read(self._config_file) # basic verification self.verify(conf) - # check auth - self.assertEqual(conf['chap-secrets']['chap-secrets'], '/run/accel-pppd/pppoe.chap-secrets') - self.assertEqual(conf['chap-secrets']['gw-ip-address'], gateway) + self.assertEqual(conf['chap-secrets']['gw-ip-address'], self._gateway) + + # check ppp + self.assertEqual(conf['ppp']['mppe'], mppe) + self.assertEqual(conf['ppp']['min-mtu'], min_mtu) + self.assertEqual(conf['ppp']['mru'], mru) - # check pado - self.assertEqual(conf['ppp']['mppe'], 'require') self.assertTrue(conf['ppp'].getboolean('ccp')) # check other settings self.assertEqual(conf['connlimit']['limit'], '20/min') # Check for running process - self.assertTrue(process_named_running(process_name)) + self.assertTrue(process_named_running(self._process_name)) + + def test_authentication_protocols(self): + """ Test configuration of local authentication for PPPoE server """ + self.basic_config() + + # explicitly test mschap-v2 - no special reason + self.set( ['authentication', 'protocols', 'mschap-v2']) + + # commit changes + self.session.commit() + + # Validate configuration values + conf = ConfigParser(allow_no_value=True) + conf.read(self._config_file) - def test_radius_auth(self): - """ Test configuration of RADIUS authentication for PPPoE server """ - radius_server = '192.0.2.22' - radius_key = 'secretVyOS' - radius_port = '2000' - radius_port_acc = '3000' + self.assertEqual(conf['modules']['auth_mschap_v2'], None) + # Check for running process + self.assertTrue(process_named_running(self._process_name)) + + def test_client_ip_pool(self): + """ Test configuration of IPv6 client pools """ self.basic_config() - self.session.set(base_path + ['authentication', 'radius', 'server', radius_server, 'key', radius_key]) - self.session.set(base_path + ['authentication', 'radius', 'server', radius_server, 'port', radius_port]) - self.session.set(base_path + ['authentication', 'radius', 'server', radius_server, 'acct-port', radius_port_acc]) - self.session.set(base_path + ['authentication', 'mode', 'radius']) + + subnet = '172.18.0.0/24' + self.set(['client-ip-pool', 'subnet', subnet]) + + start = '192.0.2.10' + stop = '192.0.2.20' + start_stop = f'{start}-{stop}' + self.set(['client-ip-pool', 'start', start]) + self.set(['client-ip-pool', 'stop', stop]) # commit changes self.session.commit() # Validate configuration values conf = ConfigParser(allow_no_value=True) - conf.read(pppoe_conf) + conf.read(self._config_file) + + # check configured subnet + self.assertEqual(conf['ip-pool'][subnet], None) + self.assertEqual(conf['ip-pool'][start_stop], None) + self.assertEqual(conf['ip-pool']['gw-ip-address'], self._gateway) + + # Check for running process + self.assertTrue(process_named_running(self._process_name)) - # basic verification - self.verify(conf) - # check auth - self.assertTrue(conf['radius'].getboolean('verbose')) - self.assertTrue(conf['radius']['acct-timeout'], '3') - self.assertTrue(conf['radius']['timeout'], '3') - self.assertTrue(conf['radius']['max-try'], '3') - self.assertTrue(conf['radius']['gw-ip-address'], gateway) - - server = conf['radius']['server'].split(',') - self.assertEqual(radius_server, server[0]) - self.assertEqual(radius_key, server[1]) - self.assertEqual(f'auth-port={radius_port}', server[2]) - self.assertEqual(f'acct-port={radius_port_acc}', server[3]) - self.assertEqual(f'req-limit=0', server[4]) - self.assertEqual(f'fail-time=0', server[5]) - - # check defaults - self.assertEqual(conf['ppp']['mppe'], 'prefer') - self.assertFalse(conf['ppp'].getboolean('ccp')) + def test_client_ipv6_pool(self): + """ Test configuration of IPv6 client pools """ + self.basic_config() + + # Enable IPv6 + allow_ipv6 = 'allow' + random = 'random' + self.set(['ppp-options', 'ipv6', allow_ipv6]) + self.set(['ppp-options', 'ipv6-intf-id', random]) + self.set(['ppp-options', 'ipv6-accept-peer-intf-id']) + self.set(['ppp-options', 'ipv6-peer-intf-id', random]) + + prefix = '2001:db8:ffff::/64' + prefix_mask = '128' + client_prefix = f'{prefix},{prefix_mask}' + self.set(['client-ipv6-pool', 'prefix', prefix, 'mask', prefix_mask]) + + delegate_prefix = '2001:db8::/40' + delegate_mask = '56' + self.set(['client-ipv6-pool', 'delegate', delegate_prefix, 'delegation-prefix', delegate_mask]) + + # commit changes + self.session.commit() + + # Validate configuration values + conf = ConfigParser(allow_no_value=True, delimiters='=') + conf.read(self._config_file) + + for tmp in ['ipv6pool', 'ipv6_nd', 'ipv6_dhcp']: + self.assertEqual(conf['modules'][tmp], None) + + self.assertEqual(conf['ppp']['ipv6'], allow_ipv6) + self.assertEqual(conf['ppp']['ipv6-intf-id'], random) + self.assertEqual(conf['ppp']['ipv6-peer-intf-id'], random) + self.assertTrue(conf['ppp'].getboolean('ipv6-accept-peer-intf-id')) + + self.assertEqual(conf['ipv6-pool'][client_prefix], None) + self.assertEqual(conf['ipv6-pool']['delegate'], f'{delegate_prefix},{delegate_mask}') # Check for running process - self.assertTrue(process_named_running(process_name)) + self.assertTrue(process_named_running(self._process_name)) + + + def test_authentication_radius(self): + radius_called_sid = 'ifname:mac' + radius_acct_interim_jitter = '9' + + self.set(['authentication', 'radius', 'called-sid-format', radius_called_sid]) + self.set(['authentication', 'radius', 'acct-interim-jitter', radius_acct_interim_jitter]) + + # run common tests + super().test_authentication_radius() + + # Validate configuration values + conf = ConfigParser(allow_no_value=True, delimiters='=') + conf.read(self._config_file) + + # Validate configuration + self.assertEqual(conf['radius']['called-sid'], radius_called_sid) + self.assertEqual(conf['radius']['acct-interim-jitter'], radius_acct_interim_jitter) + if __name__ == '__main__': unittest.main() diff --git a/smoketest/scripts/cli/test_system_ntp.py b/smoketest/scripts/cli/test_system_ntp.py index 2a7c64870..4f62b62d5 100755 --- a/smoketest/scripts/cli/test_system_ntp.py +++ b/smoketest/scripts/cli/test_system_ntp.py @@ -70,10 +70,6 @@ class TestSystemNTP(unittest.TestCase): def test_ntp_clients(self): """ Test the allowed-networks statement """ - listen_address = ['127.0.0.1', '::1'] - for listen in listen_address: - self.session.set(base_path + ['listen-address', listen]) - networks = ['192.0.2.0/24', '2001:db8:1000::/64'] for network in networks: self.session.set(base_path + ['allow-clients', 'address', network]) @@ -99,9 +95,7 @@ class TestSystemNTP(unittest.TestCase): # Check listen address tmp = get_config_value('interface') - test = ['ignore wildcard'] - for listen in listen_address: - test.append(f'listen {listen}') + test = ['ignore wildcard', 'listen 127.0.0.1', 'listen ::1'] self.assertEqual(tmp, test) # Check for running process diff --git a/smoketest/scripts/cli/test_vpn_sstp.py b/smoketest/scripts/cli/test_vpn_sstp.py new file mode 100755 index 000000000..83be4c248 --- /dev/null +++ b/smoketest/scripts/cli/test_vpn_sstp.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2020 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +import unittest + +from base_accel_ppp_test import BasicAccelPPPTest +from vyos.util import cmd + +process_name = 'accel-pppd' +ca_cert = '/tmp/ca.crt' +ssl_cert = '/tmp/server.crt' +ssl_key = '/tmp/server.key' + +class TestVPNSSTPServer(BasicAccelPPPTest.BaseTest): + def setUp(self): + self._base_path = ['vpn', 'sstp'] + self._process_name = 'accel-pppd' + self._config_file = '/run/accel-pppd/sstp.conf' + self._chap_secrets = '/run/accel-pppd/sstp.chap-secrets' + + super().setUp() + + def tearDown(self): + super().tearDown() + + def basic_config(self): + # SSL is mandatory + self.set(['ssl', 'ca-cert-file', ca_cert]) + self.set(['ssl', 'cert-file', ssl_cert]) + self.set(['ssl', 'key-file', ssl_key]) + self.set(['client-ip-pool', 'subnet', '192.0.2.0/24']) + + super().basic_config() + +if __name__ == '__main__': + # Our SSL certificates need a subject ... + subject = '/C=DE/ST=BY/O=VyOS/localityName=Cloud/commonName=vyos/' \ + 'organizationalUnitName=VyOS/emailAddress=maintainers@vyos.io/' + + # Generate mandatory SSL certificate + tmp = f'openssl req -newkey rsa:4096 -new -nodes -x509 -days 3650 '\ + f'-keyout {ssl_key} -out {ssl_cert} -subj {subject}' + cmd(tmp) + + # Generate "CA" + tmp = f'openssl req -new -x509 -key {ssl_key} -out {ca_cert} '\ + f'-subj {subject}' + cmd(tmp) + + unittest.main() diff --git a/src/conf_mode/interfaces-macsec.py b/src/conf_mode/interfaces-macsec.py index 613648adb..2c8367ff3 100755 --- a/src/conf_mode/interfaces-macsec.py +++ b/src/conf_mode/interfaces-macsec.py @@ -16,6 +16,7 @@ import os +from netifaces import interfaces from sys import exit from vyos.config import Config @@ -58,8 +59,7 @@ def get_config(config=None): # Check if interface has been removed if 'deleted' in macsec: - source_interface = conf.return_effective_value( - base + ['source-interface']) + source_interface = conf.return_effective_value(['source-interface']) macsec.update({'source_interface': source_interface}) return macsec @@ -110,11 +110,13 @@ def generate(macsec): def apply(macsec): # Remove macsec interface - if 'deleted' in macsec.keys(): + if 'deleted' in macsec: call('systemctl stop wpa_supplicant-macsec@{source_interface}' .format(**macsec)) - MACsecIf(macsec['ifname']).remove() + if macsec['ifname'] in interfaces(): + tmp = MACsecIf(macsec['ifname']) + tmp.remove() # delete configuration on interface removal if os.path.isfile(wpa_suppl_conf.format(**macsec)): diff --git a/src/conf_mode/interfaces-wireguard.py b/src/conf_mode/interfaces-wireguard.py index d5800264f..9bda35d0a 100755 --- a/src/conf_mode/interfaces-wireguard.py +++ b/src/conf_mode/interfaces-wireguard.py @@ -57,13 +57,13 @@ def get_config(config=None): # Determine which Wireguard peer has been removed. # Peers can only be removed with their public key! + dict = {} tmp = node_changed(conf, ['peer']) - if tmp: - dict = {} - for peer in tmp: - peer_config = leaf_node_changed(conf, ['peer', peer, 'pubkey']) - dict = dict_merge({'peer_remove' : {peer : {'pubkey' : peer_config}}}, dict) - wireguard.update(dict) + for peer in (tmp or []): + pubkey = leaf_node_changed(conf, ['peer', peer, 'pubkey']) + if pubkey: + dict = dict_merge({'peer_remove' : {peer : {'pubkey' : pubkey[0]}}}, dict) + wireguard.update(dict) return wireguard @@ -101,12 +101,12 @@ def verify(wireguard): f'for peer "{tmp}" if either one of them is set!') def apply(wireguard): + tmp = WireGuardIf(wireguard['ifname']) if 'deleted' in wireguard: - WireGuardIf(wireguard['ifname']).remove() + tmp.remove() return None - w = WireGuardIf(wireguard['ifname']) - w.update(wireguard) + tmp.update(wireguard) return None if __name__ == '__main__': diff --git a/src/conf_mode/interfaces-wireless.py b/src/conf_mode/interfaces-wireless.py index f8520aecf..ad8aee168 100755 --- a/src/conf_mode/interfaces-wireless.py +++ b/src/conf_mode/interfaces-wireless.py @@ -74,7 +74,18 @@ def get_config(config=None): else: conf = Config() base = ['interfaces', 'wireless'] + wifi = get_interface_dict(conf, base) + # defaults include RADIUS server specifics per TAG node which need to be + # added to individual RADIUS servers instead - so we can simply delete them + if vyos_dict_search('security.wpa.radius.server.port', wifi): + del wifi['security']['wpa']['radius']['server']['port'] + if not len(wifi['security']['wpa']['radius']['server']): + del wifi['security']['wpa']['radius'] + if not len(wifi['security']['wpa']): + del wifi['security']['wpa'] + if not len(wifi['security']): + del wifi['security'] if 'security' in wifi and 'wpa' in wifi['security']: wpa_cipher = wifi['security']['wpa'].get('cipher') @@ -99,6 +110,14 @@ def get_config(config=None): tmp = find_other_stations(conf, base, wifi['ifname']) if tmp: wifi['station_interfaces'] = tmp + # Add individual RADIUS server default values + if vyos_dict_search('security.wpa.radius.server', wifi): + default_values = defaults(base + ['security', 'wpa', 'radius', 'server']) + + for server in vyos_dict_search('security.wpa.radius.server', wifi): + wifi['security']['wpa']['radius']['server'][server] = dict_merge( + default_values, wifi['security']['wpa']['radius']['server'][server]) + return wifi def verify(wifi): diff --git a/src/conf_mode/nat.py b/src/conf_mode/nat.py index eb634fd78..b66cd370a 100755 --- a/src/conf_mode/nat.py +++ b/src/conf_mode/nat.py @@ -238,8 +238,11 @@ def verify(nat): if rule['translation_address']: addr = rule['translation_address'] - if addr != 'masquerade' and not is_addr_assigned(addr): - print(f'Warning: IP address {addr} does not exist on the system!') + if addr != 'masquerade': + for ip in addr.split('-'): + if not is_addr_assigned(ip): + print(f'Warning: IP address {ip} does not exist on the system!') + elif not rule['exclude']: raise ConfigError(f'{err_msg} translation address not specified') diff --git a/src/conf_mode/service_pppoe-server.py b/src/conf_mode/service_pppoe-server.py index a4e937b1a..a520120f8 100755 --- a/src/conf_mode/service_pppoe-server.py +++ b/src/conf_mode/service_pppoe-server.py @@ -15,433 +15,56 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import os -import re -from copy import deepcopy -from stat import S_IRUSR, S_IWUSR, S_IRGRP from sys import exit from vyos.config import Config +from vyos.configdict import get_accel_dict +from vyos.configverify import verify_accel_ppp_base_service from vyos.template import render -from vyos.util import call, get_half_cpus -from vyos.validate import is_ipv4 +from vyos.util import call +from vyos.util import vyos_dict_search from vyos import ConfigError - from vyos import airbag airbag.enable() pppoe_conf = r'/run/accel-pppd/pppoe.conf' pppoe_chap_secrets = r'/run/accel-pppd/pppoe.chap-secrets' -default_config_data = { - 'auth_mode': 'local', - 'auth_proto': ['auth_mschap_v2', 'auth_mschap_v1', 'auth_chap_md5', 'auth_pap'], - 'chap_secrets_file': pppoe_chap_secrets, # used in Jinja2 template - 'client_ip_pool': '', - 'client_ip_subnets': [], - 'client_ipv6_pool': [], - 'client_ipv6_delegate_prefix': [], - 'concentrator': 'vyos-ac', - 'interfaces': [], - 'local_users' : [], - - 'svc_name': [], - 'dnsv4': [], - 'dnsv6': [], - 'wins': [], - 'mtu': '1492', - - 'limits_burst': '', - 'limits_connections': '', - 'limits_timeout': '', - - 'pado_delay': '', - 'ppp_ccp': False, - 'ppp_gw': '', - 'ppp_ipv4': '', - 'ppp_ipv6': '', - 'ppp_ipv6_accept_peer_intf_id': False, - 'ppp_ipv6_intf_id': '', - 'ppp_ipv6_peer_intf_id': '', - 'ppp_echo_failure': '3', - 'ppp_echo_interval': '30', - 'ppp_echo_timeout': '0', - 'ppp_min_mtu': '', - 'ppp_mppe': 'prefer', - 'ppp_mru': '', - 'ppp_preallocate_vif': False, - - 'radius_server': [], - 'radius_acct_inter_jitter': '', - 'radius_acct_tmo': '3', - 'radius_max_try': '3', - 'radius_timeout': '3', - 'radius_nas_id': '', - 'radius_nas_ip': '', - 'radius_source_address': '', - 'radius_shaper_attr': '', - 'radius_shaper_vendor': '', - 'radius_dynamic_author': '', - 'sesscrtl': 'replace', - 'snmp': False, - 'thread_cnt': get_half_cpus() -} - def get_config(config=None): if config: conf = config else: conf = Config() - base_path = ['service', 'pppoe-server'] - if not conf.exists(base_path): + base = ['service', 'pppoe-server'] + if not conf.exists(base): return None - conf.set_level(base_path) - pppoe = deepcopy(default_config_data) - - # general options - if conf.exists(['access-concentrator']): - pppoe['concentrator'] = conf.return_value(['access-concentrator']) - - if conf.exists(['service-name']): - pppoe['svc_name'] = conf.return_values(['service-name']) - - if conf.exists(['interface']): - for interface in conf.list_nodes(['interface']): - conf.set_level(base_path + ['interface', interface]) - tmp = { - 'name': interface, - 'vlans': [] - } - - if conf.exists(['vlan-id']): - tmp['vlans'] += conf.return_values(['vlan-id']) - - if conf.exists(['vlan-range']): - tmp['vlans'] += conf.return_values(['vlan-range']) - - pppoe['interfaces'].append(tmp) - - conf.set_level(base_path) - - if conf.exists(['local-ip']): - pppoe['ppp_gw'] = conf.return_value(['local-ip']) - - if conf.exists(['name-server']): - for name_server in conf.return_values(['name-server']): - if is_ipv4(name_server): - pppoe['dnsv4'].append(name_server) - else: - pppoe['dnsv6'].append(name_server) - - if conf.exists(['wins-server']): - pppoe['wins'] = conf.return_values(['wins-server']) - - - if conf.exists(['client-ip-pool']): - if conf.exists(['client-ip-pool', 'start']) and conf.exists(['client-ip-pool', 'stop']): - start = conf.return_value(['client-ip-pool', 'start']) - stop = conf.return_value(['client-ip-pool', 'stop']) - pppoe['client_ip_pool'] = start + '-' + re.search('[0-9]+$', stop).group(0) - - if conf.exists(['client-ip-pool', 'subnet']): - pppoe['client_ip_subnets'] = conf.return_values(['client-ip-pool', 'subnet']) - - - if conf.exists(['client-ipv6-pool', 'prefix']): - for prefix in conf.list_nodes(['client-ipv6-pool', 'prefix']): - tmp = { - 'prefix': prefix, - 'mask': '64' - } - - if conf.exists(['client-ipv6-pool', 'prefix', prefix, 'mask']): - tmp['mask'] = conf.return_value(['client-ipv6-pool', 'prefix', prefix, 'mask']) - - pppoe['client_ipv6_pool'].append(tmp) - - - if conf.exists(['client-ipv6-pool', 'delegate']): - for prefix in conf.list_nodes(['client-ipv6-pool', 'delegate']): - tmp = { - 'prefix': prefix, - 'mask': '' - } - - if conf.exists(['client-ipv6-pool', 'delegate', prefix, 'delegation-prefix']): - tmp['mask'] = conf.return_value(['client-ipv6-pool', 'delegate', prefix, 'delegation-prefix']) - - pppoe['client_ipv6_delegate_prefix'].append(tmp) - - - if conf.exists(['limits']): - if conf.exists(['limits', 'burst']): - pppoe['limits_burst'] = conf.return_value(['limits', 'burst']) - - if conf.exists(['limits', 'connection-limit']): - pppoe['limits_connections'] = conf.return_value(['limits', 'connection-limit']) - - if conf.exists(['limits', 'timeout']): - pppoe['limits_timeout'] = conf.return_value(['limits', 'timeout']) - - - if conf.exists(['snmp']): - pppoe['snmp'] = True - - if conf.exists(['snmp', 'master-agent']): - pppoe['snmp'] = 'enable-ma' - - # authentication mode local - if conf.exists(['authentication', 'mode']): - pppoe['auth_mode'] = conf.return_value(['authentication', 'mode']) - - if conf.exists(['authentication', 'local-users']): - for username in conf.list_nodes(['authentication', 'local-users', 'username']): - user = { - 'name' : username, - 'password' : '', - 'state' : 'enabled', - 'ip' : '*', - 'upload' : None, - 'download' : None - } - conf.set_level(base_path + ['authentication', 'local-users', 'username', username]) - - if conf.exists(['password']): - user['password'] = conf.return_value(['password']) - - if conf.exists(['disable']): - user['state'] = 'disable' - - if conf.exists(['static-ip']): - user['ip'] = conf.return_value(['static-ip']) - - if conf.exists(['rate-limit', 'download']): - user['download'] = conf.return_value(['rate-limit', 'download']) - - if conf.exists(['rate-limit', 'upload']): - user['upload'] = conf.return_value(['rate-limit', 'upload']) - - pppoe['local_users'].append(user) - - conf.set_level(base_path) - - if conf.exists(['authentication', 'protocols']): - auth_mods = { - 'mschap-v2': 'auth_mschap_v2', - 'mschap': 'auth_mschap_v1', - 'chap': 'auth_chap_md5', - 'pap': 'auth_pap' - } - - pppoe['auth_proto'] = [] - for proto in conf.return_values(['authentication', 'protocols']): - pppoe['auth_proto'].append(auth_mods[proto]) - - # - # authentication mode radius servers and settings - if conf.exists(['authentication', 'mode', 'radius']): - - for server in conf.list_nodes(['authentication', 'radius', 'server']): - radius = { - 'server' : server, - 'key' : '', - 'fail_time' : 0, - 'port' : '1812', - 'acct_port' : '1813' - } - - conf.set_level(base_path + ['authentication', 'radius', 'server', server]) - - if conf.exists(['fail-time']): - radius['fail_time'] = conf.return_value(['fail-time']) - - if conf.exists(['port']): - radius['port'] = conf.return_value(['port']) - - if conf.exists(['acct-port']): - radius['acct_port'] = conf.return_value(['acct-port']) - - if conf.exists(['key']): - radius['key'] = conf.return_value(['key']) - - if not conf.exists(['disable']): - pppoe['radius_server'].append(radius) - - # - # advanced radius-setting - conf.set_level(base_path + ['authentication', 'radius']) - - if conf.exists(['acct-interim-jitter']): - pppoe['radius_acct_inter_jitter'] = conf.return_value(['acct-interim-jitter']) - - if conf.exists(['acct-timeout']): - pppoe['radius_acct_tmo'] = conf.return_value(['acct-timeout']) - - if conf.exists(['max-try']): - pppoe['radius_max_try'] = conf.return_value(['max-try']) - - if conf.exists(['timeout']): - pppoe['radius_timeout'] = conf.return_value(['timeout']) - - if conf.exists(['nas-identifier']): - pppoe['radius_nas_id'] = conf.return_value(['nas-identifier']) - - if conf.exists(['nas-ip-address']): - pppoe['radius_nas_ip'] = conf.return_value(['nas-ip-address']) - - if conf.exists(['preallocate-vif']): - pppoe['ppp_preallocate_vif'] = True - - if conf.exists(['source-address']): - pppoe['radius_source_address'] = conf.return_value(['source-address']) - - # Dynamic Authorization Extensions (DOA)/Change Of Authentication (COA) - if conf.exists(['dynamic-author']): - dae = { - 'port' : '', - 'server' : '', - 'key' : '' - } - - if conf.exists(['dynamic-author', 'server']): - dae['server'] = conf.return_value(['dynamic-author', 'server']) - - if conf.exists(['dynamic-author', 'port']): - dae['port'] = conf.return_value(['dynamic-author', 'port']) - - if conf.exists(['dynamic-author', 'key']): - dae['key'] = conf.return_value(['dynamic-author', 'key']) - - pppoe['radius_dynamic_author'] = dae - - # RADIUS based rate-limiter - if conf.exists(['rate-limit', 'enable']): - pppoe['radius_shaper_attr'] = 'Filter-Id' - c_attr = ['rate-limit', 'enable', 'attribute'] - if conf.exists(c_attr): - pppoe['radius_shaper_attr'] = conf.return_value(c_attr) - - c_vendor = ['rate-limit', 'enable', 'vendor'] - if conf.exists(c_vendor): - pppoe['radius_shaper_vendor'] = conf.return_value(c_vendor) - - # re-set config level - conf.set_level(base_path) - - if conf.exists(['mtu']): - pppoe['mtu'] = conf.return_value(['mtu']) - - if conf.exists(['session-control']): - pppoe['sesscrtl'] = conf.return_value(['session-control']) - - # ppp_options - if conf.exists(['ppp-options']): - conf.set_level(base_path + ['ppp-options']) - - if conf.exists(['ccp']): - pppoe['ppp_ccp'] = True - - if conf.exists(['ipv4']): - pppoe['ppp_ipv4'] = conf.return_value(['ipv4']) - - if conf.exists(['ipv6']): - pppoe['ppp_ipv6'] = conf.return_value(['ipv6']) - - if conf.exists(['ipv6-accept-peer-intf-id']): - pppoe['ppp_ipv6_peer_intf_id'] = True - - if conf.exists(['ipv6-intf-id']): - pppoe['ppp_ipv6_intf_id'] = conf.return_value(['ipv6-intf-id']) - - if conf.exists(['ipv6-peer-intf-id']): - pppoe['ppp_ipv6_peer_intf_id'] = conf.return_value(['ipv6-peer-intf-id']) - - if conf.exists(['lcp-echo-failure']): - pppoe['ppp_echo_failure'] = conf.return_value(['lcp-echo-failure']) - - if conf.exists(['lcp-echo-failure']): - pppoe['ppp_echo_interval'] = conf.return_value(['lcp-echo-failure']) - - if conf.exists(['lcp-echo-timeout']): - pppoe['ppp_echo_timeout'] = conf.return_value(['lcp-echo-timeout']) - - if conf.exists(['min-mtu']): - pppoe['ppp_min_mtu'] = conf.return_value(['min-mtu']) - - if conf.exists(['mppe']): - pppoe['ppp_mppe'] = conf.return_value(['mppe']) - - if conf.exists(['mru']): - pppoe['ppp_mru'] = conf.return_value(['mru']) - - if conf.exists(['pado-delay']): - pppoe['pado_delay'] = '0' - a = {} - for id in conf.list_nodes(['pado-delay']): - if not conf.return_value(['pado-delay', id, 'sessions']): - a[id] = 0 - else: - a[id] = conf.return_value(['pado-delay', id, 'sessions']) - - for k in sorted(a.keys()): - if k != sorted(a.keys())[-1]: - pppoe['pado_delay'] += ",{0}:{1}".format(k, a[k]) - else: - pppoe['pado_delay'] += ",{0}:{1}".format('-1', a[k]) - + # retrieve common dictionary keys + pppoe = get_accel_dict(conf, base, pppoe_chap_secrets) return pppoe - def verify(pppoe): if not pppoe: return None - # vertify auth settings - if pppoe['auth_mode'] == 'local': - if not pppoe['local_users']: - raise ConfigError('PPPoE local auth mode requires local users to be configured!') - - for user in pppoe['local_users']: - username = user['name'] - if not user['password']: - raise ConfigError(f'Password required for local user "{username}"') + verify_accel_ppp_base_service(pppoe) - # if up/download is set, check that both have a value - if user['upload'] and not user['download']: - raise ConfigError(f'Download speed value required for local user "{username}"') - - if user['download'] and not user['upload']: - raise ConfigError(f'Upload speed value required for local user "{username}"') - - elif pppoe['auth_mode'] == 'radius': - if len(pppoe['radius_server']) == 0: - raise ConfigError('RADIUS authentication requires at least one server') - - for radius in pppoe['radius_server']: - if not radius['key']: - server = radius['server'] - raise ConfigError(f'Missing RADIUS secret key for server "{ server }"') - - if len(pppoe['wins']) > 2: + if 'wins_server' in pppoe and len(pppoe['wins_server']) > 2: raise ConfigError('Not more then two IPv4 WINS name-servers can be configured') - if len(pppoe['dnsv4']) > 2: - raise ConfigError('Not more then two IPv4 DNS name-servers can be configured') - - if len(pppoe['dnsv6']) > 3: - raise ConfigError('Not more then three IPv6 DNS name-servers can be configured') - - if not pppoe['interfaces']: + if 'interface' not in pppoe: raise ConfigError('At least one listen interface must be defined!') # local ippool and gateway settings config checks - if pppoe['client_ip_subnets'] or pppoe['client_ip_pool']: - if not pppoe['ppp_gw']: - raise ConfigError('PPPoE server requires local IP to be configured') + if not (vyos_dict_search('client_ip_pool.subnet', pppoe) or + (vyos_dict_search('client_ip_pool.start', pppoe) and + vyos_dict_search('client_ip_pool.stop', pppoe))): + print('Warning: No PPPoE client pool defined') - if pppoe['ppp_gw'] and not pppoe['client_ip_subnets'] and not pppoe['client_ip_pool']: - print("Warning: No PPPoE client pool defined") + if vyos_dict_search('authentication.radius.dynamic_author.server', pppoe): + if not vyos_dict_search('authentication.radius.dynamic_author.key', pppoe): + raise ConfigError('DA/CoE server key required!') return None @@ -452,12 +75,12 @@ def generate(pppoe): render(pppoe_conf, 'accel-ppp/pppoe.config.tmpl', pppoe, trim_blocks=True) - if pppoe['local_users']: - render(pppoe_chap_secrets, 'accel-ppp/chap-secrets.tmpl', pppoe, trim_blocks=True) - os.chmod(pppoe_chap_secrets, S_IRUSR | S_IWUSR | S_IRGRP) + if vyos_dict_search('authentication.mode', pppoe) == 'local': + render(pppoe_chap_secrets, 'accel-ppp/chap-secrets.config_dict.tmpl', + pppoe, trim_blocks=True, permission=0o640) else: if os.path.exists(pppoe_chap_secrets): - os.unlink(pppoe_chap_secrets) + os.unlink(pppoe_chap_secrets) return None diff --git a/src/conf_mode/vpn_sstp.py b/src/conf_mode/vpn_sstp.py index 7fc370f99..2597ba42f 100755 --- a/src/conf_mode/vpn_sstp.py +++ b/src/conf_mode/vpn_sstp.py @@ -16,340 +16,66 @@ import os -from time import sleep from sys import exit -from copy import deepcopy -from stat import S_IRUSR, S_IWUSR, S_IRGRP from vyos.config import Config +from vyos.configdict import get_accel_dict +from vyos.configverify import verify_accel_ppp_base_service from vyos.template import render -from vyos.util import call, run, get_half_cpus -from vyos.validate import is_ipv4 +from vyos.util import call +from vyos.util import vyos_dict_search from vyos import ConfigError - from vyos import airbag airbag.enable() sstp_conf = '/run/accel-pppd/sstp.conf' sstp_chap_secrets = '/run/accel-pppd/sstp.chap-secrets' -default_config_data = { - 'local_users' : [], - 'auth_mode' : 'local', - 'auth_proto' : ['auth_mschap_v2'], - 'chap_secrets_file': sstp_chap_secrets, # used in Jinja2 template - 'client_ip_pool' : [], - 'client_ipv6_pool': [], - 'client_ipv6_delegate_prefix': [], - 'client_gateway': '', - 'dnsv4' : [], - 'dnsv6' : [], - 'radius_server' : [], - 'radius_acct_tmo' : '3', - 'radius_max_try' : '3', - 'radius_timeout' : '3', - 'radius_nas_id' : '', - 'radius_nas_ip' : '', - 'radius_source_address' : '', - 'radius_shaper_attr' : '', - 'radius_shaper_vendor': '', - 'radius_dynamic_author' : '', - 'ssl_ca' : '', - 'ssl_cert' : '', - 'ssl_key' : '', - 'mtu' : '', - 'ppp_mppe' : 'prefer', - 'ppp_echo_failure' : '', - 'ppp_echo_interval' : '', - 'ppp_echo_timeout' : '', - 'thread_cnt' : get_half_cpus() -} - def get_config(config=None): - sstp = deepcopy(default_config_data) - base_path = ['vpn', 'sstp'] if config: conf = config else: conf = Config() - if not conf.exists(base_path): + base = ['vpn', 'sstp'] + if not conf.exists(base): return None - conf.set_level(base_path) - - if conf.exists(['authentication', 'mode']): - sstp['auth_mode'] = conf.return_value(['authentication', 'mode']) - - # - # local auth - if conf.exists(['authentication', 'local-users']): - for username in conf.list_nodes(['authentication', 'local-users', 'username']): - user = { - 'name' : username, - 'password' : '', - 'state' : 'enabled', - 'ip' : '*', - 'upload' : None, - 'download' : None - } - - conf.set_level(base_path + ['authentication', 'local-users', 'username', username]) - - if conf.exists(['password']): - user['password'] = conf.return_value(['password']) - - if conf.exists(['disable']): - user['state'] = 'disable' - - if conf.exists(['static-ip']): - user['ip'] = conf.return_value(['static-ip']) - - if conf.exists(['rate-limit', 'download']): - user['download'] = conf.return_value(['rate-limit', 'download']) - - if conf.exists(['rate-limit', 'upload']): - user['upload'] = conf.return_value(['rate-limit', 'upload']) - - sstp['local_users'].append(user) - - # - # RADIUS auth and settings - conf.set_level(base_path + ['authentication', 'radius']) - if conf.exists(['server']): - for server in conf.list_nodes(['server']): - radius = { - 'server' : server, - 'key' : '', - 'fail_time' : 0, - 'port' : '1812', - 'acct_port' : '1813' - } - - conf.set_level(base_path + ['authentication', 'radius', 'server', server]) - - if conf.exists(['fail-time']): - radius['fail_time'] = conf.return_value(['fail-time']) - - if conf.exists(['port']): - radius['port'] = conf.return_value(['port']) - - if conf.exists(['acct-port']): - radius['acct_port'] = conf.return_value(['acct-port']) - - if conf.exists(['key']): - radius['key'] = conf.return_value(['key']) - - if not conf.exists(['disable']): - sstp['radius_server'].append(radius) - - # - # advanced radius-setting - conf.set_level(base_path + ['authentication', 'radius']) - - if conf.exists(['acct-timeout']): - sstp['radius_acct_tmo'] = conf.return_value(['acct-timeout']) - - if conf.exists(['max-try']): - sstp['radius_max_try'] = conf.return_value(['max-try']) - - if conf.exists(['timeout']): - sstp['radius_timeout'] = conf.return_value(['timeout']) - - if conf.exists(['nas-identifier']): - sstp['radius_nas_id'] = conf.return_value(['nas-identifier']) - - if conf.exists(['nas-ip-address']): - sstp['radius_nas_ip'] = conf.return_value(['nas-ip-address']) - - if conf.exists(['source-address']): - sstp['radius_source_address'] = conf.return_value(['source-address']) - - # Dynamic Authorization Extensions (DOA)/Change Of Authentication (COA) - if conf.exists(['dynamic-author']): - dae = { - 'port' : '', - 'server' : '', - 'key' : '' - } - - if conf.exists(['dynamic-author', 'server']): - dae['server'] = conf.return_value(['dynamic-author', 'server']) - - if conf.exists(['dynamic-author', 'port']): - dae['port'] = conf.return_value(['dynamic-author', 'port']) - - if conf.exists(['dynamic-author', 'key']): - dae['key'] = conf.return_value(['dynamic-author', 'key']) - - sstp['radius_dynamic_author'] = dae - - if conf.exists(['rate-limit', 'enable']): - sstp['radius_shaper_attr'] = 'Filter-Id' - c_attr = ['rate-limit', 'enable', 'attribute'] - if conf.exists(c_attr): - sstp['radius_shaper_attr'] = conf.return_value(c_attr) - - c_vendor = ['rate-limit', 'enable', 'vendor'] - if conf.exists(c_vendor): - sstp['radius_shaper_vendor'] = conf.return_value(c_vendor) - - # - # authentication protocols - conf.set_level(base_path + ['authentication']) - if conf.exists(['protocols']): - # clear default list content, now populate with actual CLI values - sstp['auth_proto'] = [] - auth_mods = { - 'pap': 'auth_pap', - 'chap': 'auth_chap_md5', - 'mschap': 'auth_mschap_v1', - 'mschap-v2': 'auth_mschap_v2' - } - - for proto in conf.return_values(['protocols']): - sstp['auth_proto'].append(auth_mods[proto]) - - # - # read in SSL certs - conf.set_level(base_path + ['ssl']) - if conf.exists(['ca-cert-file']): - sstp['ssl_ca'] = conf.return_value(['ca-cert-file']) - - if conf.exists(['cert-file']): - sstp['ssl_cert'] = conf.return_value(['cert-file']) - - if conf.exists(['key-file']): - sstp['ssl_key'] = conf.return_value(['key-file']) - - - # - # read in client IPv4 pool - conf.set_level(base_path + ['network-settings', 'client-ip-settings']) - if conf.exists(['subnet']): - sstp['client_ip_pool'] = conf.return_values(['subnet']) - - if conf.exists(['gateway-address']): - sstp['client_gateway'] = conf.return_value(['gateway-address']) - - # - # read in client IPv6 pool - conf.set_level(base_path + ['network-settings', 'client-ipv6-pool']) - if conf.exists(['prefix']): - for prefix in conf.list_nodes(['prefix']): - tmp = { - 'prefix': prefix, - 'mask': '64' - } - - if conf.exists(['prefix', prefix, 'mask']): - tmp['mask'] = conf.return_value(['prefix', prefix, 'mask']) - - sstp['client_ipv6_pool'].append(tmp) - - if conf.exists(['delegate']): - for prefix in conf.list_nodes(['delegate']): - tmp = { - 'prefix': prefix, - 'mask': '' - } - - if conf.exists(['delegate', prefix, 'delegation-prefix']): - tmp['mask'] = conf.return_value(['delegate', prefix, 'delegation-prefix']) - - sstp['client_ipv6_delegate_prefix'].append(tmp) - - # - # read in network settings - conf.set_level(base_path + ['network-settings']) - if conf.exists(['name-server']): - for name_server in conf.return_values(['name-server']): - if is_ipv4(name_server): - sstp['dnsv4'].append(name_server) - else: - sstp['dnsv6'].append(name_server) - - if conf.exists(['mtu']): - sstp['mtu'] = conf.return_value(['mtu']) - - # - # read in PPP stuff - conf.set_level(base_path + ['ppp-settings']) - if conf.exists('mppe'): - sstp['ppp_mppe'] = conf.return_value(['ppp-settings', 'mppe']) - - if conf.exists(['lcp-echo-failure']): - sstp['ppp_echo_failure'] = conf.return_value(['lcp-echo-failure']) - - if conf.exists(['lcp-echo-interval']): - sstp['ppp_echo_interval'] = conf.return_value(['lcp-echo-interval']) - - if conf.exists(['lcp-echo-timeout']): - sstp['ppp_echo_timeout'] = conf.return_value(['lcp-echo-timeout']) - + # retrieve common dictionary keys + sstp = get_accel_dict(conf, base, sstp_chap_secrets) return sstp - def verify(sstp): - if sstp is None: + if not sstp: return None - # vertify auth settings - if sstp['auth_mode'] == 'local': - if not sstp['local_users']: - raise ConfigError('SSTP local auth mode requires local users to be configured!') - - for user in sstp['local_users']: - username = user['name'] - if not user['password']: - raise ConfigError(f'Password required for local user "{username}"') - - # if up/download is set, check that both have a value - if user['upload'] and not user['download']: - raise ConfigError(f'Download speed value required for local user "{username}"') - - if user['download'] and not user['upload']: - raise ConfigError(f'Upload speed value required for local user "{username}"') - - if not sstp['client_ip_pool']: - raise ConfigError('Client IP subnet required') - - if not sstp['client_gateway']: - raise ConfigError('Client gateway IP address required') - - if len(sstp['dnsv4']) > 2: - raise ConfigError('Not more then two IPv4 DNS name-servers can be configured') + verify_accel_ppp_base_service(sstp) - # check ipv6 - if sstp['client_ipv6_delegate_prefix'] and not sstp['client_ipv6_pool']: - raise ConfigError('IPv6 prefix delegation requires client-ipv6-pool prefix') + if not sstp['client_ip_pool']: + raise ConfigError('Client IP subnet required') - for prefix in sstp['client_ipv6_delegate_prefix']: - if not prefix['mask']: - raise ConfigError('Delegation-prefix required for individual delegated networks') - - if not sstp['ssl_ca'] or not sstp['ssl_cert'] or not sstp['ssl_key']: - raise ConfigError('One or more SSL certificates missing') - - if not os.path.exists(sstp['ssl_ca']): - file = sstp['ssl_ca'] - raise ConfigError(f'SSL CA certificate file "{file}" does not exist') - - if not os.path.exists(sstp['ssl_cert']): - file = sstp['ssl_cert'] - raise ConfigError(f'SSL public key file "{file}" does not exist') - - if not os.path.exists(sstp['ssl_key']): - file = sstp['ssl_key'] - raise ConfigError(f'SSL private key file "{file}" does not exist') + # + # SSL certificate checks + # + tmp = vyos_dict_search('ssl.ca_cert_file', sstp) + if not tmp: + raise ConfigError(f'SSL CA certificate file required!') + else: + if not os.path.isfile(tmp): + raise ConfigError(f'SSL CA certificate "{tmp}" does not exist!') - if sstp['auth_mode'] == 'radius': - if len(sstp['radius_server']) == 0: - raise ConfigError('RADIUS authentication requires at least one server') + tmp = vyos_dict_search('ssl.cert_file', sstp) + if not tmp: + raise ConfigError(f'SSL public key file required!') + else: + if not os.path.isfile(tmp): + raise ConfigError(f'SSL public key "{tmp}" does not exist!') - for radius in sstp['radius_server']: - if not radius['key']: - server = radius['server'] - raise ConfigError(f'Missing RADIUS secret key for server "{ server }"') + tmp = vyos_dict_search('ssl.key_file', sstp) + if not tmp: + raise ConfigError(f'SSL private key file required!') + else: + if not os.path.isfile(tmp): + raise ConfigError(f'SSL private key "{tmp}" does not exist!') def generate(sstp): if not sstp: @@ -358,9 +84,9 @@ def generate(sstp): # accel-cmd reload doesn't work so any change results in a restart of the daemon render(sstp_conf, 'accel-ppp/sstp.config.tmpl', sstp, trim_blocks=True) - if sstp['local_users']: - render(sstp_chap_secrets, 'accel-ppp/chap-secrets.tmpl', sstp, trim_blocks=True) - os.chmod(sstp_chap_secrets, S_IRUSR | S_IWUSR | S_IRGRP) + if vyos_dict_search('authentication.mode', sstp) == 'local': + render(sstp_chap_secrets, 'accel-ppp/chap-secrets.config_dict.tmpl', + sstp, trim_blocks=True, permission=0o640) else: if os.path.exists(sstp_chap_secrets): os.unlink(sstp_chap_secrets) diff --git a/src/conf_mode/vrrp.py b/src/conf_mode/vrrp.py index f1ceb261b..4510dd3e7 100755 --- a/src/conf_mode/vrrp.py +++ b/src/conf_mode/vrrp.py @@ -62,6 +62,7 @@ def get_config(config=None): group["sync_group"] = config.return_value("sync-group") group["preempt_delay"] = config.return_value("preempt-delay") group["virtual_addresses"] = config.return_values("virtual-address") + group["virtual_addresses_excluded"] = config.return_values("virtual-address-excluded") group["auth_password"] = config.return_value("authentication password") group["auth_type"] = config.return_value("authentication type") diff --git a/src/migration-scripts/pppoe-server/0-to-1 b/src/migration-scripts/pppoe-server/0-to-1 index bb24211b6..063c7eb56 100755 --- a/src/migration-scripts/pppoe-server/0-to-1 +++ b/src/migration-scripts/pppoe-server/0-to-1 @@ -1,37 +1,50 @@ #!/usr/bin/env python3 - -# Convert "service pppoe-server authentication radius-server node key" -# to: -# "service pppoe-server authentication radius-server node secret" - -import sys - +# +# Copyright (C) 2020 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Convert "service pppoe-server authentication radius-server node key" +# to: "service pppoe-server authentication radius-server node secret" + +from sys import argv, exit from vyos.configtree import ConfigTree -if (len(sys.argv) < 1): +if (len(argv) < 1): print("Must specify file name!") - sys.exit(1) + exit(1) -file_name = sys.argv[1] +file_name = argv[1] with open(file_name, 'r') as f: config_file = f.read() ctree = ConfigTree(config_file) +base = ['service', 'pppoe-server', 'authentication', 'radius-server'] - -if not ctree.exists(['service', 'pppoe-server', 'authentication','radius-server']): +if not ctree.exists(base): # Nothing to do - sys.exit(0) + exit(0) else: - nodes = ctree.list_nodes(['service', 'pppoe-server', 'authentication','radius-server']) - for node in nodes: - if ctree.exists(['service', 'pppoe-server', 'authentication', 'radius-server', node, 'key']): - val = ctree.return_value(['service', 'pppoe-server', 'authentication', 'radius-server', node, 'key']) - ctree.set(['service', 'pppoe-server', 'authentication', 'radius-server', node, 'secret'], value=val, replace=False) - ctree.delete(['service', 'pppoe-server', 'authentication', 'radius-server', node, 'key']) - try: - open(file_name,'w').write(ctree.to_string()) - except OSError as e: - print("Failed to save the modified config: {}".format(e)) - sys.exit(1) + nodes = ctree.list_nodes(base) + for node in nodes: + if ctree.exists(base + [node, 'key']): + val = ctree.return_value(base + [node, 'key']) + ctree.set(base + [node, 'secret'], value=val, replace=False) + ctree.delete(base + [node, 'key']) + + try: + open(file_name,'w').write(ctree.to_string()) + except OSError as e: + print("Failed to save the modified config: {}".format(e)) + exit(1) diff --git a/src/migration-scripts/pppoe-server/1-to-2 b/src/migration-scripts/pppoe-server/1-to-2 index fa83896d3..902efb86b 100755 --- a/src/migration-scripts/pppoe-server/1-to-2 +++ b/src/migration-scripts/pppoe-server/1-to-2 @@ -1,38 +1,61 @@ #!/usr/bin/env python3 - -# Convert "service pppoe-server interface ethX" -# to: -# "service pppoe-server interface ethX {}" - -import sys - +# +# Copyright (C) 2020 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# change mppe node to a leaf node with value prefer + +import os + +from sys import argv, exit from vyos.configtree import ConfigTree -if (len(sys.argv) < 1): +if (len(argv) < 1): print("Must specify file name!") - sys.exit(1) + exit(1) -file_name = sys.argv[1] +file_name = argv[1] with open(file_name, 'r') as f: config_file = f.read() -ctree = ConfigTree(config_file) -cbase = ['service', 'pppoe-server','interface'] - -if not ctree.exists(cbase): - sys.exit(0) +config = ConfigTree(config_file) +base = ['service', 'pppoe-server'] +if not config.exists(base): + # Nothing to do + exit(0) else: - nics = ctree.return_values(cbase) - # convert leafNode to a tagNode - ctree.set(cbase) - ctree.set_tag(cbase) - for nic in nics: - ctree.set(cbase + [nic]) - - try: - open(file_name,'w').write(ctree.to_string()) - except OSError as e: - print("Failed to save the modified config: {}".format(e)) - sys.exit(1) + mppe_base = base + ['ppp-options', 'mppe'] + if config.exists(mppe_base): + # get current values + tmp = config.list_nodes(mppe_base) + # drop node(s) first ... + config.delete(mppe_base) + + print(tmp) + # set new value based on preference + if 'require' in tmp: + config.set(mppe_base, value='require') + elif 'prefer' in tmp: + config.set(mppe_base, value='prefer') + elif 'deny' in tmp: + config.set(mppe_base, value='deny') + + try: + with open(file_name, 'w') as f: + f.write(config.to_string()) + except OSError as e: + print("Failed to save the modified config: {}".format(e)) + exit(1) diff --git a/src/migration-scripts/pppoe-server/2-to-3 b/src/migration-scripts/pppoe-server/2-to-3 index 5f9730a41..7cae3b5bc 100755 --- a/src/migration-scripts/pppoe-server/2-to-3 +++ b/src/migration-scripts/pppoe-server/2-to-3 @@ -14,9 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -# - remove primary/secondary identifier from nameserver - -import os +# Convert "service pppoe-server interface ethX" to: "service pppoe-server interface ethX {}" from sys import argv, exit from vyos.configtree import ConfigTree @@ -30,112 +28,21 @@ file_name = argv[1] with open(file_name, 'r') as f: config_file = f.read() -config = ConfigTree(config_file) -base = ['service', 'pppoe-server'] -if not config.exists(base): - # Nothing to do +ctree = ConfigTree(config_file) +cbase = ['service', 'pppoe-server','interface'] + +if not ctree.exists(cbase): exit(0) else: - - # Migrate IPv4 DNS servers - dns_base = base + ['dns-servers'] - if config.exists(dns_base): - for server in ['server-1', 'server-2']: - if config.exists(dns_base + [server]): - dns = config.return_value(dns_base + [server]) - config.set(base + ['name-server'], value=dns, replace=False) - - config.delete(dns_base) - - # Migrate IPv6 DNS servers - dns_base = base + ['dnsv6-servers'] - if config.exists(dns_base): - for server in ['server-1', 'server-2', 'server-3']: - if config.exists(dns_base + [server]): - dns = config.return_value(dns_base + [server]) - config.set(base + ['name-server'], value=dns, replace=False) - - config.delete(dns_base) - - # Migrate IPv4 WINS servers - wins_base = base + ['wins-servers'] - if config.exists(wins_base): - for server in ['server-1', 'server-2']: - if config.exists(wins_base + [server]): - wins = config.return_value(wins_base + [server]) - config.set(base + ['wins-server'], value=wins, replace=False) - - config.delete(wins_base) - - # Migrate radius-settings node to RADIUS and use this as base for the - # later migration of the RADIUS servers - this will save a lot of code - radius_settings = base + ['authentication', 'radius-settings'] - if config.exists(radius_settings): - config.rename(radius_settings, 'radius') - - # Migrate RADIUS dynamic author / change of authorisation server - dae_old = base + ['authentication', 'radius', 'dae-server'] - if config.exists(dae_old): - config.rename(dae_old, 'dynamic-author') - dae_new = base + ['authentication', 'radius', 'dynamic-author'] - - if config.exists(dae_new + ['ip-address']): - config.rename(dae_new + ['ip-address'], 'server') - - if config.exists(dae_new + ['secret']): - config.rename(dae_new + ['secret'], 'key') - - # Migrate RADIUS server - radius_server = base + ['authentication', 'radius-server'] - if config.exists(radius_server): - new_base = base + ['authentication', 'radius', 'server'] - config.set(new_base) - config.set_tag(new_base) - for server in config.list_nodes(radius_server): - old_base = radius_server + [server] - config.copy(old_base, new_base + [server]) - - # migrate key - if config.exists(new_base + [server, 'secret']): - config.rename(new_base + [server, 'secret'], 'key') - - # remove old req-limit node - if config.exists(new_base + [server, 'req-limit']): - config.delete(new_base + [server, 'req-limit']) - - config.delete(radius_server) - - # Migrate IPv6 prefixes - ipv6_base = base + ['client-ipv6-pool'] - if config.exists(ipv6_base + ['prefix']): - prefix_old = config.return_values(ipv6_base + ['prefix']) - # delete old prefix CLI nodes - config.delete(ipv6_base + ['prefix']) - # create ned prefix tag node - config.set(ipv6_base + ['prefix']) - config.set_tag(ipv6_base + ['prefix']) - - for p in prefix_old: - prefix = p.split(',')[0] - mask = p.split(',')[1] - config.set(ipv6_base + ['prefix', prefix, 'mask'], value=mask) - - if config.exists(ipv6_base + ['delegate-prefix']): - prefix_old = config.return_values(ipv6_base + ['delegate-prefix']) - # delete old delegate prefix CLI nodes - config.delete(ipv6_base + ['delegate-prefix']) - # create ned delegation tag node - config.set(ipv6_base + ['delegate']) - config.set_tag(ipv6_base + ['delegate']) - - for p in prefix_old: - prefix = p.split(',')[0] - mask = p.split(',')[1] - config.set(ipv6_base + ['delegate', prefix, 'delegation-prefix'], value=mask) + nics = ctree.return_values(cbase) + # convert leafNode to a tagNode + ctree.set(cbase) + ctree.set_tag(cbase) + for nic in nics: + ctree.set(cbase + [nic]) try: - with open(file_name, 'w') as f: - f.write(config.to_string()) + open(file_name,'w').write(ctree.to_string()) except OSError as e: print("Failed to save the modified config: {}".format(e)) exit(1) diff --git a/src/migration-scripts/pppoe-server/3-to-4 b/src/migration-scripts/pppoe-server/3-to-4 index ed5a01625..5f9730a41 100755 --- a/src/migration-scripts/pppoe-server/3-to-4 +++ b/src/migration-scripts/pppoe-server/3-to-4 @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -# change mppe node to a leaf node with value prefer +# - remove primary/secondary identifier from nameserver import os @@ -36,15 +36,102 @@ if not config.exists(base): # Nothing to do exit(0) else: - mppe_base = base + ['ppp-options', 'mppe'] - if config.exists(mppe_base): - # drop node first ... - config.delete(mppe_base) - # ... and set new default - config.set(mppe_base, value='prefer') - - print(config.to_string()) - exit(1) + + # Migrate IPv4 DNS servers + dns_base = base + ['dns-servers'] + if config.exists(dns_base): + for server in ['server-1', 'server-2']: + if config.exists(dns_base + [server]): + dns = config.return_value(dns_base + [server]) + config.set(base + ['name-server'], value=dns, replace=False) + + config.delete(dns_base) + + # Migrate IPv6 DNS servers + dns_base = base + ['dnsv6-servers'] + if config.exists(dns_base): + for server in ['server-1', 'server-2', 'server-3']: + if config.exists(dns_base + [server]): + dns = config.return_value(dns_base + [server]) + config.set(base + ['name-server'], value=dns, replace=False) + + config.delete(dns_base) + + # Migrate IPv4 WINS servers + wins_base = base + ['wins-servers'] + if config.exists(wins_base): + for server in ['server-1', 'server-2']: + if config.exists(wins_base + [server]): + wins = config.return_value(wins_base + [server]) + config.set(base + ['wins-server'], value=wins, replace=False) + + config.delete(wins_base) + + # Migrate radius-settings node to RADIUS and use this as base for the + # later migration of the RADIUS servers - this will save a lot of code + radius_settings = base + ['authentication', 'radius-settings'] + if config.exists(radius_settings): + config.rename(radius_settings, 'radius') + + # Migrate RADIUS dynamic author / change of authorisation server + dae_old = base + ['authentication', 'radius', 'dae-server'] + if config.exists(dae_old): + config.rename(dae_old, 'dynamic-author') + dae_new = base + ['authentication', 'radius', 'dynamic-author'] + + if config.exists(dae_new + ['ip-address']): + config.rename(dae_new + ['ip-address'], 'server') + + if config.exists(dae_new + ['secret']): + config.rename(dae_new + ['secret'], 'key') + + # Migrate RADIUS server + radius_server = base + ['authentication', 'radius-server'] + if config.exists(radius_server): + new_base = base + ['authentication', 'radius', 'server'] + config.set(new_base) + config.set_tag(new_base) + for server in config.list_nodes(radius_server): + old_base = radius_server + [server] + config.copy(old_base, new_base + [server]) + + # migrate key + if config.exists(new_base + [server, 'secret']): + config.rename(new_base + [server, 'secret'], 'key') + + # remove old req-limit node + if config.exists(new_base + [server, 'req-limit']): + config.delete(new_base + [server, 'req-limit']) + + config.delete(radius_server) + + # Migrate IPv6 prefixes + ipv6_base = base + ['client-ipv6-pool'] + if config.exists(ipv6_base + ['prefix']): + prefix_old = config.return_values(ipv6_base + ['prefix']) + # delete old prefix CLI nodes + config.delete(ipv6_base + ['prefix']) + # create ned prefix tag node + config.set(ipv6_base + ['prefix']) + config.set_tag(ipv6_base + ['prefix']) + + for p in prefix_old: + prefix = p.split(',')[0] + mask = p.split(',')[1] + config.set(ipv6_base + ['prefix', prefix, 'mask'], value=mask) + + if config.exists(ipv6_base + ['delegate-prefix']): + prefix_old = config.return_values(ipv6_base + ['delegate-prefix']) + # delete old delegate prefix CLI nodes + config.delete(ipv6_base + ['delegate-prefix']) + # create ned delegation tag node + config.set(ipv6_base + ['delegate']) + config.set_tag(ipv6_base + ['delegate']) + + for p in prefix_old: + prefix = p.split(',')[0] + mask = p.split(',')[1] + config.set(ipv6_base + ['delegate', prefix, 'delegation-prefix'], value=mask) try: with open(file_name, 'w') as f: diff --git a/src/migration-scripts/pppoe-server/4-to-5 b/src/migration-scripts/pppoe-server/4-to-5 new file mode 100755 index 000000000..05e9c17d6 --- /dev/null +++ b/src/migration-scripts/pppoe-server/4-to-5 @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2020 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# - rename local-ip to gateway-address + +from vyos.configtree import ConfigTree +from sys import argv +from sys import exit + +if (len(argv) < 1): + print("Must specify file name!") + exit(1) + +file_name = argv[1] + +with open(file_name, 'r') as f: + config_file = f.read() + +config = ConfigTree(config_file) +base_path = ['service', 'pppoe-server'] +if not config.exists(base_path): + # Nothing to do + exit(0) +else: + config_gw = base_path + ['local-ip'] + if config.exists(config_gw): + config.rename(config_gw, 'gateway-address') + config.delete(config_gw) + + try: + with open(file_name, 'w') as f: + f.write(config.to_string()) + except OSError as e: + print("Failed to save the modified config: {}".format(e)) + exit(1) + diff --git a/src/migration-scripts/sstp/0-to-1 b/src/migration-scripts/sstp/0-to-1 index 0e8dd1c4b..dc65bdeab 100755 --- a/src/migration-scripts/sstp/0-to-1 +++ b/src/migration-scripts/sstp/0-to-1 @@ -107,9 +107,9 @@ else: config.delete(radius_server) # migrate SSL certificates - old_ssl = new_base + ['sstp-settings', 'ssl-certs'] + old_ssl = new_base + ['sstp-settings'] new_ssl = new_base + ['ssl'] - config.copy(old_ssl, new_ssl) + config.copy(old_ssl + ['ssl-certs'], new_ssl) config.delete(old_ssl) if config.exists(new_ssl + ['ca']): @@ -121,7 +121,6 @@ else: if config.exists(new_ssl + ['server-key']): config.rename(new_ssl + ['server-key'], 'key-file') - try: with open(file_name, 'w') as f: f.write(config.to_string()) diff --git a/src/migration-scripts/sstp/2-to-3 b/src/migration-scripts/sstp/2-to-3 new file mode 100755 index 000000000..963b2ba4b --- /dev/null +++ b/src/migration-scripts/sstp/2-to-3 @@ -0,0 +1,78 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2020 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# - Rename SSTP ppp-settings node to ppp-options to make use of a common +# Jinja Template to render Accel-PPP services + +from vyos.configtree import ConfigTree +from sys import argv +from sys import exit + +if (len(argv) < 1): + print("Must specify file name!") + exit(1) + +file_name = argv[1] + +with open(file_name, 'r') as f: + config_file = f.read() + +config = ConfigTree(config_file) +base_path = ['vpn', 'sstp'] +if not config.exists(base_path): + # Nothing to do + exit(0) +else: + if config.exists(base_path + ['ppp-settings']): + config.rename(base_path + ['ppp-settings'], 'ppp-options') + + config_ns = base_path + ['network-settings', 'name-server'] + if config.exists(config_ns): + config.copy(config_ns, base_path + ['name-server']) + config.delete(config_ns) + + config_mtu = base_path + ['network-settings', 'mtu'] + if config.exists(config_mtu): + config.copy(config_mtu, base_path + ['mtu']) + config.delete(config_mtu) + + config_gw = base_path + ['network-settings', 'client-ip-settings', 'gateway-address'] + if config.exists(config_gw): + config.copy(config_gw, base_path + ['gateway-address']) + config.delete(config_gw) + + config_client_ip = base_path + ['network-settings', 'client-ip-settings'] + if config.exists(config_client_ip): + config.copy(config_client_ip, base_path + ['client-ip-pool']) + config.delete(config_client_ip) + + config_client_ipv6 = base_path + ['network-settings', 'client-ipv6-pool'] + if config.exists(config_client_ipv6): + config.copy(config_client_ipv6, base_path + ['client-ipv6-pool']) + config.delete(config_client_ipv6) + + # all nodes now have been migrated out of network-settings - delete node + config_nw_settings = base_path + ['network-settings'] + if config.exists(config_nw_settings): + config.delete(config_nw_settings) + + try: + with open(file_name, 'w') as f: + f.write(config.to_string()) + except OSError as e: + print("Failed to save the modified config: {}".format(e)) + exit(1) + diff --git a/src/op_mode/show_openvpn.py b/src/op_mode/show_openvpn.py index 32918ddce..1da4c7ecb 100755 --- a/src/op_mode/show_openvpn.py +++ b/src/op_mode/show_openvpn.py @@ -51,7 +51,7 @@ def bytes2HR(size): return output def get_status(mode, interface): - status_file = '/opt/vyatta/etc/openvpn/status/{}.status'.format(interface) + status_file = '/var/run/openvpn/{}.status'.format(interface) # this is an empirical value - I assume we have no more then 999999 # current OpenVPN connections routing_table_line = 999999 @@ -175,4 +175,3 @@ if __name__ == '__main__': tmpl = jinja2.Template(outp_tmpl) print(tmpl.render(data)) - diff --git a/src/services/vyos-configd b/src/services/vyos-configd index 642952936..671a89036 100755 --- a/src/services/vyos-configd +++ b/src/services/vyos-configd @@ -27,7 +27,7 @@ import importlib.util import zmq from vyos.defaults import directories -from vyos.configsource import ConfigSourceString +from vyos.configsource import ConfigSourceString, ConfigSourceError from vyos.config import Config from vyos import ConfigError @@ -59,9 +59,6 @@ configd_env_unset_file = os.path.join(directories['data'], 'vyos-configd-env-uns # sourced on entering config session configd_env_file = '/etc/default/vyos-configd-env' -active_string = '' -session_string = '' - session_tty = None def key_name_from_file_name(f): @@ -137,8 +134,19 @@ def initialization(socket): # Reset config strings: active_string = '' session_string = '' + # check first for resent init msg, in case of client timeout + while True: + msg = socket.recv().decode() + try: + message = json.loads(msg) + if message["type"] == "init": + resp = "init" + socket.send(resp.encode()) + except: + break + # zmq synchronous for ipc from single client: - active_string = socket.recv().decode() + active_string = msg resp = "active" socket.send(resp.encode()) session_string = socket.recv().decode() @@ -154,8 +162,12 @@ def initialization(socket): except FileNotFoundError: session_tty = None - configsource = ConfigSourceString(running_config_text=active_string, - session_config_text=session_string) + try: + configsource = ConfigSourceString(running_config_text=active_string, + session_config_text=session_string) + except ConfigSourceError as e: + logger.debug(e) + return None config = Config(config_source=configsource) |