def discover(data: ConnectionData) -> None:
assert isinstance(data, ConnectionData)
ip_net, iface = data
try:
ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=ip_net), iface=iface, timeout=2, verbose=False)
for s, r in ans:
line = r.sprintf("%Ether.src% %ARP.psrc%")
try:
hostname = socket.gethostbyaddr(r.psrc)
line += ' ' + hostname[0]
except socket.herror:
pass
print(line)
except PermissionError:
print('Cannot execute necessary code, did you run as root?')
sys.exit(1)
except:
raise
discovery.py 文件源码
python
阅读 32
收藏 0
点赞 0
评论 0
评论列表
文章目录