From 7217854b60b9a6c68180e0aac3de24c2ccf35350 Mon Sep 17 00:00:00 2001 From: tersec Date: Thu, 25 Jan 2024 11:05:18 +0000 Subject: [PATCH] rm deprecated ValidIpAddress support (#96) --- confutils/std/net.nim | 15 +++------------ confutils/toml/std/net.nim | 8 +------- tests/test_config_file.nim | 15 +++------------ 3 files changed, 7 insertions(+), 31 deletions(-) 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