Refactor packet sniffing to run in a loop with a longer timeout for improved performance

This commit is contained in:
Yaro Kasear 2025-04-30 13:58:09 -05:00
parent 2a227d7222
commit 2b328b7368

View file

@ -67,17 +67,16 @@ if __name__ == "__main__":
print(f"[+] Listening on interface {INTERFACE} (press Ctrl+C to stop)")
# Start sniffing in a background thread
sniff_thread = sniff(
iface=INTERFACE,
prn=handle_packet,
store=False,
monitor=True,
timeout=1
)
try:
while running:
sniff(
iface=INTERFACE,
prn=handle_packet,
store=False,
monitor=True,
timeout=10
)
print_stats()
time.sleep(10)
except KeyboardInterrupt:
pass