feat(daemon): configurable port and listen address (#79)#85
Draft
Nic-dorman wants to merge 1 commit into
Draft
Conversation
Add --port and --listen-addr flags to `ant node daemon start` and the hidden `daemon run` so the node-management HTTP API can be pinned to a predictable bind. Default behaviour is unchanged (loopback, OS-assigned). Flags are forwarded from the detached `start` path through to the spawned `run` child via a new `daemon_run_args` helper. Use case: running the daemon inside a container with a `-p` mapping. Example: `ant node daemon start --listen-addr 0.0.0.0 --port 8765`. The daemon has no authentication, so the README and clap help text flag the security implications of binding to a non-loopback address. Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Closes #79.
Summary
ant node daemon startand the hiddendaemon rungain--port <PORT>and--listen-addr <IP>flags.127.0.0.1) + OS-assigned port.--port 0is accepted as an explicit OS-assigned request.startpath to the spawnedrunchild via a newdaemon_run_argshelper inant-core::node::daemon::client.Use case
The issue reporter is running the daemon in a Docker container and needs a predictable port for
docker run -p. With this change:Security note (in the README and clap help)
The daemon has no authentication. Binding to a non-loopback address exposes node-management — start, stop, reset, registry mutation — to anyone who can reach the port. The README and
--listen-addrhelp text both call this out; users opt in deliberately by setting the flag.Tests
ant-core/src/node/daemon/client.rs::testscovering the args-builder (default, explicit port, explicit listen addr, both, explicit0).server_binds_to_pinned_portinant-core/tests/daemon_integration.rs: probes a free loopback port, asks the server to pin it, and asserts both the boundSocketAddrand thedaemon.portfile agree.cargo fmt,cargo clippy --all-targets --all-features -- -D warnings, and the daemon test slices all pass on Windows.cargo test --allhas one pre-existing failure (save_snapshot_to_unwritable_dir_does_not_panicinadaptive.rs) that also fails onmainand is unrelated to this change.E2E skill update
.claude/skills/e2e-node-management-test/SKILL.mdgains Step 5.4 "Pinned-port flag round-trip" which stops the daemon, restarts it with--port 18765, verifiesdaemon statusreports exactly that port, then restores the OS-assigned default for the remaining phases.Test plan
e2e-node-management-testskill against a real testnet on Linux/macOS to confirm the new Step 5.4 passes outside of Windows.docker run -p 8765:8765 ... ant node daemon start --listen-addr 0.0.0.0 --port 8765and confirmcurl host:8765/api/v1/statusworks from outside the container.Out of scope (worth follow-up issues if there's demand)
0.0.0.0. Today the client URL construction hard-codes127.0.0.1, which is fine for0.0.0.0listeners but won't reach a daemon bound to e.g.192.168.1.5. Would require the port file (or a sibling file) to carryhost:port.