From 4a8af0ad85a5d1d0a45b9124224d4bc93276c512 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 8 Sep 2022 14:35:16 -0400 Subject: [PATCH] Fix assumptions about ip going into netutil --- confluent_server/confluent/netutil.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/confluent_server/confluent/netutil.py b/confluent_server/confluent/netutil.py index 9bf26bdc..4172eab0 100644 --- a/confluent_server/confluent/netutil.py +++ b/confluent_server/confluent/netutil.py @@ -84,13 +84,11 @@ def ip_on_same_subnet(first, second, prefix): return ip & mask == oip & mask -def ip_is_local(ipaddr): - fam, _, _, _, ainfo = socket.getaddrinfo(ipaddr, 0, proto=socket.IPPROTO_UDP)[0] - ipn = socket.inet_pton(fam, ainfo[0]) - if fam == socket.AF_INET6 and ipn.startswith(b'\xfe\x80'): +def ipn_is_local(ipn): + if len(ipn) > 5 and ipn.startswith(b'\xfe\x80'): return True for addr in get_my_addresses(): - if fam != addr[0]: + if len(addr[1]) != len(ipn): continue if ipn_on_same_subnet(addr[0], ipn, addr[1], addr[2]): return True