Only show tcpdump message when tcpdump is available
- Check for tcpdump availability before printing startup message - Show 'Note: tcpdump not found, skipping concurrent count' when unavailable - Prevents confusing message when tcpdump is not installed Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
1ef363f644
commit
77fb5c69d4
|
|
@ -887,9 +887,23 @@ class PacketCapture:
|
||||||
pcap_file.close()
|
pcap_file.close()
|
||||||
print(f"Capturing to file: {pcap_path}")
|
print(f"Capturing to file: {pcap_path}")
|
||||||
|
|
||||||
# Start tcpdump counter concurrently
|
# Start tcpdump counter concurrently (only if available)
|
||||||
print("Starting concurrent tcpdump counter for data frames...")
|
tcpdump_task = None
|
||||||
tcpdump_task = asyncio.create_task(self._run_tcpdump_counter(interface, duration))
|
try:
|
||||||
|
# Check if tcpdump is available before starting
|
||||||
|
check_proc = await asyncio.create_subprocess_exec(
|
||||||
|
"which", "tcpdump",
|
||||||
|
stdout=asyncio.subprocess.DEVNULL,
|
||||||
|
stderr=asyncio.subprocess.DEVNULL
|
||||||
|
)
|
||||||
|
await check_proc.wait()
|
||||||
|
if check_proc.returncode == 0:
|
||||||
|
print("Starting concurrent tcpdump counter for data frames...")
|
||||||
|
tcpdump_task = asyncio.create_task(self._run_tcpdump_counter(interface, duration))
|
||||||
|
else:
|
||||||
|
print("Note: tcpdump not found, skipping concurrent count")
|
||||||
|
except Exception:
|
||||||
|
print("Note: tcpdump not found, skipping concurrent count")
|
||||||
|
|
||||||
capture_error = None
|
capture_error = None
|
||||||
try:
|
try:
|
||||||
|
|
@ -928,8 +942,10 @@ class PacketCapture:
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
# Get tcpdump count
|
# Get tcpdump count (if task was started)
|
||||||
tcpdump_data_count = await tcpdump_task
|
tcpdump_data_count = None
|
||||||
|
if tcpdump_task is not None:
|
||||||
|
tcpdump_data_count = await tcpdump_task
|
||||||
|
|
||||||
self.analyzer.analyze(packets, duration, tcpdump_data_count)
|
self.analyzer.analyze(packets, duration, tcpdump_data_count)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue