From 8c4d4d3de2fa0f64a6a51e7ccb2bbbc54781103f Mon Sep 17 00:00:00 2001 From: munna0908 Date: Wed, 18 Dec 2024 15:00:48 +0530 Subject: [PATCH] update cli flags --- codex/conf.nim | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/codex/conf.nim b/codex/conf.nim index d59b347e..d7bf12f1 100644 --- a/codex/conf.nim +++ b/codex/conf.nim @@ -37,9 +37,10 @@ import ./logutils import ./stores import ./units import ./utils +import ./nat from ./validationconfig import MaxSlots, ValidationGroups -export units, net, codextypes, logutils +export units, net, codextypes, logutils,completeCmdArg,parseCmdArg,NatConfig export ValidationGroups, MaxSlots export @@ -140,19 +141,13 @@ type name: "listen-addrs" }: seq[MultiAddress] # TODO: change this once we integrate nat support + nat* {. - desc: "IP Addresses to announce behind a NAT" - defaultValue: ValidIpAddress.init("127.0.0.1") - defaultValueDesc: "127.0.0.1" - abbr: "a" - name: "nat" }: ValidIpAddress - - discoveryIp* {. - desc: "Discovery listen address" - defaultValue: ValidIpAddress.init(IPv4_any()) - defaultValueDesc: "0.0.0.0" - abbr: "e" - name: "disc-ip" }: ValidIpAddress + desc: "Specify method to use for determining public address. " & + "Must be one of: any, none, upnp, pmp, extip:" + defaultValue: NatConfig(hasExtIp: false, nat: NatAny) + defaultValueDesc: "any" + name: "nat" }: NatConfig discoveryPort* {. desc: "Discovery (UDP) port" @@ -528,6 +523,12 @@ proc readValue*(r: var TomlReader, val: var Duration) quit QuitFailure val = dur +proc readValue*(r: var TomlReader, val: var NatConfig) + {.raises: [SerializationError].} = + val = try: parseCmdArg(NatConfig, r.readValue(string)) + except CatchableError as err: + raise newException(SerializationError, err.msg) + # no idea why confutils needs this: proc completeCmdArg*(T: type EthAddress; val: string): seq[string] = discard