fix: accept port 0 in parseCmdArg#146
Conversation
Port 0 is a meaningful value when binding sockets — it asks the OS to assign an ephemeral port. Embedded users of confutils (e.g. libraries that re-parse config from JSON) currently can't pass port 0 through the standard parser, which forces every consumer to roll its own override. Refs: logos-co/logos-delivery-module#18 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
@jmgomez @arnetheduck can you please take a look? Is this a reasonable change? |
|
cc @nitely 🙏 |
|
see 5d8d1ea Port 0 is not a valid port... but it's a valid value so I don't see why not. |
I think this is unlikely to break anything because it relaxes a restriction. The other way around, not allowing Port(0) would be a breaking change, ex: if this gets reverted it would break logos-delivery. Also, you can always make your own version of |
Now that confutils accepts port 0 in parseCmdArg (status-im/nim-confutils#146), revert the local Port special-case in createWaku and bump confutils to the fix instead. confutils is temporarily pinned to the PR fork commit (igor-sirotin/nim-confutils@0292f00d) until #146 merges to status-im master. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Agree 💯 @nitely Can you please merge it then, I have zero rights in this repo |
status-im/nim-confutils#146 is merged; move the confutils pin from the PR fork back to status-im/nim-confutils master (36f3115). Content is identical to the fork commit, so nimble sha1 and nix sha256 are unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore: pin confutils to merged upstream commit status-im/nim-confutils#146 is merged; move the confutils pin from the PR fork back to status-im/nim-confutils master (36f3115). Content is identical to the fork commit, so nimble sha1 and nix sha256 are unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
In createNode, default each listening port (tcpPort, discv5UdpPort, restPort, metricsServerPort, websocketPort) to 0 when the caller did not pin it, so the OS assigns ephemeral ports and multiple module instances can coexist on one host. Caller-supplied ports are preserved so fleet configs that pin ports keep working. logos-delivery now accepts port 0 (status-im/nim-confutils#146), which is what makes injecting 0 work end to end. Also stop logging the cfg payload from createNode: it can carry sensitive config. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
In createNode, default each listening port (tcpPort, discv5UdpPort, restPort, metricsServerPort, websocketPort) to 0 when the caller did not pin it, so the OS assigns ephemeral ports and multiple module instances can coexist on one host. Caller-supplied ports are preserved so fleet configs that pin ports keep working. logos-delivery now accepts port 0 (status-im/nim-confutils#146), which is what makes injecting 0 work end to end. Also stop logging the cfg payload from createNode: it can carry sensitive config. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Allow
0inparseCmdArg(T: type Port, s: string). Port0is the standard "let the OS assign an ephemeral port" value for socket binds, but the current parser rejects it as out of range.Downstream context: logos-co/logos-delivery-module#18 — the Waku-based delivery library needs to accept port
0from a JSON config so that multiple instances on one host can bind without collision. Right now every embedded consumer has to wrap or sidestep this parser.🤖 Generated with Claude Code