2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 19:10:10 +00:00

Reject fe80:: as always not same

For our purposes, this same-subnet check doesn't
apply to link-local
This commit is contained in:
Jarrod Johnson 2022-11-07 13:50:45 -05:00
parent e6e89bcee5
commit 578b05604b

View File

@ -66,6 +66,8 @@ def ip_on_same_subnet(first, second, prefix):
second = second.replace('::ffff:', '')
addrinf = socket.getaddrinfo(first, None, 0, socket.SOCK_STREAM)[0]
fam = addrinf[0]
if '%' in addrinf[-1][0]:
return False
ip = socket.inet_pton(fam, addrinf[-1][0])
ip = int(codecs.encode(bytes(ip), 'hex'), 16)
addrinf = socket.getaddrinfo(second, None, 0, socket.SOCK_STREAM)[0]