feat: dynamic connect/listen, relay promotion, stats counters#103
Merged
feat: dynamic connect/listen, relay promotion, stats counters#103
Conversation
active_connections and active_flows are real-time gauges that return to 0 after sessions close. Every UAT agent reports "stats broken" because they check after traffic completes. Add monotonically increasing total_* counters alongside the existing gauges. Also adds packets_dropped to the REST API and OpenAPI spec — it was already present in proto, CLI, and MCP but missing from REST (interface parity violation). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
MCP/REST/REPL users can now dynamically connect, listen, and disconnect without restarting the daemon. A NodeCommand channel from Handler to the mode task feeds a tokio::select! loop in auto mode. When both --connect and --listen are specified, the node starts as exit and promotes to relay when the listener accepts a second peer — multi-hop topologies form organically without pre-declaring relay mode. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
cross build fails inside its Ubuntu 20.04 container because the nightly toolchain's build scripts need glibc 2.32+. Since musl is installed natively, use cargo directly. Bench init.sh used removed positional subcommands (wallhack daemon entry) instead of the unified --role flag. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
justfile module set working-directory to "website" which resolved to website/website/ when loaded as a module, breaking shell resolution. Content config was in the Astro 5 location (src/content/config.ts) with no loader — Astro 6 requires src/content.config.ts with a glob loader. Pages used removed .slug and .render() APIs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e40ece8 to
2ba53ad
Compare
Replace the dedicated mpsc channel (cmd_tx/cmd_rx) between Handler and mode task with a command queue on SharedNodeState — which is already threaded to both sides. Zero new fields in Handler or NodeResources. Add From<Metrics> for proto StatsResponse and Display for StatsResponse so IPC dispatch and MCP output use traits instead of field-by-field mapping. Add From<proto::StatsResponse> for the REST StatsResponse. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
84dc79f to
c4fffea
Compare
Replace the separate hint watch channel and command queue with a single mpsc channel carrying NodeCommand (Role, Connect, Listen, Disconnect). Eliminates the Mutex<VecDeque> + Notify on SharedNodeState and the watch<Option<RoleHint>> — one channel handles all Handler→mode-task communication. Add From<Metrics> for proto StatsResponse and Display for StatsResponse so IPC dispatch and MCP output use traits instead of field-by-field mapping. Add From<proto::StatsResponse> for the REST StatsResponse. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
c4fffea to
d672e25
Compare
- Add AutoContext struct bundling shared state (global, cfg, metrics, peers, routes, route_updates_tx, node_state, tun_capable); all internal auto-mode functions now take Arc<AutoContext> instead of 8-11 individual arguments - Extract spawn_source_to_peer_bidi_bridge and spawn_peer_announcement_forwarder from relay.rs as pub(crate) non-generic helpers operating on erased types; auto.rs uses these instead of copy-pasted inline blocks - Remove dead route_updates receiver parameter from auto::run; callers obtain fresh receivers via ctx.route_updates_tx.subscribe() - Remove #[allow(clippy::too_many_arguments)] suppressions where fixed Net: -298 lines across three files Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Aligns channel names with the NodeCommand type they carry. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
total_connectionsandtotal_flowssurvive session close — UAT agents no longer report "stats broken". Also fixespackets_droppedmissing from REST API/OpenAPI (interface parity).tokio::select!loops — peers can be added/removed at runtime via MCP/REST/REPL without restarting.--connect+--listenbegin as exit and promote to relay when a second peer connects. Multi-hop topologies form organically.cross→ nativecargofor musl builds (container glibc too old for nightly toolchain); init.sh updated for--roleflag.How to verify
just checkpasses end to end (fmt, lint, build, test, smoke, resilience, website)wallhack statsshowstotal_connections > 0after traffic completeswallhack connect <addr>/wallhack listen <addr>from MCP dynamically adds peers--connect+--listenstarts as exit, promotes to relay on second peer🤖 Generated with Claude Code