From fa6650a072484425d6080aee7a65932cd02a4577 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 29 Jun 2017 10:33:10 -0400 Subject: [PATCH] Non-linux fallback for list_interface_indexes() When errors suggest we are not in linux, make a best effort using netifaces. --- confluent_server/confluent/util.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/confluent_server/confluent/util.py b/confluent_server/confluent/util.py index 4fd60fbf..5e2d6e1e 100644 --- a/confluent_server/confluent/util.py +++ b/confluent_server/confluent/util.py @@ -37,7 +37,14 @@ def list_interface_indexes(): yield intidx except (IOError, OSError): # Probably situation is non-Linux, just do limited support for - # such platforms until other people come alonge + # such platforms until other people come along + for iface in netifaces.interfaces(): + addrinfo = netifaces.ifaddresses(iface).get(socket.AF_INET6, []) + for addr in addrinfo: + v6addr = addr.get('addr', '').partition('%')[2] + if v6addr: + yield(int(v6addr)) + break return