mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-04 06:53:12 +00:00
* fix: deprecate `--dns-discovery` Properly deprecates `--dns-discovery` CLI arg. DNS Discovery is enabled if a non-empty DNS Discovery URL is passed. * test: add test_all for factory add and use test_all for some tests.
35 lines
1.1 KiB
Nim
35 lines
1.1 KiB
Nim
import chronicles, std/[net, options, strutils], results
|
|
import ../waku_conf
|
|
|
|
logScope:
|
|
topics = "waku conf builder dns discovery"
|
|
|
|
##################################
|
|
## DNS Discovery Config Builder ##
|
|
##################################
|
|
type DnsDiscoveryConfBuilder* = object
|
|
enrTreeUrl*: Option[string]
|
|
nameServers*: seq[IpAddress]
|
|
|
|
proc init*(T: type DnsDiscoveryConfBuilder): DnsDiscoveryConfBuilder =
|
|
DnsDiscoveryConfBuilder()
|
|
|
|
proc withEnrTreeUrl*(b: var DnsDiscoveryConfBuilder, enrTreeUrl: string) =
|
|
b.enrTreeUrl = some(enrTreeUrl)
|
|
|
|
proc withNameServers*(b: var DnsDiscoveryConfBuilder, nameServers: seq[IpAddress]) =
|
|
b.nameServers = nameServers
|
|
|
|
proc build*(b: DnsDiscoveryConfBuilder): Result[Option[DnsDiscoveryConf], string] =
|
|
if b.enrTreeUrl.isNone():
|
|
return ok(none(DnsDiscoveryConf))
|
|
|
|
if isEmptyOrWhiteSpace(b.enrTreeUrl.get()):
|
|
return err("dnsDiscovery.enrTreeUrl cannot be an empty string")
|
|
if b.nameServers.len == 0:
|
|
return err("dnsDiscovery.nameServers is not specified")
|
|
|
|
return ok(
|
|
some(DnsDiscoveryConf(nameServers: b.nameServers, enrTreeUrl: b.enrTreeUrl.get()))
|
|
)
|