From c4f0fafc041eb529679d3c9a3b17fbd23290afc2 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sun, 26 Mar 2023 20:31:25 +0200 Subject: [PATCH] Ignore error when multiple interfaces are detected --- generate-dhcpd-conf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generate-dhcpd-conf b/generate-dhcpd-conf index 58138d5..7276c67 100755 --- a/generate-dhcpd-conf +++ b/generate-dhcpd-conf @@ -40,8 +40,8 @@ def addr_of(addrs, dev : str) -> ipaddress.IPv4Interface: for addr in addrs: if addr['ifname'] != dev: continue - if len(addr['addr_info']) != 1: - raise ValueError('only exactly one address on dev is supported') + #if len(addr['addr_info']) != 1: + # raise ValueError('only exactly one address on dev is supported') info = addr['addr_info'][0] return ipaddress.IPv4Interface((info['local'], info['prefixlen'])) raise ValueError('dev {0} not found'.format(dev)) @@ -50,11 +50,11 @@ def generate_conf(intf_name : str, dns : Iterable[str]) -> str: """Generates a dhcpd config. `intf_name` is the interface to listen on.""" with subprocess.Popen(['ip', '-json', 'route'], stdout=subprocess.PIPE) as proc: - routes = json.load(proc.stdout) + routes = json.load(proc.stdout) with subprocess.Popen(['ip', '-json', 'addr'], stdout=subprocess.PIPE) as proc: addrs = json.load(proc.stdout) - + droute = default_route(routes) host_addr = addr_of(addrs, droute['dev'])