mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-25 19:10:10 +00:00
Fix assumptions about ip going into netutil
This commit is contained in:
parent
7b98b7dc00
commit
4a8af0ad85
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user