Skip to content

Commit d8d73f6

Browse files
committed
Use KiloBytes for Host View and Improve PCAP filename save
1 parent 6d2c8df commit d8d73f6

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/libinspector/device_detail_page.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,6 @@ def process_network_flows(df: pandas.DataFrame):
430430
local_timezone = datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo
431431
df['first_seen'] = df['first_seen'].dt.tz_localize('UTC').dt.tz_convert(local_timezone)
432432
df['last_seen'] = df['last_seen'].dt.tz_localize('UTC').dt.tz_convert(local_timezone)
433-
434-
df['inferred_activity'] = None
435-
df['confirmation'] = False
436433
df = df.reset_index(drop=True)
437434

438435
st.markdown("#### Network Flows")
@@ -477,7 +474,7 @@ def show_device_details(mac_address: str):
477474
SELECT MIN(timestamp) AS first_seen,
478475
MAX(timestamp) AS last_seen,
479476
COALESCE(dest_hostname, dest_ip_address) AS dest_info,
480-
SUM(byte_count) * 8 AS Bits
477+
ROUND(SUM(byte_count) / 1024.0, 2) AS KiloBytes
481478
FROM network_flows
482479
WHERE src_mac_address = ?
483480
AND timestamp >= ?
@@ -490,7 +487,7 @@ def show_device_details(mac_address: str):
490487
SELECT MIN(timestamp) AS first_seen,
491488
MAX(timestamp) AS last_seen,
492489
COALESCE(src_hostname, src_ip_address) AS src_info,
493-
SUM(byte_count) * 8 AS Bits
490+
ROUND(SUM(byte_count) / 1024.0, 2) AS KiloBytes
494491
FROM network_flows
495492
WHERE dest_mac_address = ?
496493
AND timestamp >= ?

src/libinspector/server/packet_collector.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,17 @@ def make_pcap_filename(start_time: int, end_time: int) -> str:
185185
Returns:
186186
str: Human-readable filename.
187187
"""
188-
start_dt = datetime.datetime.fromtimestamp(start_time)
189-
duration_seconds = end_time - start_time
188+
# Determine the local timezone object of the machine running the script.
189+
local_tz = datetime.datetime.now().astimezone().tzinfo
190190

191-
# Format the start time: e.g., 'Oct-31-2025_113100AM'
192-
safe_start = start_dt.strftime("%b-%d-%Y_%I:%M:%S%p")
191+
# We explicitly tell fromtimestamp() that the input is UTC.
192+
start_dt_utc = datetime.datetime.fromtimestamp(start_time, tz=datetime.timezone.utc)
193+
start_dt_localized = start_dt_utc.astimezone(local_tz)
194+
duration_seconds = end_time - start_time
195+
safe_start = start_dt_localized.strftime("%b-%d-%Y_%I:%M:%S%p")
193196

194197
# Generate the filename with duration
195-
filename = f"{safe_start}_{duration_seconds}s.pcap"
198+
filename = f"{safe_start}_{duration_seconds:.2f}s.pcap"
196199
return filename
197200

198201

0 commit comments

Comments
 (0)