Refactor packet sniffing to run in a loop with a longer timeout for improved performance
This commit is contained in:
parent
2a227d7222
commit
2b328b7368
1 changed files with 8 additions and 9 deletions
17
listener.py
17
listener.py
|
@ -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(
|
|
||||||
iface=INTERFACE,
|
|
||||||
prn=handle_packet,
|
|
||||||
store=False,
|
|
||||||
monitor=True,
|
|
||||||
timeout=1
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while running:
|
while running:
|
||||||
|
sniff(
|
||||||
|
iface=INTERFACE,
|
||||||
|
prn=handle_packet,
|
||||||
|
store=False,
|
||||||
|
monitor=True,
|
||||||
|
timeout=10
|
||||||
|
)
|
||||||
print_stats()
|
print_stats()
|
||||||
time.sleep(10)
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue