Remove `udpPort` CLI option from waku v1 and v2 nodes (#728)

This commit is contained in:
Pascal Precht 2021-10-12 13:43:01 +02:00 committed by GitHub
parent 5f76d90b7f
commit 83f71ae905
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 22 additions and 25 deletions

View File

@ -18,7 +18,9 @@ proc runBackground() {.async.} =
conf = WakuNodeConf.load()
(extIp, extTcpPort, extUdpPort) = setupNat(conf.nat, clientId,
Port(uint16(conf.tcpPort) + conf.portsShift),
Port(uint16(conf.udpPort) + conf.portsShift))
# This is actually a UDP port but we're only supplying this value
# To satisfy the API.
Port(uint16(conf.tcpPort) + conf.portsShift))
node = WakuNode.new(conf.nodeKey, conf.listenAddress,
Port(uint16(conf.tcpPort) + conf.portsShift), extIp, extTcpPort)

View File

@ -31,11 +31,6 @@ type
defaultValue: 30303
name: "devp2p-tcp-port" .}: uint16
udpPort* {.
desc: "UDP listening port"
defaultValue: 9000
name: "udp-port" .}: uint16
portsShift* {.
desc: "Add a shift to all default port numbers"
defaultValue: 0

View File

@ -265,24 +265,28 @@ when isMainModule:
if conf.logLevel != LogLevel.NONE:
setLogLevel(conf.logLevel)
## `udpPort` is only supplied to satisfy underlying APIs but is not
## actually a supported transport.
let udpPort = conf.devp2pTcpPort
# Load address configuration
let
(nodev1ExtIp, _, _) = setupNat(conf.nat, ClientIdV1,
Port(conf.devp2pTcpPort + conf.portsShift),
Port(conf.udpPort + conf.portsShift))
Port(udpPort + conf.portsShift))
# TODO: EthereumNode should have a better split of binding address and
# external address. Also, can't have different ports as it stands now.
nodev1Address = if nodev1ExtIp.isNone():
Address(ip: parseIpAddress("0.0.0.0"),
tcpPort: Port(conf.devp2pTcpPort + conf.portsShift),
udpPort: Port(conf.udpPort + conf.portsShift))
udpPort: Port(udpPort + conf.portsShift))
else:
Address(ip: nodev1ExtIp.get(),
tcpPort: Port(conf.devp2pTcpPort + conf.portsShift),
udpPort: Port(conf.udpPort + conf.portsShift))
udpPort: Port(udpPort + conf.portsShift))
(nodev2ExtIp, nodev2ExtPort, _) = setupNat(conf.nat, clientId,
Port(uint16(conf.libp2pTcpPort) + conf.portsShift),
Port(uint16(conf.udpPort) + conf.portsShift))
Port(uint16(udpPort) + conf.portsShift))
# Topic interest and bloom
var topicInterest: Option[seq[waku_protocol.Topic]]

View File

@ -28,11 +28,6 @@ type
defaultValue: 30303
name: "tcp-port" .}: uint16
udpPort* {.
desc: "UDP listening port."
defaultValue: 30303
name: "udp-port" .}: uint16
portsShift* {.
desc: "Add a shift to all port numbers."
defaultValue: 0

View File

@ -15,20 +15,23 @@ const clientId = "Nimbus waku node"
proc run(config: WakuNodeConf, rng: ref BrHmacDrbgContext)
{.raises: [Defect, ValueError, RpcBindError, CatchableError, Exception]} =
## `udpPort` is only supplied to satisfy underlying APIs but is not
## actually a supported transport.
let udpPort = config.tcpPort
let
(ipExt, tcpPortExt, udpPortExt) = setupNat(config.nat, clientId,
(ipExt, tcpPortExt, _) = setupNat(config.nat, clientId,
Port(config.tcpPort + config.portsShift),
Port(config.udpPort + config.portsShift))
Port(udpPort + config.portsShift))
# TODO: EthereumNode should have a better split of binding address and
# external address. Also, can't have different ports as it stands now.
address = if ipExt.isNone():
Address(ip: parseIpAddress("0.0.0.0"),
tcpPort: Port(config.tcpPort + config.portsShift),
udpPort: Port(config.udpPort + config.portsShift))
udpPort: Port(udpPort + config.portsShift))
else:
Address(ip: ipExt.get(),
tcpPort: Port(config.tcpPort + config.portsShift),
udpPort: Port(config.udpPort + config.portsShift))
udpPort: Port(udpPort + config.portsShift))
# Set-up node
var node = newEthereumNode(config.nodekey, address, NetworkId(1), nil, clientId,

View File

@ -32,11 +32,6 @@ type
defaultValue: 60000
name: "tcp-port" }: Port
udpPort* {.
desc: "UDP listening port."
defaultValue: 60000
name: "udp-port" }: Port
portsShift* {.
desc: "Add a shift to all port numbers."
defaultValue: 0

View File

@ -823,11 +823,14 @@ when isMainModule:
## file. Optionally include persistent peer storage.
## No protocols are mounted yet.
## `udpPort` is only supplied to satisfy underlying APIs but is not
## actually a supported transport.
let udpPort = conf.tcpPort
let
(extIp, extTcpPort, extUdpPort) = setupNat(conf.nat,
clientId,
Port(uint16(conf.tcpPort) + conf.portsShift),
Port(uint16(conf.udpPort) + conf.portsShift))
Port(uint16(udpPort) + conf.portsShift))
## @TODO: the NAT setup assumes a manual port mapping configuration if extIp config is set. This probably
## implies adding manual config item for extPort as well. The following heuristic assumes that, in absence of manual
## config, the external port is the same as the bind port.