feat: headless mode with a JSONL event stream - #600
Closed
domcyrus wants to merge 1 commit into
Closed
Conversation
- --headless runs the full pipeline without a terminal and streams startup, new_connection, connection_closed, and snapshot events to stdout - --snapshot-interval and --filter (interactive filter syntax) for the stream; --log-level goes to stderr - connection events are serde structs shared by stdout, --json-log, and the PCAP sidecar; stdout writes go through a bounded queue and a writer thread - docs in en, zh-CN, and ja
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Headless front-end (PR 2 of 3, stacked on #598; retarget to main once that merges).
rustnet --headlessruns the full pipeline (capture, DPI, attribution, GeoIP, DNS, sandbox, uid drop) without a terminal and streamsstartup,new_connection,connection_closed, and optionalsnapshotevents as JSON lines to stdout.--log-levelgoes to stderr.--snapshot-interval SECONDSemits the whole connection table periodically;--filter QUERYrestricts the stream using the interactive filter syntax and is validated before any privileged work.src/headless/events.rs, shared by stdout,--json-log, and the PCAP sidecar (same keys and value types as before; key order is now struct order). Stdout writes go through a bounded queue and a dedicated writer thread, so a slow consumer drops events instead of stalling capture; a closed pipe ends the run cleanly.Verified: fmt, clippy,
cargo test --workspace(default and no-default-features), real headless runs on macOS (Seatbelt) and Linux (OrbStack, Landlock ABI 8, eBPF attribution), including--json-logparity,--filter, the EPIPE path, and the new spawn tests intests/headless_cli.rs.Known:
new_connectionfires on the first packet, so attribution and DPI usually land inconnection_closedandsnapshotevents instead (documented). No Windows console control handler yet, so Ctrl+C there exits without draining the queue (documented, follow-up).