Commit Graph
12 Commits
Author SHA1 Message Date
catarrh 5d91450b55 Track device connection and capture gaps; surface sniff error flags 2026-08-19 18:00:52 +03:00
catarrh 97a7e6034a Show status in trace empty-state; discard empty captures; polish capture-mode
Frontend:
- trace empty-state now shows connection status + capture mode (boxed,
  colored) in the center, updated live via checkConnection
- capture-mode uses amber warning style (gsmtap/disabled), green for direct
- stopCapture clears currentSessionId

Server:
- gsmtap read_packet catches OSError on socket close (no more EBADF
  traceback on stop)
- stop_session joins the loop and discards a session with zero messages;
  /api/capture/stop reports discarded
- startup prints server version

Tests: 122 (gsmtap close, empty/non-empty capture lifecycle).
2026-08-15 08:48:07 +03:00
catarrh c21b655fe1 Fix pcapng timestamp resolution + imported-session duration
- pcap.py: _parse_tsresol now pads options to a 32-bit boundary
  ((-length) % 4) and uses 2** for the MSB-set (power-of-2) case, so
  nanosecond if_tsresol is read correctly (was defaulting to µs and
  scaling timestamps 1000x)
- database/server: set imported session started/ended from the first/last
  packet timestamps (falling back to wall-clock for synthetic SPB)
- frontend: formatDuration renders hours
- tests: tsresol (ns after padded option, default µs, ns round-trip) and
  session-window/fallback (119 total)
2026-08-15 02:02:44 +03:00
catarrh 9362bef869 Add server-source selector (same-origin default) and drop SIMTRACE_EMBEDDED
- Settings: 'Server' selector — 'Same origin' (default) vs 'Custom URL'
  (URL input revealed only in custom mode, placeholder 127.0.0.1:8081)
- serverUrl defaults to '' (same-origin); persisted per choice
- remove SIMTRACE_EMBEDDED frontend check and the server's _EMBEDDED_MARKER
  index.html injection (no longer needed)
- i18n: Server / Same origin / Custom URL (EN/RU)
2026-08-15 00:24:58 +03:00
catarrh 24d0decd51 Add --capture disabled mode + capture-mode status in PWA
Server:
- --capture accepts 'disabled'; no backend is created, capture_mode exposed
- /api/status returns capture_mode; capture start/stop return 403 when
  disabled; latest/status/delete_session are None-safe

PWA:
- captureMode state; conn-status shows server version
- new capture-mode line (Settings) explaining gsmtap/direct/disabled
- hide capture + New capture UI when disabled; trace empty-state shows
  'Capture unavailable'
- 7 new EN/RU i18n keys

Version 1.2.0 (server + PWA); tests: 111.
2026-08-14 23:49:10 +03:00
catarrh b900a8a3e1 Merge simtrace-analyser PWA into frontend/ (monorepo); serve it same-origin
- frontend/: simtrace-analyser PWA (index.html, sw.js, manifest.json,
  icons, tests/index.test.html) copied in fresh
- server.py: static file serving (_STATIC_MIME, _serve_static) with
  path-traversal guard; injects window.SIMTRACE_EMBEDDED='1' into
  index.html so the PWA defaults to a relative API base
- server __main__: --web-dir (default <repo>/frontend)
- frontend: embedded same-origin mode; sw.js relative precache paths +
  cache v4; GitHub link + version-warn point at simtrace2-pysniff
- version 1.1.0 everywhere (__version__, pyproject, PWA_VERSION,
  manifest); MIN_SERVER_VERSION stays 1.0.0
- README/scripts/.gitignore updated

Tests: 107.
2026-08-14 16:26:28 +03:00
catarrh 8b7b10b8fa Version 1.0.0; expose version in /api/status
First published version. __version__ and pyproject bumped to 1.0.0,
/api/status now returns 'version' so the PWA can check compatibility.

Tests: 107 (status includes version, package version).
2026-08-14 10:24:24 +03:00
catarrh 73f40ad570 server: send Access-Control-Allow-Private-Network on CORS responses
Lets a public-hosted PWA reach a local simtrace2-pysniff-server
(http://127.0.0.1:8081); without it the browser blocks the preflight
before any request is sent.
2026-08-14 00:45:52 +03:00
catarrh dd34c25899 Add PCAP/PCAPNG import via POST /api/sessions/import
- pcap.py: parse_pcap (micro/nano, both byte orders) and parse_pcapng
  (SHB byte-order, IDB linktype + if_tsresol, EPB/SPB) readers that
  unwrap Ethernet/RAW/IPv4/NULL/SLL/SLL2 to UDP and extract GSMTAP-SIM
  packets (APDU->tpdu, ATR->atr, PPS->pps), with a heuristic fallback
- database: insert_messages bulk-insert helper
- server: import endpoint reads raw body, auto-detects format, skips
  non-GSMTAP packets; 400 'No GSMTAP data found in trace' (no session)
  when empty, else creates a 'pcap' session named after the file

Tests: 102 (pcap round-trip, pcapng, no-GSMTAP, endpoint 200/400).
2026-08-13 10:15:22 +03:00
catarrh e09aac4cb7 Add session export to PCAP
pcap.py: build_pcap(packets) — build PCAP bytes in memory (same format
as PcapWriter)
database.py: get_messages_raw() — raw elapsed/type/data without decode
server.py: GET /api/sessions/<id>/pcap generates a GSMTAP-encapsulated
PCAP (ATR/TPDU) with real timestamps and downloads it as
<session-name>.pcap (ASCII filename fallback + RFC 5987 UTF-8 for
spaces/unicode via _content_disposition)

tests: build_pcap + _content_disposition (67 total)
2026-08-12 21:16:11 +03:00
catarrh a1bbd0cf0f Add session stats and VACUUM on deletion
database.py: count_sessions(), db_size() (db+WAL+SHM), vacuum()
(VACUUM + wal_checkpoint(TRUNCATE) to actually reclaim space in WAL mode)

server.py: /api/sessions now returns total_sessions + db_size;
DELETE /api/sessions/<id> runs vacuum() after deletion
2026-08-12 21:05:54 +03:00
catarrh 17eeda27f3 Merge simtrace-analyser-server into simtrace2_pysniff.server
Add simtrace2-pysniff-server CLI — HTTP API for simtrace-analyser PWA.
Two capture modes: GSMTAP UDP listener (compatible with simtrace2-sniff)
or direct SIMtrace2 hardware capture. SQLite storage with sessions +
messages tables. REST API with CORS.

server/ sub-package: database.py, capture.py, server.py, __main__.py

README updated with server usage section.
pyproject.toml: simtrace2-pysniff-server script entry added.
2026-08-12 15:59:51 +03:00