diff --git a/tests/v2/test_wakunode.nim b/tests/v2/test_wakunode.nim index ee24904f0..09b0a4ef8 100644 --- a/tests/v2/test_wakunode.nim +++ b/tests/v2/test_wakunode.nim @@ -1388,4 +1388,38 @@ asyncTest "Messages are relayed between nodes with multiple transports (websocke check: (await completionFut.withTimeout(5.seconds)) == true await node1.stop() - await node2.stop() \ No newline at end of file + await node2.stop() + +asyncTest "Peer info updates with correct announced addresses": + let + nodeKey = crypto.PrivateKey.random(Secp256k1, rng[])[] + bindIp = ValidIpAddress.init("0.0.0.0") + bindPort = Port(60000) + extIp = some(ValidIpAddress.init("127.0.0.1")) + extPort = some(Port(60002)) + node = WakuNode.new( + nodeKey, + bindIp, bindPort, + extIp, extPort) + + let + bindEndpoint = MultiAddress.init(bindIp, tcpProtocol, bindPort) + announcedEndpoint = MultiAddress.init(extIp.get(), tcpProtocol, extPort.get()) + + check: + # Check that underlying peer info contains only bindIp before starting + node.switch.peerInfo.addrs.len == 1 + node.switch.peerInfo.addrs.contains(bindEndpoint) + + node.announcedAddresses.len == 1 + node.announcedAddresses.contains(announcedEndpoint) + + await node.start() + + check: + # Check that underlying peer info is updated with announced address + node.started + node.switch.peerInfo.addrs.len == 1 + node.switch.peerInfo.addrs.contains(announcedEndpoint) + + await node.stop() diff --git a/vendor/nim-libbacktrace/vendor/libbacktrace-upstream/libtool b/vendor/nim-libbacktrace/vendor/libbacktrace-upstream/libtool index 4ad349e3c..6bf30469d 100755 --- a/vendor/nim-libbacktrace/vendor/libbacktrace-upstream/libtool +++ b/vendor/nim-libbacktrace/vendor/libbacktrace-upstream/libtool @@ -2,7 +2,7 @@ # libtool - Provide generalized library-building support services. # Generated automatically by config.status (libbacktrace) version-unused -# Libtool was configured on host fv-az190-693: +# Libtool was configured on host fv-az173-167: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, diff --git a/vendor/nimbus-build-system/vendor/Nim/compiler/nim b/vendor/nimbus-build-system/vendor/Nim/compiler/nim index e444e5b73..7038ea09c 100755 Binary files a/vendor/nimbus-build-system/vendor/Nim/compiler/nim and b/vendor/nimbus-build-system/vendor/Nim/compiler/nim differ diff --git a/vendor/nimbus-build-system/vendor/Nim/compiler/nim1 b/vendor/nimbus-build-system/vendor/Nim/compiler/nim1 index 1983e8c84..46281aaa8 100755 Binary files a/vendor/nimbus-build-system/vendor/Nim/compiler/nim1 and b/vendor/nimbus-build-system/vendor/Nim/compiler/nim1 differ diff --git a/vendor/nimbus-build-system/vendor/Nim/compiler/nim2 b/vendor/nimbus-build-system/vendor/Nim/compiler/nim2 index e444e5b73..7038ea09c 100755 Binary files a/vendor/nimbus-build-system/vendor/Nim/compiler/nim2 and b/vendor/nimbus-build-system/vendor/Nim/compiler/nim2 differ diff --git a/waku/v2/node/wakunode2.nim b/waku/v2/node/wakunode2.nim index c2a11f479..667778e63 100644 --- a/waku/v2/node/wakunode2.nim +++ b/waku/v2/node/wakunode2.nim @@ -125,6 +125,22 @@ proc removeContentFilters(filters: var Filters, contentFilters: seq[ContentFilte debug "filters modified", filters=filters +proc updateSwitchPeerInfo(node: WakuNode) = + ## TODO: remove this when supported upstream + ## + ## nim-libp2p does not yet support announcing addrs + ## different from bound addrs. + ## + ## This is a temporary workaround to replace + ## peer info addrs in switch to announced + ## addresses. + ## + ## WARNING: this should only be called once the switch + ## has already been started. + + if node.announcedAddresses.len > 0: + node.switch.peerInfo.addrs = node.announcedAddresses + template tcpEndPoint(address, port): auto = MultiAddress.init(address, tcpProtocol, port) @@ -839,6 +855,9 @@ proc start*(node: WakuNode) {.async.} = info "Listening on", full = listenStr info "Discoverable ENR ", enr = node.enr.toURI() + ## Update switch peer info with announced addrs + node.updateSwitchPeerInfo() + if not node.wakuRelay.isNil: await node.startRelay()