replace ValidIpAddress with IpAddress in configurations (#5536)

This commit is contained in:
tersec 2023-11-01 08:33:00 +01:00 committed by GitHub
parent e1f47bb27a
commit ed446b1d5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 20 deletions

View File

@ -36,7 +36,7 @@ from consensus_object_pools/block_pools_types_light_client
export
uri, nat, enr,
defaultEth2TcpPort, enabledLogLevel, ValidIpAddress,
defaultEth2TcpPort, enabledLogLevel,
defs, parseCmdArg, completeCmdArg, network_metadata,
el_conf, network, BlockHashOrNumber,
confTomlDefs, confTomlNet, confTomlUri,
@ -47,8 +47,8 @@ declareGauge network_name, "network name", ["name"]
const
# TODO: How should we select between IPv4 and IPv6
# Maybe there should be a config option for this.
defaultListenAddress* = (static ValidIpAddress.init("0.0.0.0"))
defaultAdminListenAddress* = (static ValidIpAddress.init("127.0.0.1"))
defaultListenAddress* = (static parseIpAddress("0.0.0.0"))
defaultAdminListenAddress* = (static parseIpAddress("127.0.0.1"))
defaultSigningNodeRequestTimeout* = 60
defaultBeaconNode* = "http://127.0.0.1:" & $defaultEth2RestPort
defaultBeaconNodeUri* = parseUri(defaultBeaconNode)
@ -292,7 +292,7 @@ type
desc: "Listening address for the Ethereum LibP2P and Discovery v5 traffic"
defaultValue: defaultListenAddress
defaultValueDesc: $defaultListenAddressDesc
name: "listen-address" .}: ValidIpAddress
name: "listen-address" .}: IpAddress
tcpPort* {.
desc: "Listening TCP port for Ethereum LibP2P traffic"
@ -408,7 +408,7 @@ type
desc: "Listening address of the metrics server"
defaultValue: defaultAdminListenAddress
defaultValueDesc: $defaultAdminListenAddressDesc
name: "metrics-address" .}: ValidIpAddress
name: "metrics-address" .}: IpAddress
metricsPort* {.
desc: "Listening HTTP port of the metrics server"
@ -449,7 +449,7 @@ type
# Deprecated > 1.7.0
hidden
desc: "Deprecated for removal"
name: "rpc-address" .}: Option[ValidIpAddress]
name: "rpc-address" .}: Option[IpAddress]
restEnabled* {.
desc: "Enable the REST server"
@ -466,7 +466,7 @@ type
desc: "Listening address of the REST server"
defaultValue: defaultAdminListenAddress
defaultValueDesc: $defaultAdminListenAddressDesc
name: "rest-address" .}: ValidIpAddress
name: "rest-address" .}: IpAddress
restAllowedOrigin* {.
desc: "Limit the access to the REST API to a particular hostname " &
@ -520,7 +520,7 @@ type
desc: "Listening port for the REST keymanager API"
defaultValue: defaultAdminListenAddress
defaultValueDesc: $defaultAdminListenAddressDesc
name: "keymanager-address" .}: ValidIpAddress
name: "keymanager-address" .}: IpAddress
keymanagerAllowedOrigin* {.
desc: "Limit the access to the Keymanager API to a particular hostname " &
@ -776,7 +776,7 @@ type
of RecordCmd.create:
ipExt* {.
desc: "External IP address"
name: "ip" .}: ValidIpAddress
name: "ip" .}: IpAddress
tcpPortExt* {.
desc: "External TCP port"
@ -973,7 +973,7 @@ type
desc: "Listening port for the REST keymanager API"
defaultValue: defaultAdminListenAddress
defaultValueDesc: $defaultAdminListenAddressDesc
name: "keymanager-address" .}: ValidIpAddress
name: "keymanager-address" .}: IpAddress
keymanagerAllowedOrigin* {.
desc: "Limit the access to the Keymanager API to a particular hostname " &
@ -993,7 +993,7 @@ type
desc: "Listening address of the metrics server (BETA)"
defaultValue: defaultAdminListenAddress
defaultValueDesc: $defaultAdminListenAddressDesc
name: "metrics-address" .}: ValidIpAddress
name: "metrics-address" .}: IpAddress
metricsPort* {.
desc: "Listening HTTP port of the metrics server (BETA)"
@ -1091,7 +1091,7 @@ type
desc: "Listening address of the REST HTTP server"
defaultValue: defaultAdminListenAddress
defaultValueDesc: $defaultAdminListenAddressDesc
name: "bind-address" .}: ValidIpAddress
name: "bind-address" .}: IpAddress
tlsEnabled* {.
desc: "Use secure TLS communication for REST server"

View File

@ -65,7 +65,7 @@ type LightClientConf* = object
desc: "Listening address for the Ethereum LibP2P and Discovery v5 traffic"
defaultValue: defaultListenAddress
defaultValueDesc: $defaultListenAddressDesc
name: "listen-address" .}: ValidIpAddress
name: "listen-address" .}: IpAddress
tcpPort* {.
desc: "Listening TCP port for Ethereum LibP2P traffic"

View File

@ -2304,7 +2304,8 @@ proc createEth2Node*(rng: ref HmacDrbgContext,
cfg, getBeaconTime().slotOrZero.epoch, genesis_validators_root)
(extIp, extTcpPort, extUdpPort) = try: setupAddress(
config.nat, config.listenAddress, config.tcpPort, config.udpPort, clientId)
config.nat, ValidIpAddress.init config.listenAddress, config.tcpPort,
config.udpPort, clientId)
except CatchableError as exc: raise exc
except Exception as exc: raiseAssert exc.msg
@ -2326,7 +2327,8 @@ proc createEth2Node*(rng: ref HmacDrbgContext,
info "Adding privileged direct peer", peerId, address
res
hostAddress = tcpEndPoint(config.listenAddress, config.tcpPort)
hostAddress = tcpEndPoint(
ValidIpAddress.init config.listenAddress, config.tcpPort)
announcedAddresses = if extIp.isNone() or extTcpPort.isNone(): @[]
else: @[tcpEndPoint(extIp.get(), extTcpPort.get())]

View File

@ -2108,7 +2108,7 @@ proc doRecord(config: BeaconNodeConf, rng: var HmacDrbgContext) {.
let record = enr.Record.init(
config.seqNumber,
netKeys.seckey.asEthKey,
some(config.ipExt),
some(ValidIpAddress.init config.ipExt),
some(config.tcpPortExt),
some(config.udpPortExt),
fieldPairs).expect("Record within size limits")

View File

@ -117,9 +117,9 @@ type
bootstrapAddress* {.
desc: "The public IP address that will be advertised as a bootstrap node for the testnet"
defaultValue: init(ValidIpAddress, defaultAdminListenAddress)
defaultValue: defaultAdminListenAddress
defaultValueDesc: $defaultAdminListenAddressDesc
name: "bootstrap-address" .}: ValidIpAddress
name: "bootstrap-address" .}: IpAddress
bootstrapPort* {.
desc: "The TCP/UDP port that will be used by the bootstrap node"
@ -194,9 +194,9 @@ type
enrAddress* {.
desc: "The public IP address of that ENR"
defaultValue: init(ValidIpAddress, defaultAdminListenAddress)
defaultValue: defaultAdminListenAddress
defaultValueDesc: $defaultAdminListenAddressDesc
name: "enr-address" .}: ValidIpAddress
name: "enr-address" .}: IpAddress
enrPort* {.
desc: "The TCP/UDP port of that ENR"