logos-messaging-nim/waku/net/bound_ports.nim
Fabiana Cecin 71a369ffad
feat: allow a port value of zero for service ports (auto-assign port) (#3828)
* any port set to 0 on conf results in a random port bound
* Debug API MyBoundPorts reports actually bound ports for all services, reports 0 if disabled
* write back bound values to both WakuConf and WakuNode.ports
* setupDiscoveryV5 returns Result and errors out on port 0
* rename setupAndStartDiscv5WithAutoPort to setupAndStartDiscv5
* updateWaku ENR rebuild now runs after discv5 startup
* Add DefaultP2pTcpPort, DefaultDiscv5UdpPort, DefaultWebSocketPort, DefaultRestPort, DefaultMetricsHttpPort
* add tests
2026-05-11 15:22:22 -03:00

21 lines
508 B
Nim

{.push raises: [].}
import std/json
type BoundPorts* {.requiresInit.} = object
## Set by the factory once each service has bound to a port.
## A value of 0 means the service was not enabled or did not bind.
tcp*: uint16
webSocket*: uint16
rest*: uint16
discv5Udp*: uint16
metrics*: uint16
proc init*(T: type BoundPorts): BoundPorts =
return BoundPorts(
tcp: 0'u16, webSocket: 0'u16, rest: 0'u16, discv5Udp: 0'u16, metrics: 0'u16
)
proc `$`*(p: BoundPorts): string =
return $(%*p)