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)") print(f"[+] Listening on interface {INTERFACE} (press Ctrl+C to stop)")
# Start sniffing in a background thread # Start sniffing in a background thread
sniff_thread = sniff( try:
while running:
sniff(
iface=INTERFACE, iface=INTERFACE,
prn=handle_packet, prn=handle_packet,
store=False, store=False,
monitor=True, monitor=True,
timeout=1 timeout=10
) )
try:
while running:
print_stats() print_stats()
time.sleep(10)
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass