mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-28 15:46:33 +00:00
deploy: e1254c20aed22588500825c02dc86276b186ddca
This commit is contained in:
parent
6bdd28cecd
commit
58b03b8c84
@ -9,6 +9,7 @@ The full list of changes is below.
|
|||||||
|
|
||||||
- The `waku-rln-relay` now supports spam-protection for a specific combination of `pubsubTopic` and `contentTopic` (available under the `rln` compiler flag).
|
- The `waku-rln-relay` now supports spam-protection for a specific combination of `pubsubTopic` and `contentTopic` (available under the `rln` compiler flag).
|
||||||
- The `waku-rln-relay` protocol in integrated into `chat2` (available under the`rln` compiler flag)
|
- The `waku-rln-relay` protocol in integrated into `chat2` (available under the`rln` compiler flag)
|
||||||
|
- Added support for resolving dns-based `multiaddrs`
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import
|
|||||||
libp2p/protocols/pubsub/rpc/messages,
|
libp2p/protocols/pubsub/rpc/messages,
|
||||||
libp2p/protocols/pubsub/pubsub,
|
libp2p/protocols/pubsub/pubsub,
|
||||||
libp2p/protocols/pubsub/gossipsub,
|
libp2p/protocols/pubsub/gossipsub,
|
||||||
|
libp2p/nameresolving/mockresolver,
|
||||||
eth/keys,
|
eth/keys,
|
||||||
../../waku/v2/node/storage/sqlite,
|
../../waku/v2/node/storage/sqlite,
|
||||||
../../waku/v2/node/storage/message/waku_message_store,
|
../../waku/v2/node/storage/message/waku_message_store,
|
||||||
@ -468,6 +469,31 @@ procSuite "WakuNode":
|
|||||||
$(remotePeerInfo.addrs[0][0].tryGet()) == "/ip4/127.0.0.1"
|
$(remotePeerInfo.addrs[0][0].tryGet()) == "/ip4/127.0.0.1"
|
||||||
$(remotePeerInfo.addrs[0][1].tryGet()) == "/tcp/60002"
|
$(remotePeerInfo.addrs[0][1].tryGet()) == "/tcp/60002"
|
||||||
|
|
||||||
|
# DNS multiaddrs parsing expected cases:
|
||||||
|
let
|
||||||
|
dnsPeer = parseRemotePeerInfo("/dns/localhost/tcp/60002/p2p/16Uuu2HBmAcHvhLqQKwSSbX6BG5JLWUDRcaLVrehUVqpw7fz1hbYc")
|
||||||
|
dnsAddrPeer = parseRemotePeerInfo("/dnsaddr/localhost/tcp/60002/p2p/16Uuu2HBmAcHvhLqQKwSSbX6BG5JLWUDRcaLVrehUVqpw7fz1hbYc")
|
||||||
|
dns4Peer = parseRemotePeerInfo("/dns4/localhost/tcp/60002/p2p/16Uuu2HBmAcHvhLqQKwSSbX6BG5JLWUDRcaLVrehUVqpw7fz1hbYc")
|
||||||
|
dns6Peer = parseRemotePeerInfo("/dns6/localhost/tcp/60002/p2p/16Uuu2HBmAcHvhLqQKwSSbX6BG5JLWUDRcaLVrehUVqpw7fz1hbYc")
|
||||||
|
|
||||||
|
check:
|
||||||
|
# /dns
|
||||||
|
$(dnsPeer.peerId) == "16Uuu2HBmAcHvhLqQKwSSbX6BG5JLWUDRcaLVrehUVqpw7fz1hbYc"
|
||||||
|
$(dnsPeer.addrs[0][0].tryGet()) == "/dns/localhost"
|
||||||
|
$(dnsPeer.addrs[0][1].tryGet()) == "/tcp/60002"
|
||||||
|
# /dnsaddr
|
||||||
|
$(dnsAddrPeer.peerId) == "16Uuu2HBmAcHvhLqQKwSSbX6BG5JLWUDRcaLVrehUVqpw7fz1hbYc"
|
||||||
|
$(dnsAddrPeer.addrs[0][0].tryGet()) == "/dnsaddr/localhost"
|
||||||
|
$(dnsAddrPeer.addrs[0][1].tryGet()) == "/tcp/60002"
|
||||||
|
# /dns4
|
||||||
|
$(dns4Peer.peerId) == "16Uuu2HBmAcHvhLqQKwSSbX6BG5JLWUDRcaLVrehUVqpw7fz1hbYc"
|
||||||
|
$(dns4Peer.addrs[0][0].tryGet()) == "/dns4/localhost"
|
||||||
|
$(dns4Peer.addrs[0][1].tryGet()) == "/tcp/60002"
|
||||||
|
# /dns6
|
||||||
|
$(dns6Peer.peerId) == "16Uuu2HBmAcHvhLqQKwSSbX6BG5JLWUDRcaLVrehUVqpw7fz1hbYc"
|
||||||
|
$(dns6Peer.addrs[0][0].tryGet()) == "/dns6/localhost"
|
||||||
|
$(dns6Peer.addrs[0][1].tryGet()) == "/tcp/60002"
|
||||||
|
|
||||||
# Now test some common corner cases
|
# Now test some common corner cases
|
||||||
expect LPError:
|
expect LPError:
|
||||||
# gibberish
|
# gibberish
|
||||||
@ -493,6 +519,34 @@ procSuite "WakuNode":
|
|||||||
# unsupported transport
|
# unsupported transport
|
||||||
discard parseRemotePeerInfo("/ip4/127.0.0.1/udp/60002/p2p/16Uuu2HBmAcHvhLqQKwSSbX6BG5JLWUDRcaLVrehUVqpw7fz1hbYc")
|
discard parseRemotePeerInfo("/ip4/127.0.0.1/udp/60002/p2p/16Uuu2HBmAcHvhLqQKwSSbX6BG5JLWUDRcaLVrehUVqpw7fz1hbYc")
|
||||||
|
|
||||||
|
asyncTest "resolve and connect to dns multiaddrs":
|
||||||
|
let resolver = MockResolver.new()
|
||||||
|
|
||||||
|
resolver.ipResponses[("localhost", false)] = @["127.0.0.1"]
|
||||||
|
|
||||||
|
let
|
||||||
|
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
||||||
|
node1 = WakuNode.new(nodeKey1, ValidIpAddress.init("0.0.0.0"), Port(60000), nameResolver = resolver)
|
||||||
|
nodeKey2 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
||||||
|
node2 = WakuNode.new(nodeKey2, ValidIpAddress.init("0.0.0.0"), Port(60002))
|
||||||
|
|
||||||
|
# Construct DNS multiaddr for node2
|
||||||
|
let
|
||||||
|
node2PeerId = $(node2.switch.peerInfo.peerId)
|
||||||
|
node2Dns4Addr = "/dns4/localhost/tcp/60002/p2p/" & node2PeerId
|
||||||
|
|
||||||
|
node1.mountRelay()
|
||||||
|
node2.mountRelay()
|
||||||
|
|
||||||
|
await allFutures([node1.start(), node2.start()])
|
||||||
|
|
||||||
|
await node1.connectToNodes(@[node2Dns4Addr])
|
||||||
|
|
||||||
|
check:
|
||||||
|
node1.switch.connManager.connCount(node2.switch.peerInfo.peerId) == 1
|
||||||
|
|
||||||
|
await allFutures([node1.stop(), node2.stop()])
|
||||||
|
|
||||||
asyncTest "filtering relayed messages using topic validators":
|
asyncTest "filtering relayed messages using topic validators":
|
||||||
## test scenario:
|
## test scenario:
|
||||||
## node1 and node3 set node2 as their relay node
|
## node1 and node3 set node2 as their relay node
|
||||||
@ -534,7 +588,6 @@ procSuite "WakuNode":
|
|||||||
await node1.connectToNodes(@[node2.switch.peerInfo.toRemotePeerInfo()])
|
await node1.connectToNodes(@[node2.switch.peerInfo.toRemotePeerInfo()])
|
||||||
await node3.connectToNodes(@[node2.switch.peerInfo.toRemotePeerInfo()])
|
await node3.connectToNodes(@[node2.switch.peerInfo.toRemotePeerInfo()])
|
||||||
|
|
||||||
|
|
||||||
var completionFutValidatorAcc = newFuture[bool]()
|
var completionFutValidatorAcc = newFuture[bool]()
|
||||||
var completionFutValidatorRej = newFuture[bool]()
|
var completionFutValidatorRej = newFuture[bool]()
|
||||||
|
|
||||||
@ -922,6 +975,7 @@ procSuite "WakuNode":
|
|||||||
await node1.stop()
|
await node1.stop()
|
||||||
await node2.stop()
|
await node2.stop()
|
||||||
await node3.stop()
|
await node3.stop()
|
||||||
|
|
||||||
asyncTest "Relay protocol is started correctly":
|
asyncTest "Relay protocol is started correctly":
|
||||||
let
|
let
|
||||||
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
||||||
@ -1162,7 +1216,7 @@ procSuite "WakuNode":
|
|||||||
await allFutures([node1.stop(), node2.stop(), node3.stop()])
|
await allFutures([node1.stop(), node2.stop(), node3.stop()])
|
||||||
|
|
||||||
|
|
||||||
asyncTest "Messages are relayed between two websocket nodes":
|
asyncTest "Messages are relayed between two websocket nodes":
|
||||||
let
|
let
|
||||||
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
||||||
node1 = WakuNode.new(nodeKey1, ValidIpAddress.init("0.0.0.0"),
|
node1 = WakuNode.new(nodeKey1, ValidIpAddress.init("0.0.0.0"),
|
||||||
@ -1207,7 +1261,7 @@ asyncTest "Messages are relayed between two websocket nodes":
|
|||||||
await node2.stop()
|
await node2.stop()
|
||||||
|
|
||||||
|
|
||||||
asyncTest "Messages are relayed between nodes with multiple transports (TCP and Websockets)":
|
asyncTest "Messages are relayed between nodes with multiple transports (TCP and Websockets)":
|
||||||
let
|
let
|
||||||
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
||||||
node1 = WakuNode.new(nodeKey1, ValidIpAddress.init("0.0.0.0"),
|
node1 = WakuNode.new(nodeKey1, ValidIpAddress.init("0.0.0.0"),
|
||||||
@ -1251,7 +1305,7 @@ asyncTest "Messages are relayed between nodes with multiple transports (TCP and
|
|||||||
await node1.stop()
|
await node1.stop()
|
||||||
await node2.stop()
|
await node2.stop()
|
||||||
|
|
||||||
asyncTest "Messages relaying fails with non-overlapping transports (TCP or Websockets)":
|
asyncTest "Messages relaying fails with non-overlapping transports (TCP or Websockets)":
|
||||||
let
|
let
|
||||||
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
||||||
node1 = WakuNode.new(nodeKey1, ValidIpAddress.init("0.0.0.0"),
|
node1 = WakuNode.new(nodeKey1, ValidIpAddress.init("0.0.0.0"),
|
||||||
@ -1299,7 +1353,7 @@ asyncTest "Messages relaying fails with non-overlapping transports (TCP or Webso
|
|||||||
await node1.stop()
|
await node1.stop()
|
||||||
await node2.stop()
|
await node2.stop()
|
||||||
|
|
||||||
asyncTest "Messages are relayed between nodes with multiple transports (TCP and secure Websockets)":
|
asyncTest "Messages are relayed between nodes with multiple transports (TCP and secure Websockets)":
|
||||||
let
|
let
|
||||||
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
||||||
node1 = WakuNode.new(nodeKey1, ValidIpAddress.init("0.0.0.0"),
|
node1 = WakuNode.new(nodeKey1, ValidIpAddress.init("0.0.0.0"),
|
||||||
@ -1343,7 +1397,7 @@ asyncTest "Messages are relayed between nodes with multiple transports (TCP and
|
|||||||
await node1.stop()
|
await node1.stop()
|
||||||
await node2.stop()
|
await node2.stop()
|
||||||
|
|
||||||
asyncTest "Messages fails with wrong key path":
|
asyncTest "Messages fails with wrong key path":
|
||||||
let
|
let
|
||||||
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
||||||
|
|
||||||
@ -1352,7 +1406,7 @@ asyncTest "Messages fails with wrong key path":
|
|||||||
discard WakuNode.new(nodeKey1, ValidIpAddress.init("0.0.0.0"),
|
discard WakuNode.new(nodeKey1, ValidIpAddress.init("0.0.0.0"),
|
||||||
bindPort = Port(60000), wsBindPort = Port(8000), wssEnabled = true, secureKey = "../../waku/v2/node/key_dummy.txt")
|
bindPort = Port(60000), wsBindPort = Port(8000), wssEnabled = true, secureKey = "../../waku/v2/node/key_dummy.txt")
|
||||||
|
|
||||||
asyncTest "Messages are relayed between nodes with multiple transports (websocket and secure Websockets)":
|
asyncTest "Messages are relayed between nodes with multiple transports (websocket and secure Websockets)":
|
||||||
let
|
let
|
||||||
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
||||||
node1 = WakuNode.new(nodeKey1, ValidIpAddress.init("0.0.0.0"),
|
node1 = WakuNode.new(nodeKey1, ValidIpAddress.init("0.0.0.0"),
|
||||||
@ -1396,36 +1450,36 @@ asyncTest "Messages are relayed between nodes with multiple transports (websocke
|
|||||||
await node1.stop()
|
await node1.stop()
|
||||||
await node2.stop()
|
await node2.stop()
|
||||||
|
|
||||||
asyncTest "Peer info updates with correct announced addresses":
|
asyncTest "Peer info updates with correct announced addresses":
|
||||||
let
|
let
|
||||||
nodeKey = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
nodeKey = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
||||||
bindIp = ValidIpAddress.init("0.0.0.0")
|
bindIp = ValidIpAddress.init("0.0.0.0")
|
||||||
bindPort = Port(60000)
|
bindPort = Port(60000)
|
||||||
extIp = some(ValidIpAddress.init("127.0.0.1"))
|
extIp = some(ValidIpAddress.init("127.0.0.1"))
|
||||||
extPort = some(Port(60002))
|
extPort = some(Port(60002))
|
||||||
node = WakuNode.new(
|
node = WakuNode.new(
|
||||||
nodeKey,
|
nodeKey,
|
||||||
bindIp, bindPort,
|
bindIp, bindPort,
|
||||||
extIp, extPort)
|
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()
|
let
|
||||||
|
bindEndpoint = MultiAddress.init(bindIp, tcpProtocol, bindPort)
|
||||||
|
announcedEndpoint = MultiAddress.init(extIp.get(), tcpProtocol, extPort.get())
|
||||||
|
|
||||||
check:
|
check:
|
||||||
# Check that underlying peer info is updated with announced address
|
# Check that underlying peer info contains only bindIp before starting
|
||||||
node.started
|
node.switch.peerInfo.addrs.len == 1
|
||||||
node.switch.peerInfo.addrs.len == 1
|
node.switch.peerInfo.addrs.contains(bindEndpoint)
|
||||||
node.switch.peerInfo.addrs.contains(announcedEndpoint)
|
|
||||||
|
node.announcedAddresses.len == 1
|
||||||
|
node.announcedAddresses.contains(announcedEndpoint)
|
||||||
|
|
||||||
|
await node.start()
|
||||||
|
|
||||||
await node.stop()
|
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()
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# libtool - Provide generalized library-building support services.
|
# libtool - Provide generalized library-building support services.
|
||||||
# Generated automatically by config.status (libbacktrace) version-unused
|
# Generated automatically by config.status (libbacktrace) version-unused
|
||||||
# Libtool was configured on host fv-az272-316:
|
# Libtool was configured on host fv-az190-599:
|
||||||
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
|
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
|
||||||
#
|
#
|
||||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
|
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
|
||||||
|
@ -64,6 +64,18 @@ type
|
|||||||
desc: "Enable message persistence: true|false",
|
desc: "Enable message persistence: true|false",
|
||||||
defaultValue: false
|
defaultValue: false
|
||||||
name: "persist-messages" }: bool
|
name: "persist-messages" }: bool
|
||||||
|
|
||||||
|
## DNS addrs config
|
||||||
|
|
||||||
|
dnsAddrs* {.
|
||||||
|
desc: "Enable resolution of `dnsaddr`, `dns4` or `dns6` multiaddrs"
|
||||||
|
defaultValue: true
|
||||||
|
name: "dns-addrs" }: bool
|
||||||
|
|
||||||
|
dnsAddrsNameServers* {.
|
||||||
|
desc: "DNS name server IPs to query for DNS multiaddrs resolution. Argument may be repeated."
|
||||||
|
defaultValue: @[ValidIpAddress.init("1.1.1.1"), ValidIpAddress.init("1.0.0.1")]
|
||||||
|
name: "dns-addrs-name-server" }: seq[ValidIpAddress]
|
||||||
|
|
||||||
## Relay config
|
## Relay config
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import
|
|||||||
libp2p/crypto/crypto,
|
libp2p/crypto/crypto,
|
||||||
libp2p/protocols/ping,
|
libp2p/protocols/ping,
|
||||||
libp2p/protocols/pubsub/[gossipsub, rpc/messages],
|
libp2p/protocols/pubsub/[gossipsub, rpc/messages],
|
||||||
libp2p/nameresolving/dnsresolver,
|
libp2p/nameresolving/nameresolver,
|
||||||
libp2p/[builders, multihash],
|
libp2p/[builders, multihash],
|
||||||
libp2p/transports/[transport, tcptransport, wstransport],
|
libp2p/transports/[transport, tcptransport, wstransport],
|
||||||
../protocol/[waku_relay, waku_message],
|
../protocol/[waku_relay, waku_message],
|
||||||
@ -159,7 +159,8 @@ proc new*(T: type WakuNode, nodeKey: crypto.PrivateKey,
|
|||||||
wssEnabled: bool = false,
|
wssEnabled: bool = false,
|
||||||
secureKey: string = "",
|
secureKey: string = "",
|
||||||
secureCert: string = "",
|
secureCert: string = "",
|
||||||
wakuFlags = none(WakuEnrBitfield)
|
wakuFlags = none(WakuEnrBitfield),
|
||||||
|
nameResolver: NameResolver = nil,
|
||||||
): T
|
): T
|
||||||
{.raises: [Defect, LPError, IOError, TLSStreamProtocolError].} =
|
{.raises: [Defect, LPError, IOError, TLSStreamProtocolError].} =
|
||||||
## Creates a Waku Node.
|
## Creates a Waku Node.
|
||||||
@ -218,7 +219,8 @@ proc new*(T: type WakuNode, nodeKey: crypto.PrivateKey,
|
|||||||
maxConnections = maxConnections,
|
maxConnections = maxConnections,
|
||||||
wssEnabled = wssEnabled,
|
wssEnabled = wssEnabled,
|
||||||
secureKeyPath = secureKey,
|
secureKeyPath = secureKey,
|
||||||
secureCertPath = secureCert)
|
secureCertPath = secureCert,
|
||||||
|
nameResolver = nameResolver)
|
||||||
|
|
||||||
let wakuNode = WakuNode(
|
let wakuNode = WakuNode(
|
||||||
peerManager: PeerManager.new(switch, peerStorage),
|
peerManager: PeerManager.new(switch, peerStorage),
|
||||||
@ -926,6 +928,7 @@ when isMainModule:
|
|||||||
import
|
import
|
||||||
confutils,
|
confutils,
|
||||||
system/ansi_c,
|
system/ansi_c,
|
||||||
|
libp2p/nameresolving/dnsresolver,
|
||||||
../../common/utils/nat,
|
../../common/utils/nat,
|
||||||
./config,
|
./config,
|
||||||
./waku_setup,
|
./waku_setup,
|
||||||
@ -997,7 +1000,15 @@ when isMainModule:
|
|||||||
## file. Optionally include persistent peer storage.
|
## file. Optionally include persistent peer storage.
|
||||||
## No protocols are mounted yet.
|
## No protocols are mounted yet.
|
||||||
|
|
||||||
|
var dnsResolver: DnsResolver
|
||||||
|
if conf.dnsAddrs:
|
||||||
|
# Support for DNS multiaddrs
|
||||||
|
var nameServers: seq[TransportAddress]
|
||||||
|
for ip in conf.dnsAddrsNameServers:
|
||||||
|
nameServers.add(initTAddress(ip, Port(53))) # Assume all servers use port 53
|
||||||
|
|
||||||
|
dnsResolver = DnsResolver.new(nameServers)
|
||||||
|
|
||||||
let
|
let
|
||||||
## `udpPort` is only supplied to satisfy underlying APIs but is not
|
## `udpPort` is only supplied to satisfy underlying APIs but is not
|
||||||
## actually a supported transport for libp2p traffic.
|
## actually a supported transport for libp2p traffic.
|
||||||
@ -1020,17 +1031,18 @@ when isMainModule:
|
|||||||
conf.relay)
|
conf.relay)
|
||||||
|
|
||||||
node = WakuNode.new(conf.nodekey,
|
node = WakuNode.new(conf.nodekey,
|
||||||
conf.listenAddress, Port(uint16(conf.tcpPort) + conf.portsShift),
|
conf.listenAddress, Port(uint16(conf.tcpPort) + conf.portsShift),
|
||||||
extIp, extPort,
|
extIp, extPort,
|
||||||
pStorage,
|
pStorage,
|
||||||
conf.maxConnections.int,
|
conf.maxConnections.int,
|
||||||
Port(uint16(conf.websocketPort) + conf.portsShift),
|
Port(uint16(conf.websocketPort) + conf.portsShift),
|
||||||
conf.websocketSupport,
|
conf.websocketSupport,
|
||||||
conf.websocketSecureSupport,
|
conf.websocketSecureSupport,
|
||||||
conf.websocketSecureKeyPath,
|
conf.websocketSecureKeyPath,
|
||||||
conf.websocketSecureCertPath,
|
conf.websocketSecureCertPath,
|
||||||
some(wakuFlags)
|
some(wakuFlags),
|
||||||
)
|
dnsResolver
|
||||||
|
)
|
||||||
|
|
||||||
if conf.discv5Discovery:
|
if conf.discv5Discovery:
|
||||||
let discv5UdpPort = Port(uint16(conf.discv5UdpPort) + conf.portsShift)
|
let discv5UdpPort = Port(uint16(conf.discv5UdpPort) + conf.portsShift)
|
||||||
|
@ -69,13 +69,13 @@ proc parseRemotePeerInfo*(address: string): RemotePeerInfo {.raises: [Defect, Va
|
|||||||
let multiAddr = MultiAddress.init(address).tryGet()
|
let multiAddr = MultiAddress.init(address).tryGet()
|
||||||
|
|
||||||
var
|
var
|
||||||
|
nwPart, tcpPart, p2pPart, wsPart, wssPart: MultiAddress
|
||||||
ipPart, tcpPart, p2pPart, wsPart, wssPart: MultiAddress
|
|
||||||
|
|
||||||
for addrPart in multiAddr.items():
|
for addrPart in multiAddr.items():
|
||||||
case addrPart[].protoName()[]
|
case addrPart[].protoName()[]
|
||||||
of "ip4", "ip6":
|
# All protocols listed here: https://github.com/multiformats/multiaddr/blob/b746a7d014e825221cc3aea6e57a92d78419990f/protocols.csv
|
||||||
ipPart = addrPart.tryGet()
|
of "ip4", "ip6", "dns", "dnsaddr", "dns4", "dns6":
|
||||||
|
nwPart = addrPart.tryGet()
|
||||||
of "tcp":
|
of "tcp":
|
||||||
tcpPart = addrPart.tryGet()
|
tcpPart = addrPart.tryGet()
|
||||||
of "p2p":
|
of "p2p":
|
||||||
@ -89,7 +89,7 @@ proc parseRemotePeerInfo*(address: string): RemotePeerInfo {.raises: [Defect, Va
|
|||||||
let
|
let
|
||||||
peerIdStr = p2pPart.toString()[].split("/")[^1]
|
peerIdStr = p2pPart.toString()[].split("/")[^1]
|
||||||
|
|
||||||
wireAddr = ipPart & tcpPart & wsPart & wssPart
|
wireAddr = nwPart & tcpPart & wsPart & wssPart
|
||||||
if (not wireAddr.validWireAddr()):
|
if (not wireAddr.validWireAddr()):
|
||||||
raise newException(ValueError, "Invalid node multi-address")
|
raise newException(ValueError, "Invalid node multi-address")
|
||||||
|
|
||||||
|
@ -45,8 +45,6 @@ proc withWssTransport*(b: SwitchBuilder,
|
|||||||
tlsCertificate = cert,
|
tlsCertificate = cert,
|
||||||
{TLSFlags.NoVerifyHost, TLSFlags.NoVerifyServerName}))
|
{TLSFlags.NoVerifyHost, TLSFlags.NoVerifyServerName}))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
proc newWakuSwitch*(
|
proc newWakuSwitch*(
|
||||||
privKey = none(crypto.PrivateKey),
|
privKey = none(crypto.PrivateKey),
|
||||||
address = MultiAddress.init("/ip4/127.0.0.1/tcp/0").tryGet(),
|
address = MultiAddress.init("/ip4/127.0.0.1/tcp/0").tryGet(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user