diff --git a/confutils/std/net.nim b/confutils/std/net.nim index 5100c8d..bcea7f9 100644 --- a/confutils/std/net.nim +++ b/confutils/std/net.nim @@ -1,15 +1,6 @@ -import std/parseutils -import stew/shims/net as stewNet -export stewNet - -export ValidIpAddress - -func parseCmdArg*(T: type ValidIpAddress, s: string): T = - ValidIpAddress.init(s) - -func completeCmdArg*(T: type ValidIpAddress, val: string): seq[string] = - # TODO: Maybe complete the local IP address? - @[] +import std/net +from std/parseutils import parseInt +export net func parseCmdArg*(T: type IpAddress, s: string): T = parseIpAddress(s) diff --git a/confutils/toml/std/net.nim b/confutils/toml/std/net.nim index be8917c..95bd414 100644 --- a/confutils/toml/std/net.nim +++ b/confutils/toml/std/net.nim @@ -1,5 +1,5 @@ import - stew/shims/net, + std/net, toml_serialization, toml_serialization/lexer export @@ -11,12 +11,6 @@ proc readValue*(r: var TomlReader, val: var IpAddress) except ValueError as err: r.lex.raiseUnexpectedValue("IP address") -proc readValue*(r: var TomlReader, val: var ValidIpAddress) - {.raises: [SerializationError, IOError, Defect].} = - val = try: ValidIpAddress.init(r.readValue(string)) - except ValueError as err: - r.lex.raiseUnexpectedValue("IP address") - proc readValue*(r: var TomlReader, val: var Port) {.raises: [SerializationError, IOError, Defect].} = let port = try: r.readValue(uint16) diff --git a/tests/test_config_file.nim b/tests/test_config_file.nim index e68896d..efedad3 100644 --- a/tests/test_config_file.nim +++ b/tests/test_config_file.nim @@ -1,5 +1,5 @@ # nim-confutils -# Copyright (c) 2020 Status Research & Development GmbH +# Copyright (c) 2020-2024 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license: [LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT # * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) @@ -90,9 +90,9 @@ type name: "rpc-port" }: Port rpcAddress* {. - defaultValue: ValidIpAddress.init(defaultAdminListenAddress(config)) + defaultValue: defaultAdminListenAddress(config) desc: "Address of the server to connect to for RPC - for the validator duties in the pull model" - name: "rpc-address" }: ValidIpAddress + name: "rpc-address" }: IpAddress restAddress* {. defaultValue: defaultAdminListenAddress(config) @@ -159,12 +159,6 @@ proc readValue(r: var TomlReader, value: var IpAddress) = except ValueError as ex: raise newException(SerializationError, ex.msg) -proc readValue(r: var TomlReader, value: var ValidIpAddress) = - try: - value = ValidIpAddress.init(r.parseAsString()) - except ValueError as ex: - raise newException(SerializationError, ex.msg) - proc readValue(r: var TomlReader, value: var Port) = value = r.parseInt(int).Port @@ -182,9 +176,6 @@ proc readValue(r: var WinregReader, proc readValue(r: var WinregReader, value: var IpAddress) {.used.} = value = parseIpAddress(r.readValue(string)) -proc readValue(r: var WinregReader, value: var ValidIpAddress) {.used.} = - value = ValidIpAddress.init(r.readValue(string)) - proc readValue(r: var WinregReader, value: var Port) {.used.} = value = r.readValue(int).Port