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