Skip to content

Commit

Permalink
rm deprecated ValidIpAddress support (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
tersec committed Jan 25, 2024
1 parent 7568f1b commit 7217854
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 31 deletions.
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

0 comments on commit 7217854

Please sign in to comment.