support IpAddress in contexts ValidIpAddress is supported (#95)
This commit is contained in:
parent
07b598ff28
commit
7568f1b7c3
|
@ -5,6 +5,12 @@ import
|
|||
export
|
||||
net, toml_serialization
|
||||
|
||||
proc readValue*(r: var TomlReader, val: var IpAddress)
|
||||
{.raises: [SerializationError, IOError, Defect].} =
|
||||
val = try: parseIpAddress(r.readValue(string))
|
||||
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))
|
||||
|
|
|
@ -90,10 +90,15 @@ type
|
|||
name: "rpc-port" }: Port
|
||||
|
||||
rpcAddress* {.
|
||||
defaultValue: defaultAdminListenAddress(config)
|
||||
defaultValue: ValidIpAddress.init(defaultAdminListenAddress(config))
|
||||
desc: "Address of the server to connect to for RPC - for the validator duties in the pull model"
|
||||
name: "rpc-address" }: ValidIpAddress
|
||||
|
||||
restAddress* {.
|
||||
defaultValue: defaultAdminListenAddress(config)
|
||||
desc: "Address of the server to connect to for RPC - for the validator duties in the pull model"
|
||||
name: "rest-address" }: IpAddress
|
||||
|
||||
retryDelay* {.
|
||||
defaultValue: 10
|
||||
desc: "Delay in seconds between retries after unsuccessful attempts to connect to a beacon node"
|
||||
|
@ -127,8 +132,8 @@ func parseCmdArg*(T: type GraffitiBytes, input: string): T
|
|||
func completeCmdArg*(T: type GraffitiBytes, input: string): seq[string] =
|
||||
@[]
|
||||
|
||||
func defaultAdminListenAddress*(conf: TestConf): ValidIpAddress =
|
||||
(static ValidIpAddress.init("127.0.0.1"))
|
||||
func defaultAdminListenAddress*(conf: TestConf): IpAddress =
|
||||
(static parseIpAddress("127.0.0.1"))
|
||||
|
||||
const
|
||||
defaultEth2TcpPort* = 9000
|
||||
|
@ -148,6 +153,12 @@ proc readValue(r: var TomlReader,
|
|||
type T = type value
|
||||
value = T r.parseAsString()
|
||||
|
||||
proc readValue(r: var TomlReader, value: var IpAddress) =
|
||||
try:
|
||||
value = parseIpAddress(r.parseAsString())
|
||||
except ValueError as ex:
|
||||
raise newException(SerializationError, ex.msg)
|
||||
|
||||
proc readValue(r: var TomlReader, value: var ValidIpAddress) =
|
||||
try:
|
||||
value = ValidIpAddress.init(r.parseAsString())
|
||||
|
@ -168,6 +179,9 @@ proc readValue(r: var WinregReader,
|
|||
type T = type value
|
||||
value = r.readValue(string).T
|
||||
|
||||
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))
|
||||
|
||||
|
|
Loading…
Reference in New Issue