Repository navigation
feat(id): multiple web listeners by flag and config (#2145) - #4118
Conversation
Bindings model from triage task 3155: ServeOptions resolves its web listener set once at startup -- repeatable --web-listen flags win, else the new [web_bindings] section in defaults.conf, else the legacy --bind/--port pair. --web-listen with an explicitly-set --bind/--port is a startup error naming the flag. All listeners bind early; any bind failure aborts naming the listener. Startup prints a listener count plus one line per listener; ServeInfo gains web_bindings (serde default) with web_port kept as the first listener port. Routers share one AppState (identity store opens exclusively) with per-listener WebSecurity via web::web_routers. Queue task 5191.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 2 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ac8f8ae3e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let web_routers = crate::web::web_routers( | ||
| store_handle.clone(), |
There was a problem hiding this comment.
Skip router initialization when the web interface is disabled
In builds with the web feature, invoking serve without --web now calls web_routers with an empty security list. That function constructs AppState before iterating the list, opening both the local-events directory and .identity.redb. Consequently, a corrupt, inaccessible, or externally locked web database can now abort an otherwise web-disabled P2P server, and normal startup unnecessarily creates web persistence files. Preserve the previous web-enabled guard around state construction.
Useful? React with 👍 / 👎.
| #[arg(long = "web-listen", value_name = "IP:PORT")] | ||
| web_listen: Vec<SocketAddr>, |
There was a problem hiding this comment.
Add integration tests for the new listener CLI behavior
pkgs/id/AGENTS.md explicitly requires integration tests in tests/cli_integration.rs for CLI behavior, but this change adds only unit tests and leaves that integration suite unchanged. Searching the repository tests found no coverage for web-listen, web_listen, or web_bindings. Add executable-level coverage for repeated listeners and explicit --bind/--port conflicts so the argument-source wiring in main.rs and actual multi-listener startup are checked, rather than only parsing and resolution in isolation.
AGENTS.md reference: pkgs/id/AGENTS.md:L152-L152
Useful? React with 👍 / 👎.
| /// (#2145 bindings model, designed in triage task 3155): | ||
| /// | ||
| /// 1. `--web-listen` flags, when given at least once, win entirely. | ||
| /// Combining them with an explicitly-set `--bind` or `--port` is an | ||
| /// error naming the conflicting flag (clap defaults do not count). | ||
| /// 2. Else the `[web_bindings]` section of `defaults.conf`, parsed here | ||
| /// so a malformed line fails startup naming the line. |
There was a problem hiding this comment.
Record the listener design in the required dated document
This introduces a new serving interface and listener-precedence semantics without the dated design record required by pkgs/id/AGENTS.md. Repository-wide Markdown searches, including the pkgs/id/docs symlink target, found no corresponding multi-listener design document; the commit instead references an external issue comment. Add the prescribed dated folder and matching Markdown recording the request, design, and decisions so this interface change has the required repository architecture record.
AGENTS.md reference: pkgs/id/AGENTS.md:L168-L168
Useful? React with 👍 / 👎.
| .map(|addr| WebBinding { | ||
| bind: addr.ip(), | ||
| port: addr.port(), |
There was a problem hiding this comment.
Preserve the interface scope of IPv6 listener addresses
For a scoped link-local IPv6 listener such as --web-listen '[fe80::1%3]:3000', parsing succeeds, but extracting only addr.ip() and addr.port() discards the IPv6 scope ID. WebBinding::socket_addr() then reconstructs the address with scope zero, so binding cannot select the requested interface and startup fails even when the original scoped address is valid. The config-binding path performs the same lossy conversion. Retain the full SocketAddr through resolution and binding, deriving its IP separately for the security policy.
Useful? React with 👍 / 👎.
|
🤖 Agent note · parked
|
Implements the #2145 bindings model designed in triage task 3155 (design comment on #2145). Queue task 5191.
What
pkgs/id/src/commands/serve.rs):ServeOptionsgainsweb_listen: Vec<SocketAddr>plusbind_explicit/port_explicit;resolve_web_bindingsresolves the listener set once at startup:--web-listen <IP:PORT>flags win entirely;[web_bindings]section ofdefaults.conf;--bind/--port(unchanged defaults).--web-listencombined with an explicitly-set--bindor--portis a startup error naming the conflicting flag (clap defaults do not count —main.rsreads clap value sources).pkgs/id/crates/id-core):parse_defaultscollects[web_bindings]lines raw intoDefaults.web_bindings; parsing happens at serve startup so a malformed line fails startup naming the line. The embeddeddefaults.confdocuments the section with commented examples only — default behavior unchanged.web: failed to bind listener <addr>: <err>— no partial start. Startup printsweb: <n> listener(s)plus oneweb: http://host:portline per listener in binding order with actual ports. Each listener serves the same Explorerweb_routerwith its ownWebSecurity::for_bind; the non-loopback no-token warning fires per listener naming addr:port.ServeInfogainsweb_bindings: Vec<String>(#[serde(default)], so pre-id(serve): a bindings model — multiple listeners by flag and config #2145 lock files still parse);web_portkeeps meaning first-listener port.Out of scope (per design): per-listener distinct tokens and program content (#2146), runtime per-user config file.
Tests
Laptop (
cargo test, pkgs/id):id-corelib: 57 passed — incl. newtest_parse_defaults_web_bindings,test_parse_defaults_no_web_bindings_section.idlib:servefilter 51 passed (default features) and 51 passed with--features web;web_bindingsfilter 10 passed default / 12 passed with web — incl.resolve_web_bindingsprecedence (flags win over config), legacy fallback, conflict errors naming--bind/--port, malformed config line named, pre-id(serve): a bindings model — multiple listeners by flag and config #2145 lock JSON still parses;web_listenCLI parse: 1 passed (repeatable + malformed rejected);serve_info: 5 passed.--features webbuild):serve --ephemeral --web --web-listen 127.0.0.1:18099 --web-listen 127.0.0.1:18100printedweb: 2 listener(s)+ oneweb: http://localhost:<port>line per listener; both listeners answered HTTP 200; lock file:"web_port": 18099,"web_bindings": ["127.0.0.1:18099", "127.0.0.1:18100"]. Occupied-port launch aborts withweb: failed to bind listener 127.0.0.1:18099: Address already in use;--web-listen+--portaborts naming the conflict.web_routerper listener fails on the second identity-store open (redb is exclusive), so all listeners now share oneAppStatevia the newweb::web_routers(state built once, cloned per listener, finished with each listener's ownWebSecurity).Closes #2145
Need help on this PR? Tag
@codesmith-botwith what you need.