Pep8
This commit is contained in:
parent
06a5a758a3
commit
58fa7d1ee6
19 changed files with 567 additions and 377 deletions
|
|
@ -10,15 +10,14 @@ class NetworkScanner:
|
|||
def __init__(self, interface=None):
|
||||
"""Инициализация параметров интерфейсов"""
|
||||
self.interface = (
|
||||
interface or netifaces.gateways()["default"][netifaces.AF_INET][1]
|
||||
)
|
||||
self.ip_info = netifaces.ifaddresses(self.interface).get(netifaces.AF_INET, [])
|
||||
interface or netifaces.gateways()["default"][netifaces.AF_INET][1])
|
||||
self.ip_info = netifaces.ifaddresses(self.interface).get(
|
||||
netifaces.AF_INET, [])
|
||||
self.networks = [
|
||||
IPNetwork(f"{ip['addr']}/{ip['netmask']}") for ip in self.ip_info
|
||||
]
|
||||
self.local_mac = netifaces.ifaddresses(self.interface)[netifaces.AF_LINK][0][
|
||||
"addr"
|
||||
]
|
||||
self.local_mac = netifaces.ifaddresses(
|
||||
self.interface)[netifaces.AF_LINK][0]["addr"]
|
||||
|
||||
def _create_arp_packet(self, target_ip):
|
||||
"""Создание пакета ARP для отправки"""
|
||||
|
|
@ -36,9 +35,10 @@ class NetworkScanner:
|
|||
clients = []
|
||||
|
||||
for _ in range(attempts):
|
||||
result = srp(packet, timeout=timeout, iface=self.interface, verbose=0)[
|
||||
0
|
||||
]
|
||||
result = srp(packet,
|
||||
timeout=timeout,
|
||||
iface=self.interface,
|
||||
verbose=0)[0]
|
||||
for _, received in result:
|
||||
client = {"ip": received.psrc, "mac": received.hwsrc}
|
||||
if client not in clients: # Избегаем дублирования клиентов
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue