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()
|
||||
print(f"Capturing to file: {pcap_path}")
|
||||
|
||||
# Start tcpdump counter concurrently
|
||||
print("Starting concurrent tcpdump counter for data frames...")
|
||||
tcpdump_task = asyncio.create_task(self._run_tcpdump_counter(interface, duration))
|
||||
# Start tcpdump counter concurrently (only if available)
|
||||
tcpdump_task = None
|
||||
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
|
||||
try:
|
||||
|
|
@ -928,8 +942,10 @@ class PacketCapture:
|
|||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
# Get tcpdump count
|
||||
tcpdump_data_count = await tcpdump_task
|
||||
# Get tcpdump count (if task was started)
|
||||
tcpdump_data_count = None
|
||||
if tcpdump_task is not None:
|
||||
tcpdump_data_count = await tcpdump_task
|
||||
|
||||
self.analyzer.analyze(packets, duration, tcpdump_data_count)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue