opticflow 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. opticflow-0.1.0/DECISIONS.md +487 -0
  2. opticflow-0.1.0/LICENSE +21 -0
  3. opticflow-0.1.0/MANIFEST.in +4 -0
  4. opticflow-0.1.0/PKG-INFO +242 -0
  5. opticflow-0.1.0/README.md +210 -0
  6. opticflow-0.1.0/pyproject.toml +59 -0
  7. opticflow-0.1.0/setup.cfg +4 -0
  8. opticflow-0.1.0/src/opticflow/__init__.py +3 -0
  9. opticflow-0.1.0/src/opticflow/__main__.py +6 -0
  10. opticflow-0.1.0/src/opticflow/app.py +470 -0
  11. opticflow-0.1.0/src/opticflow/capture.py +329 -0
  12. opticflow-0.1.0/src/opticflow/cli.py +90 -0
  13. opticflow-0.1.0/src/opticflow/filters.py +85 -0
  14. opticflow-0.1.0/src/opticflow/formatting.py +80 -0
  15. opticflow-0.1.0/src/opticflow/prompt.py +92 -0
  16. opticflow-0.1.0/src/opticflow/snapshot.py +232 -0
  17. opticflow-0.1.0/src/opticflow/sources.py +273 -0
  18. opticflow-0.1.0/src/opticflow/table.py +256 -0
  19. opticflow-0.1.0/src/opticflow/terminal.py +141 -0
  20. opticflow-0.1.0/src/opticflow.egg-info/PKG-INFO +242 -0
  21. opticflow-0.1.0/src/opticflow.egg-info/SOURCES.txt +34 -0
  22. opticflow-0.1.0/src/opticflow.egg-info/dependency_links.txt +1 -0
  23. opticflow-0.1.0/src/opticflow.egg-info/entry_points.txt +2 -0
  24. opticflow-0.1.0/src/opticflow.egg-info/requires.txt +4 -0
  25. opticflow-0.1.0/src/opticflow.egg-info/top_level.txt +1 -0
  26. opticflow-0.1.0/tests/conftest.py +145 -0
  27. opticflow-0.1.0/tests/data/snapshots.jsonl +3 -0
  28. opticflow-0.1.0/tests/fake_dumpcap.py +69 -0
  29. opticflow-0.1.0/tests/test_capture.py +154 -0
  30. opticflow-0.1.0/tests/test_cli.py +193 -0
  31. opticflow-0.1.0/tests/test_filters.py +97 -0
  32. opticflow-0.1.0/tests/test_prompt.py +60 -0
  33. opticflow-0.1.0/tests/test_pty.py +229 -0
  34. opticflow-0.1.0/tests/test_snapshot.py +139 -0
  35. opticflow-0.1.0/tests/test_sources.py +181 -0
  36. opticflow-0.1.0/tests/test_table.py +158 -0
@@ -0,0 +1,487 @@
1
+ # Decisions
2
+
3
+ Each decision, why, and a public source for any fact it relies on.
4
+
5
+ > **Status:** design approved and built 2026-12-03; tried in the VM with a
6
+ > phone on the test router the same day. Repository public from 2026-12-03.
7
+
8
+ ## At a glance
9
+
10
+ ```text
11
+ ┌────────────┐ ┌──────────────┐ ┌───────────────────┐
12
+ engine ──snapshot──▶│ -i device │──▶│ f and a keys │──▶│ screen + NAME.txt │
13
+ (socket/pipe/file) │ (required) │ │ (filters) │ │ (what is shown) │
14
+ └────────────┘ └──────────────┘ └───────────────────┘
15
+
16
+ lima0 ──packets──▶ dumpcap -f "host DEVICE" ──pipe──▶ opticflow ──▶ NAME.pcap
17
+ (only with -log) (whole device)
18
+ ```
19
+
20
+ | Topic | Decision |
21
+ | --- | --- |
22
+ | Name | `opticflow` |
23
+ | Who | one device per run, `-i ADDRESS` required |
24
+ | Screen | one table per snapshot, appended, newest flow first |
25
+ | Filters | `f` any of, `a` max age, both must pass, `c` clears |
26
+ | Capture | `-log NAME`: device-only `NAME.pcap` + `NAME.txt` |
27
+ | Runtime | Python 3.10+, standard library only |
28
+
29
+ ---
30
+
31
+ ## 2026-12-03 · Name: opticflow
32
+
33
+ | Name | PyPI | Result |
34
+ | --- | --- | --- |
35
+ | flowlens, flowview, flowwatch, tailflow, flowvisor | taken | ✗ |
36
+ | **opticflow** | free (also `optic-flow`, `optic_flow`) | ✓ |
37
+
38
+ - Same name for the command, PyPI package and repository `FSayedio/opticflow` (free).
39
+ - Cost: "optic flow" is a vision-science term, so web searches find other things.
40
+ - Source: `https://pypi.org/pypi/<name>/json` (404 = free), GitHub search, 2026-12-03.
41
+
42
+ ## 2026-12-03 · One device, appended tables
43
+
44
+ ```bash
45
+ opticflow -i 192.0.2.10
46
+ ```
47
+
48
+ | ✓ Does | ✗ Does not |
49
+ | --- | --- |
50
+ | show one device's flows | show or capture a whole interface |
51
+ | append a table every snapshot | redraw the screen (no full-screen mode) |
52
+ | filter what is shown | change, block or slow traffic |
53
+ | capture that device's packets | work out anything the engine did not report |
54
+
55
+ - **Why one device:** the point is to watch one device on the test router; a
56
+ whole-interface capture would include the VM and every other device.
57
+ - **Why appended:** history stays in the scrollback, searchable and copyable, as
58
+ in flowreel's `feed`.
59
+
60
+ ## 2026-12-03 · Gateway mode makes a device visible
61
+
62
+ | Interface | Device seen as | `-i` useful? |
63
+ | --- | --- | --- |
64
+ | `lima0` (router side) | its own address, 10.42.0.100–199 by default | ✓ |
65
+ | `eth0` (uplink) | the VM's address, after translation | ✗ |
66
+
67
+ - opticflow does not read flowspool's config or leases, so it cannot check an
68
+ address; it warns instead (see "Matching the device").
69
+ - Source: flowspool README and DECISIONS.md, "Gateway mode".
70
+
71
+ ## 2026-12-03 · Only the snapshot format
72
+
73
+ | Input | Result |
74
+ | --- | --- |
75
+ | `format` ≠ `"flowsnap"` or `version` > 1 | **stop**: `this is format "X" version N; opticflow reads flowsnap version 1` |
76
+ | first line not a JSON object | **stop**: not a snapshot stream |
77
+ | later line: bad JSON, missing or wrong-typed field | skip, one-line warning naming the field |
78
+ | line over 64 MiB (format asks ≥ 16 MiB) | skip, warning, resume after its end |
79
+ | unknown field | ignore |
80
+
81
+ - No code from flowspool or flowreel.
82
+ - `id` is text; order is `start` newest first, then `id` as text.
83
+ - `transport` shown as written, in capitals: `TCP`, `ICMPV6`, `IP:2`.
84
+ - Optional fields used: `stats.dropped`, `stats.untracked` (notes in the header).
85
+ - Source: `SNAPSHOT-FORMAT.md` (draft, 2026-12-03),
86
+ https://github.com/FSayedio/flowspool.
87
+
88
+ ## 2026-12-03 · Sources
89
+
90
+ ```text
91
+ opticflow -i ADDRESS [SOURCE]
92
+ ```
93
+
94
+ | SOURCE | Read as | When it ends |
95
+ | --- | --- | --- |
96
+ | *(none)* | `/run/flowspool/snapshots.sock` | reconnect every 2 s, with a notice |
97
+ | socket path | that socket | reconnect every 2 s, with a notice |
98
+ | `-` | standard input (`flowspool watch \| opticflow -i … -`) | exit 0 |
99
+ | file | from line 1, then follow like `tail -f` | keeps waiting |
100
+ | named pipe | waits for a writer, then reads | exit 0 when the writer closes |
101
+
102
+ - File from the start (not the end, as the format suggests): a file is usually
103
+ a recording or test data.
104
+ - No snapshot for 3 intervals → notice (the format has no keep-alive).
105
+
106
+ ## 2026-12-03 · Matching the device
107
+
108
+ | Case | Behaviour |
109
+ | --- | --- |
110
+ | `-i` missing or not an address | usage message, exit 1 |
111
+ | IPv4 or IPv6 | both; compared as addresses (`2001:DB8::A` = `2001:db8::a`) |
112
+ | first snapshot has no flow for it | "waiting for flows from …" |
113
+ | 3 empty snapshots after flows | warn once: quiet or new address (lease renewal) |
114
+
115
+ - Source: Python `ipaddress`, https://docs.python.org/3/library/ipaddress.html.
116
+
117
+ ## 2026-12-03 · Filters
118
+
119
+ | Key | Asks for | Shows | Empty input |
120
+ | --- | --- | --- | --- |
121
+ | `f` | `google.com, udp, tls` | flows where **any** value appears in **any** column, ignoring case | clears `f` |
122
+ | `a` | `30` (decimals OK) | flows with `age` ≤ 30 s | clears `a` |
123
+ | `c` | — | clears both | — |
124
+
125
+ ```text
126
+ shown = device match AND f (any value) AND a (age ≤ N)
127
+ ```
128
+
129
+ - "Any column" = all columns of the full layout, even ones hidden on a narrow
130
+ terminal, so results never depend on width. Bytes match as shown (`2.8 MB`).
131
+ - Values trimmed, empties dropped; plain text, not patterns.
132
+ - Bad age input → message, filter unchanged.
133
+ - New filter → latest snapshot printed again at once, marked `again, with new filters`.
134
+ - `c` never clears the device.
135
+
136
+ ## 2026-12-03 · Table layout
137
+
138
+ ```text
139
+ ╭─ 14:03:20 · 192.0.2.10 · 5 of 9 flows · 1 new · 2 ended ──────────╮ ← time · device · shown of total · new · ended
140
+ filter: tls, udp · age ≤ 600 s ← only when a filter is set
141
+ 2 packets dropped by the capture: counts too low ← only when stats say so
142
+ ```
143
+
144
+ | Element | Rule |
145
+ | --- | --- |
146
+ | Columns, groups, colours | as flowreel's `feed` |
147
+ | Spacing | one blank line between tables |
148
+ | Time | local `HH:MM:SS`; date on the first table and when it changes |
149
+ | Ended flow | dimmed **and** `×` at row start (`x` without UTF-8) (approved) |
150
+ | Widths | per table; minimums: address 15, port 5, AGE 5, L4 6, bytes 9 |
151
+ | APPLICATION | its longest label, 11–24 |
152
+ | DOMAIN | the rest; long values cut with `~` |
153
+ | Wrapping | never; over-wide lines cut at the edge with `~` (see below) |
154
+
155
+ ### Narrowing: flowreel's columns, never a different layout
156
+
157
+ | Window | Columns | Needs (sample rows) |
158
+ | --- | --- | --- |
159
+ | wide | AGE · CLIENT IP PORT · SERVER IP PORT · L4 APP · UP DOWN TOTAL · DOMAIN | ~133 |
160
+ | narrower | ~~TOTAL~~ | ~123 |
161
+ | narrower still | ~~TOTAL~~ ~~L4~~ | ~116 |
162
+ | below that | same, lines cut at the edge with `~` + hint (once): `widen the window to 133 columns to see every column` | any |
163
+
164
+ - Why: flowreel never fits every column in 80 either. Its `feed` only squeezes
165
+ APPLICATION and DOMAIN and lets the terminal wrap; its `replay` hides TOTAL,
166
+ DOMAIN and L4. A wider window is the answer, as in flowreel. Hiding TOTAL then
167
+ L4 follows the replay; cutting instead of wrapping keeps rows one line each.
168
+ - Approved 2026-12-03, in place of a narrow "device layout" that dropped the
169
+ device's address and showed only the other side.
170
+ - `NAME.txt` always has every column.
171
+ - Source: flowreel `src/flowreel/feed.py` (`FeedTable`) and `src/flowreel/tui.py`
172
+ (`_columns`).
173
+
174
+ **80 columns (TOTAL and L4 hidden, cut):**
175
+
176
+ ```text
177
+ ╭─ 14:03:20 · 192.0.2.10 · 5 of 9 flows · 1 new · 2 ended ────────────────────╮
178
+ filter: tls, udp · age ≤ 600 s
179
+ widen the window to 133 columns to see every column
180
+ AGE │ CLIENT IP PORT │ SERVER IP PORT │ APPLICATION │ ~
181
+ ──────┼───────────────────────┼───────────────────────┼────────────────────┼──~
182
+ × 2 │ 192.0.2.10 51000 │ 192.0.2.1 53 │ DNS │ ~
183
+ 4 │ 192.0.2.10 50444 │ 198.51.100.20 443 │ QUIC.YouTube │ ~
184
+ 37 │ 192.0.2.10 51001 │ 203.0.113.5 443 │ TLS.GoogleServices │ ~
185
+ × 61 │ 203.0.113.9 52100 │ 192.0.2.10 8009 │ │ ~
186
+ 312 │ 192.0.2.10 │ 198.51.100.7 │ ICMP │ ~
187
+ ```
188
+
189
+ **120 columns (TOTAL hidden):**
190
+
191
+ ```text
192
+ ╭─ 14:03:20 · 192.0.2.10 · 5 of 9 flows · 1 new · 2 ended ─────────────────────────────────────────────────────────────╮
193
+ filter: tls, udp · age ≤ 600 s
194
+ AGE │ CLIENT IP PORT │ SERVER IP PORT │ L4 APPLICATION │ UP DOWN │ DOMAIN
195
+ ──────┼───────────────────────┼───────────────────────┼────────────────────────┼─────────────────────┼─────────────────
196
+ × 2 │ 192.0.2.10 51000 │ 192.0.2.1 53 │ UDP DNS │ 80 B 200 B │ video.example
197
+ 4 │ 192.0.2.10 50444 │ 198.51.100.20 443 │ UDP QUIC.YouTube │ 40.0 KB 2.8 MB │ rr4.video.examp~
198
+ 37 │ 192.0.2.10 51001 │ 203.0.113.5 443 │ TCP TLS.GoogleServ~ │ 2.9 KB 39.1 KB │ accounts.mail.e~
199
+ × 61 │ 203.0.113.9 52100 │ 192.0.2.10 8009 │ TCP │ 900 B 1.2 KB │
200
+ 312 │ 192.0.2.10 │ 198.51.100.7 │ ICMP ICMP │ 84 B 84 B │
201
+ ```
202
+
203
+ **Full width (150 columns):**
204
+
205
+ ```text
206
+ AGE │ CLIENT IP PORT │ SERVER IP PORT │ L4 APPLICATION │ UP DOWN TOTAL │ DOMAIN
207
+ ──────┼───────────────────────┼───────────────────────┼───────────────────────────┼───────────────────────────────┼─────────────────────
208
+ 4 │ 192.0.2.10 50444 │ 198.51.100.20 443 │ UDP QUIC.YouTube │ 40.0 KB 2.8 MB 2.8 MB │ rr4.video.example
209
+ 37 │ 192.0.2.10 51001 │ 203.0.113.5 443 │ TCP TLS.GoogleServices │ 2.9 KB 39.1 KB 42.0 KB │ accounts.mail.example
210
+ ```
211
+
212
+ ### Colour and plain text
213
+
214
+ | Output | Colour | Layout | Keys |
215
+ | --- | --- | --- | --- |
216
+ | terminal | yes, unless `NO_COLOR` set | fits the width | yes |
217
+ | terminal, `--color never` | no | fits the width | yes |
218
+ | pipe or file | no (`--color always` forces it) | full, no width limit | no |
219
+ | non-UTF-8 | — | ASCII `\| - + x` | — |
220
+
221
+ - Colours (flowreel's): dim rules · blue header · bold titles · green app ·
222
+ yellow bytes · red notes · dim ended rows.
223
+ - Source: https://no-color.org/.
224
+
225
+ ## 2026-12-03 · Keys and prompt, no full-screen library
226
+
227
+ | Key | Action |
228
+ | --- | --- |
229
+ | `f` | filter prompt |
230
+ | `a` | age prompt |
231
+ | `c` | clear both filters |
232
+ | `?` | help |
233
+ | `q` / Ctrl-C | quit |
234
+
235
+ **In a prompt:** starts with the current value · type · Backspace · Ctrl-U clears · Enter applies · Esc cancels ·
236
+ arrow keys ignored · UTF-8 decoded · long input shows its end only.
237
+
238
+ **A table arrives while typing:**
239
+
240
+ ```text
241
+ before after
242
+ ─────────────────────── ──────────────────────────────
243
+ …previous table… …previous table…
244
+ filter: tls, ud_ ╭─ 14:03:30 · … (new table) ─╮
245
+ …rows…
246
+ filter: tls, ud_ ← redrawn, nothing lost
247
+ ```
248
+
249
+ (erase line: `\r` + `ESC [ 2 K`, print table, redraw prompt)
250
+
251
+ | Concern | Decision |
252
+ | --- | --- |
253
+ | where keys come from | stdin if it is a terminal, else `/dev/tty`; none → say so once |
254
+ | key mode | cbreak (`tty.setcbreak`): no echo, one key at a time, Ctrl-C still works (`ISIG` kept) |
255
+ | waiting | `select.select()` on source + terminal |
256
+ | restoring | on every exit (q, Ctrl-C, SIGTERM, SIGHUP, errors); Ctrl-Z restores, resume re-applies |
257
+ | status lines | "waiting…", "reconnecting…" use the same erase/redraw; never logged |
258
+ | width change | from the next table |
259
+
260
+ **Why `select()` — measured on macOS 27.0.1, Python 3.13:**
261
+
262
+ | Call on `/dev/tty` | macOS | Linux |
263
+ | --- | --- | --- |
264
+ | kqueue (Python's default selector) | ✗ `Invalid argument` | n/a |
265
+ | `poll()` | ✗ `POLLNVAL` | ✓ |
266
+ | `select()` | ✓ | ✓ |
267
+
268
+ - The format's "`select()` or `poll()`" advice is half right on macOS; flowspool's
269
+ document is not changed by this project.
270
+ - Sources: Python `tty`, `select`; termios(3) `ISIG`; macOS poll(2) BUGS ("does
271
+ not support devices"); ECMA-48 Erase in Line.
272
+ https://docs.python.org/3/library/tty.html ·
273
+ https://docs.python.org/3/library/select.html ·
274
+ https://man7.org/linux/man-pages/man3/termios.3.html ·
275
+ https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/poll.2.html ·
276
+ https://ecma-international.org/publications-and-standards/standards/ecma-48/
277
+
278
+ ## 2026-12-03 · `-log NAME`
279
+
280
+ | File | Holds | Follows filters? |
281
+ | --- | --- | --- |
282
+ | `NAME.txt` | every printed line, no colour codes, tables at full width (approved 2026-12-03) | ✓ |
283
+ | `NAME.pcap` | every packet to or from the device, nothing else | ✗ |
284
+
285
+ ```text
286
+ dumpcap -q -i IFACE -f "host ADDRESS" -F pcap -w -
287
+ ```
288
+
289
+ ### Lifecycle
290
+
291
+ ```text
292
+ check names free ─▶ first snapshot ─▶ check IFACE ─▶ create files ─▶ start dumpcap
293
+ O_EXCL, 0600 │
294
+ ┌──────────── 24-byte header within 3 s, still running? ┘
295
+ ├─ yes ─▶ print tables … ─▶ exit: SIGTERM ─(5 s)─▶ SIGKILL
296
+ │ drain pipe, sync, summary
297
+ └─ no ──▶ show dumpcap's error, delete empty files, exit 1
298
+ ```
299
+
300
+ ### Why each choice — measured in the VM (Debian 13, dumpcap 4.4.19)
301
+
302
+ | Choice | Because |
303
+ | --- | --- |
304
+ | dumpcap | `wireshark` group, `cap_net_admin,cap_net_raw=eip`, mode 0754 → never root |
305
+ | opticflow creates the file | dumpcap silently overwrites existing files |
306
+ | `-w -` through a pipe | if opticflow is killed, dumpcap dies by SIGPIPE at its next write |
307
+ | not the parent-death signal | Linux clears it for programs with file capabilities |
308
+ | header = started | `Capturing on 'nosuch0'` is printed even for a missing interface; a good start writes 24 bytes at once, a bad one writes nothing and exits 1 |
309
+ | own session | Ctrl-C reaches opticflow only; it stops dumpcap in order |
310
+ | SIGTERM | SIGTERM and SIGINT both close the file properly, exit 0 |
311
+
312
+ ### Interface checks
313
+
314
+ | IFACE | Accepted? |
315
+ | --- | --- |
316
+ | `source.interface` or `--interface` | required, one of them |
317
+ | letters, digits, `. _ - :`, exists (`socket.if_nameindex()`) | ✓ |
318
+ | `-` (stdin), all digits (index), `rpcap://…`, `TCP@host:port` | ✗ dumpcap gives these special meanings |
319
+
320
+ ### Not in the capture (README says so)
321
+
322
+ - the first table's traffic (capture starts after it)
323
+ - the device's first address request (no address yet)
324
+ - IPv6 from another address of the device, e.g. link-local
325
+ - traffic between two devices on the router
326
+ - on a quiet interface, the SIGPIPE stop waits for the next device packet
327
+
328
+ ### Errors while running
329
+
330
+ | Problem | Behaviour |
331
+ | --- | --- |
332
+ | dumpcap missing / not allowed | message: run flowspool `setup.sh --capture-user`, log in again |
333
+ | dumpcap exits early, disk full | red notice, tables and text log go on, exit 1 at the end |
334
+
335
+ - Sources: dumpcap(1) (`-w`: "Use "-" for stdout"),
336
+ https://www.wireshark.org/docs/man-pages/dumpcap.html ·
337
+ pcap-filter(7) `host`, https://www.tcpdump.org/manpages/pcap-filter.7.html ·
338
+ prctl(2) `PR_SET_PDEATHSIG`, https://man7.org/linux/man-pages/man2/prctl.2.html ·
339
+ pipe(7), https://man7.org/linux/man-pages/man7/pipe.7.html ·
340
+ open(2) `O_EXCL`, https://man7.org/linux/man-pages/man2/open.2.html ·
341
+ flowspool DECISIONS.md, "Viewers capture with dumpcap".
342
+
343
+ ## 2026-12-03 · Start, messages, exit status
344
+
345
+ ```text
346
+ 1 args ok? ─▶ 2 first snapshot ─▶ 3 capture ok? (with -log) ─▶ 4 start line ─▶ tables
347
+ ✗ exit 1 ("waiting…") ✗ exit 1, nothing printed
348
+ ```
349
+
350
+ - Start line: version · device · source · engine + labeler · byte unit ·
351
+ (log files, interface, filter). Printed again if `source` changes.
352
+
353
+ | Exit | Status |
354
+ | --- | --- |
355
+ | `q`, end of stdin or pipe | 0 |
356
+ | Ctrl-C | 130 (as flowreel; approved) |
357
+ | SIGTERM, SIGHUP | 143, 129 (128 + signal; the capture is still stopped cleanly) |
358
+ | error, or the capture failed while running | 1 (stderr, and the text log) |
359
+
360
+ ## 2026-12-03 · Standard library, Python 3.10+
361
+
362
+ | Item | Choice |
363
+ | --- | --- |
364
+ | Runtime deps | none |
365
+ | Dev | pytest, ruff |
366
+ | Packaging, ruff rules, CI matrix | as flowreel (Linux + macOS × Python 3.10, 3.13) |
367
+ | VM install | venv or `pipx`, not system `pip` (Debian's Python is externally managed) |
368
+
369
+ - Source: PEP 668, https://peps.python.org/pep-0668/.
370
+
371
+ ## 2026-12-03 · Parts
372
+
373
+ | Module | Does | Needs |
374
+ | --- | --- | --- |
375
+ | `snapshot.py` | parse and check a line | nothing |
376
+ | `formatting.py` | column text (bytes, age, time) | nothing |
377
+ | `filters.py` | device, `f`, `a` | nothing |
378
+ | `table.py` | text at a width, colour/ASCII | nothing |
379
+ | `prompt.py` | line editor: bytes → events | nothing |
380
+ | `sources.py` | socket, stdin, file; reconnect | sockets, files |
381
+ | `capture.py` | `NAME.txt`/`NAME.pcap` files; dumpcap start/check/stop, pipe copy | a child process |
382
+ | `terminal.py` | cbreak, `/dev/tty`, signals, redraw | a terminal |
383
+ | `app.py`, `cli.py` | `select()` loop, options | all |
384
+
385
+ - Why: logic and layout tested headless; one test drives the real program, as in flowreel.
386
+
387
+ ## 2026-12-03 · Testing without an engine or VM
388
+
389
+ | Area | How |
390
+ | --- | --- |
391
+ | Test data | hand-written lines, RFC 5737 / RFC 3849 addresses, `.example` names; device `192.0.2.10` |
392
+ | Format | each required field missing, wrong types, unknown fields, format/version, bad first line, bad middle line, over-long line |
393
+ | Filters | IPv4/IPv6 match either side, `f` any-of/case/commas/hidden columns, `a` decimals/refusals, combined, `c` |
394
+ | Layout | exact text at 80, 116, 123, 133 and no width; cut lines + widen hint; colour on/off; ASCII; ended; IPv6; empty; notes |
395
+ | Prompt | typing, Backspace, Ctrl-U, Esc, Enter, arrow sequences, split UTF-8 |
396
+ | Sources | fake engine on a temp UNIX socket (latest on connect, close, return); stdin EOF; growing file |
397
+ | Capture | fake `dumpcap` (`tests/fake_dumpcap.py`, chosen with the `OPTICFLOW_DUMPCAP` variable): good start, missing interface, no header, early exit, ignores SIGTERM; checks args, no overwrite, cleanup, bad names, no leftover process |
398
+ | Real program | `pty.fork()`, snapshots on stdin, keys from the pty (below) |
399
+ | CI | `ruff check`, `ruff format --check`, pytest — Linux + macOS × 3.10, 3.13 |
400
+
401
+ **Pseudo-terminal test:**
402
+
403
+ ```text
404
+ type f "udp" ⏎ → table again, UDP only, filter line shown
405
+ a "30" ⏎ → only flows ≤ 30 s
406
+ c → all flows
407
+ q → exit 0
408
+ again with -log + fake dumpcap:
409
+ NAME.txt has no escape codes · NAME.pcap starts with the header · Ctrl-C stops the capture
410
+ ```
411
+
412
+ **By hand in the VM:**
413
+
414
+ | Date | Check | Result |
415
+ | --- | --- | --- |
416
+ | 2026-12-03 | live socket, real dumpcap on `lima0`, an unused documentation address | starts and stops cleanly; the pcap holds only its 24-byte header; existing files refused |
417
+ | 2026-12-03 | the owner's phone on the test router, keys and `-log` | reported working ("it works clean"); the phone's address and traffic stay out of the repository |
418
+
419
+ **Found while drawing the screenshots:** without `-log`, the "waiting for the
420
+ first snapshot" line was drawn again below every table (with `-log` the capture
421
+ start cleared it). Fixed; a pseudo-terminal test checks the line appears once.
422
+
423
+ - Sources: RFC 5737 https://www.rfc-editor.org/rfc/rfc5737 ·
424
+ RFC 3849 https://www.rfc-editor.org/rfc/rfc3849 ·
425
+ RFC 2606 https://www.rfc-editor.org/rfc/rfc2606
426
+
427
+ ## 2026-12-03 · No real traffic in the repository
428
+
429
+ | Ignored by git from the first commit | Tracked |
430
+ | --- | --- |
431
+ | `*.pcap`, `*.pcapng`, `*.txt` logs, snapshot recordings | hand-written test lines only |
432
+
433
+ - Why: traffic contains personal data. Source: RFC 5737, RFC 3849, RFC 2606.
434
+
435
+ ## 2026-12-03 · Animated screenshots from public samples
436
+
437
+ ```text
438
+ nDPI 6.0 sample pcaps ──sha256──▶ merged timeline ──flowspool-probe -r──▶ flowsnap lines
439
+ (downloaded to a temp folder, (as flowspool's (192.168.1.7 → 10.42.0.123,
440
+ never stored here) screenshots) 192.168.1.1 → 10.42.0.1)
441
+ │
442
+ docs/screenshots/*.svg ◀──recorded output◀── real opticflow in a pty
443
+ ```
444
+
445
+ | Choice | Why |
446
+ | --- | --- |
447
+ | nDPI's public sample captures, not the owner's phone | no real traffic in git (rule above); the phone's run would publish its addresses and the domains it visited |
448
+ | the netflix.pcap host as the device | 3 → 14 → 26 → 44 flows over four snapshots, with ended flows, DNS and several applications: fits a window |
449
+ | addresses moved into flowspool's lab range | the pictures match the README's setup; only those two addresses change |
450
+ | the real program in a pseudo-terminal, output recorded | the pictures show what opticflow really prints, colours included; only the window and `$` line are drawn |
451
+ | animated SVG (CSS keyframes), flowreel's colours and fonts | sharp at any size, small, renders on GitHub, same look as the sibling projects |
452
+ | `scripts/make_screenshots.py`, run in the VM | needs flowspool's probe; anyone can redraw them |
453
+
454
+ - Sources: nDPI sample captures https://github.com/ntop/nDPI/tree/6.0/tests/cfgs/default/pcap ·
455
+ flowspool's screenshot script https://github.com/FSayedio/flowspool/blob/main/scripts/make_screenshots.py
456
+
457
+ ## 2026-12-03 · Which engines: the claim in the README
458
+
459
+ | Claim | True? |
460
+ | --- | --- |
461
+ | works with any engine that writes flowsnap v1, nDPI-based or not | ✓ opticflow reads only the format, checks its name and version, ignores unknown fields |
462
+ | works with any nDPI-based tool | ✗ ntopng, nDPId and ndpiReader each write their own output, not flowsnap; they need a converter |
463
+ | works with flowspool | ✓ tested in the VM |
464
+
465
+ - Wording: the README says "any engine that writes the flowsnap format" and
466
+ names the nDPI-based tools it does not read directly, so no one expects more
467
+ than it does.
468
+ - Sources: SNAPSHOT-FORMAT.md https://github.com/FSayedio/flowspool/blob/main/SNAPSHOT-FORMAT.md ·
469
+ nDPId https://github.com/utoni/nDPId · ntopng https://github.com/ntop/ntopng ·
470
+ ndpiReader https://github.com/ntop/nDPI/tree/dev/example
471
+
472
+ ## 2026-12-03 · Releases on PyPI, as flowreel
473
+
474
+ ```text
475
+ git tag v0.1.0 ─push─▶ release.yml: tag = __version__? ─▶ README links pinned to the tag
476
+ ─▶ build + twine check --strict ─▶ tests on the built wheel
477
+ ─▶ PyPI trusted publishing (environment "pypi")
478
+ ```
479
+
480
+ | Choice | Why |
481
+ | --- | --- |
482
+ | trusted publishing, no API token | GitHub gives the job a short-lived identity for one upload; nothing secret is stored |
483
+ | tag must equal `__version__` | a tag can't publish a different version by mistake |
484
+ | README links absolute, pinned to the tag in the packaged copy | relative links break on PyPI; each release's page keeps its own pictures |
485
+ | tests run on the built wheel | proves the package works as installed, not only from the checkout |
486
+
487
+ - Source: PyPI trusted publishers https://docs.pypi.org/trusted-publishers/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Farhan Sayed
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ # Extra files for the source distribution (sdist), so it can be tested.
2
+ include DECISIONS.md
3
+ graft tests
4
+ global-exclude __pycache__ *.py[cod] *.pcap *.pcapng *.cap