logos-messaging-nim/waku/factory/network_conf.nim
fryorcraken cc66c7fe78 chore!: separate internal and CLI configurations (#3357)
Split `WakuNodeConfig` object for better separation of concerns and to introduce a tree-like structure to configuration.

* fix: ensure twn cluster conf is still applied when clusterId=1
* test: remove usage of `WakuNodeConf`
* Remove macro, split builder files, remove wakunodeconf from tests
* rm network_conf_builder module as it is not used

---------

Co-authored-by: NagyZoltanPeter <113987313+NagyZoltanPeter@users.noreply.github.com>
Co-authored-by: Ivan Folgueira Bande <ivansete@status.im>
2025-05-07 23:05:35 +02:00

35 lines
1.2 KiB
Nim

import std/[net, options, strutils]
import libp2p/multiaddress
type WebSocketSecureConf* {.requiresInit.} = object
keyPath*: string
certPath*: string
type WebSocketConf* = object
port*: Port
secureConf*: Option[WebSocketSecureConf]
type NetworkConf* = object
natStrategy*: string # TODO: make enum
p2pTcpPort*: Port
dns4DomainName*: Option[string]
p2pListenAddress*: IpAddress
extMultiAddrs*: seq[MultiAddress]
extMultiAddrsOnly*: bool
webSocketConf*: Option[WebSocketConf]
proc validateNoEmptyStrings(networkConf: NetworkConf): Result[void, string] =
if networkConf.dns4DomainName.isSome() and
isEmptyOrWhiteSpace(networkConf.dns4DomainName.get().string):
return err("dns4DomainName is an empty string, set it to none(string) instead")
if networkConf.webSocketConf.isSome() and
networkConf.webSocketConf.get().secureConf.isSome():
let secureConf = networkConf.webSocketConf.get().secureConf.get()
if isEmptyOrWhiteSpace(secureConf.keyPath):
return err("websocket.secureConf.keyPath is an empty string")
if isEmptyOrWhiteSpace(secureConf.certPath):
return err("websocket.secureConf.certPath is an empty string")
return ok()