mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-05-16 07:19:29 +00:00
* fix node info to use announcedAddresses again
* expose ports via Debug API ("MyBoundPorts")
* builders default to port 0 in discv5/metrics/p2pTcp
* add waku/net/bound_ports.nim
* move auto_port and net_config to waku/net/
* extract port-0 retry loop to tryWithAutoPort[T]
* misc refactors and fixes
28 lines
657 B
Nim
28 lines
657 B
Nim
{.push raises: [].}
|
|
|
|
import std/[json, options]
|
|
|
|
type BoundPorts* {.requiresInit.} = object
|
|
## Set by the factory once each service has bound to a port.
|
|
tcp*: Option[uint16]
|
|
webSocket*: Option[uint16]
|
|
rest*: Option[uint16]
|
|
discv5Udp*: Option[uint16]
|
|
metrics*: Option[uint16]
|
|
|
|
proc init*(T: type BoundPorts): BoundPorts =
|
|
BoundPorts(
|
|
tcp: none(uint16),
|
|
webSocket: none(uint16),
|
|
rest: none(uint16),
|
|
discv5Udp: none(uint16),
|
|
metrics: none(uint16),
|
|
)
|
|
|
|
proc toJsonString*(p: BoundPorts): string =
|
|
var obj = newJObject()
|
|
for name, value in fieldPairs(p):
|
|
if value.isSome():
|
|
obj[name] = %value.get()
|
|
return $obj
|