summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-11-08 18:37:33 +0100
committerChristian Poessinger <christian@poessinger.com>2019-11-08 18:37:33 +0100
commit8abde544455dd158d080eb6ea7b7ed226b27965a (patch)
tree2259e5768e5c71fbf38efccea7e3f0d81d819074
parent37dcd23368de5872a5d56d356d29cafb1b185ce5 (diff)
parentcc2ea329b1bb2ac23ffcc64892e831e7978023e2 (diff)
downloadvyos-1x-8abde544455dd158d080eb6ea7b7ed226b27965a.tar.gz
vyos-1x-8abde544455dd158d080eb6ea7b7ed226b27965a.zip
Merge branch 'current' of github.com:vyos/vyos-1x into equuleus
* 'current' of github.com:vyos/vyos-1x: ddclient: T1789: fix RFC2136 generated config T1774: fix error output Python/ifconfig: T1557: do not allow both IPv4 and dhcp address on interfaces list_interfaces: add wifi interfaces to bridgeable interfaces
-rw-r--r--python/vyos/ifconfig.py17
-rw-r--r--python/vyos/interfaces.py8
-rwxr-xr-xsrc/completion/list_interfaces.py4
-rwxr-xr-xsrc/conf_mode/dynamic_dns.py10
-rwxr-xr-xsrc/services/vyos-http-api-server2
5 files changed, 30 insertions, 11 deletions
diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py
index df86e3c93..66ccc85e9 100644
--- a/python/vyos/ifconfig.py
+++ b/python/vyos/ifconfig.py
@@ -23,6 +23,8 @@ import time
import vyos.interfaces
from vyos.validate import *
from vyos.config import Config
+from vyos import ConfigError
+
from ipaddress import IPv4Network, IPv6Address
from netifaces import ifaddresses, AF_INET, AF_INET6
from subprocess import Popen, PIPE, STDOUT
@@ -113,6 +115,9 @@ class Interface:
'dhcpv6_temporary' : False
}
+ # list of assigned IP addresses
+ self._addr = []
+
def _debug_msg(self, msg):
if os.path.isfile('/tmp/vyos.ifconfig.debug'):
print('DEBUG/{:<6} {}'.format(self._ifname, msg))
@@ -432,6 +437,18 @@ class Interface:
>>> j.get_addr()
['192.0.2.1/24', '2001:db8::ffff/64']
"""
+
+ # cache new IP address which is assigned to interface
+ self._addr.append(addr)
+
+ # we can not have both DHCP and static IPv4 addresses assigned to an interface
+ if 'dhcp' in self._addr:
+ for addr in self._addr:
+ # do not change below 'if' ordering esle you will get an exception as:
+ # ValueError: 'dhcp' does not appear to be an IPv4 or IPv6 address
+ if addr != 'dhcp' and is_ipv4(addr):
+ raise ConfigError("Can't configure both static IPv4 and DHCP address on the same interface")
+
if addr == 'dhcp':
self._set_dhcp()
elif addr == 'dhcpv6':
diff --git a/python/vyos/interfaces.py b/python/vyos/interfaces.py
index ecf061d17..37c093aca 100644
--- a/python/vyos/interfaces.py
+++ b/python/vyos/interfaces.py
@@ -59,7 +59,7 @@ def wireguard_dump():
"""Dump wireguard data in a python friendly way."""
last_device=None
output = {}
-
+
# Dump wireguard connection data
_f = subprocess.check_output(["wg", "show", "all", "dump"]).decode()
for line in _f.split('\n'):
@@ -72,14 +72,14 @@ def wireguard_dump():
# We are currently entering a new node
device, private_key, public_key, listen_port, fw_mark = items
last_device = device
-
+
output[device] = {
'private_key': None if private_key == '(none)' else private_key,
'public_key': None if public_key == '(none)' else public_key,
'listen_port': int(listen_port),
'fw_mark': None if fw_mark == 'off' else int(fw_mark),
'peers': {},
- }
+ }
else:
# We are entering a peer
device, public_key, preshared_key, endpoint, allowed_ips, latest_handshake, transfer_rx, transfer_tx, persistent_keepalive = items
@@ -95,5 +95,5 @@ def wireguard_dump():
'transfer_rx': int(transfer_rx),
'transfer_tx': int(transfer_tx),
'persistent_keepalive': None if persistent_keepalive == 'off' else int(persistent_keepalive),
- }
+ }
return output
diff --git a/src/completion/list_interfaces.py b/src/completion/list_interfaces.py
index 84d17f89f..47eeaf00c 100755
--- a/src/completion/list_interfaces.py
+++ b/src/completion/list_interfaces.py
@@ -16,7 +16,7 @@ args = parser.parse_args()
if args.type:
try:
interfaces = vyos.interfaces.list_interfaces_of_type(args.type)
-
+
except ValueError as e:
print(e, file=sys.stderr)
print("")
@@ -35,6 +35,8 @@ elif args.bridgeable:
vxlan = vyos.interfaces.list_interfaces_of_type("vxlan")
wireless = vyos.interfaces.list_interfaces_of_type("wireless")
tunnel = vyos.interfaces.list_interfaces_of_type("tunnel")
+ wireless = vyos.interfaces.list_interfaces_of_type("wireless")
+
interfaces = eth + bond + l2tpv3 + openvpn + vxlan + wireless + tunnel
elif args.bondable:
diff --git a/src/conf_mode/dynamic_dns.py b/src/conf_mode/dynamic_dns.py
index 027a7f7e3..7c3b9ff6a 100755
--- a/src/conf_mode/dynamic_dns.py
+++ b/src/conf_mode/dynamic_dns.py
@@ -47,11 +47,11 @@ use=if, if={{ interface.interface }}
{% for rfc in interface.rfc2136 -%}
{% for record in rfc.record %}
# RFC2136 dynamic DNS configuration for {{ record }}.{{ rfc.zone }}
-server={{ rfc.server }},
-protocol=nsupdate,
-password={{ rfc.keyfile }},
-ttl={{ rfc.ttl }},
-zone={{ rfc.zone }},
+server={{ rfc.server }}
+protocol=nsupdate
+password={{ rfc.keyfile }}
+ttl={{ rfc.ttl }}
+zone={{ rfc.zone }}
{{ record }}
{% endfor -%}
{% endfor -%}
diff --git a/src/services/vyos-http-api-server b/src/services/vyos-http-api-server
index 571ec1258..1abaed873 100755
--- a/src/services/vyos-http-api-server
+++ b/src/services/vyos-http-api-server
@@ -221,7 +221,7 @@ def get_value():
elif config_format == 'raw':
pass
else:
- return error(400, "\"{0}\" is not a valid config format")
+ return error(400, "\"{0}\" is not a valid config format".format(config_format))
else:
return error(400, "\"{0}\" is not a valid operation".format(op))
except VyOSError as e: