2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-09-29 00:31:09 +00:00

Start effort to consolidate snoop open scan

Scan and pass results as snoop answers.  They should
be like snoop answers, but with extra detail that will
be discarded.
This commit is contained in:
Jarrod Johnson
2017-02-09 17:03:05 -05:00
parent 890e23f2d9
commit fa4a759bc1
+12 -2
View File
@@ -356,8 +356,18 @@ def snoop(handler):
:return:
"""
known_peers = set([])
peerbymacaddress = {}
for scanned in scan(_slp_services):
print(repr(scanned))
for addr in scanned['addresses']:
ip = addr[0].partition('%')[0] # discard scope if present
if ip not in neighutil.neightable:
continue
if addr in known_peers:
break
known_peers.add(addr)
else:
handler(scanned)
print(repr(scanned))
net = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
net.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
slpg = socket.inet_pton(socket.AF_INET6, 'ff01::123')
@@ -378,7 +388,7 @@ def snoop(handler):
net4.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
net.bind(('', 427))
net4.bind(('', 427))
peerbymacaddress = {}
while True:
newmacs = set([])
r, _, _ = select.select((net, net4), (), (), 60)