Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rm deprecated ValidIpAddress support #96

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions confutils/std/net.nim
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
8 changes: 1 addition & 7 deletions confutils/toml/std/net.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import
stew/shims/net,
std/net,
toml_serialization, toml_serialization/lexer

export
Expand All @@ -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)
Expand Down
15 changes: 3 additions & 12 deletions tests/test_config_file.nim
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down