chore(wakucanary): resolve dns (#1271)

This commit is contained in:
Alvaro Revuelta 2022-10-18 10:13:42 -05:00 committed by GitHub
parent 5046a4b3da
commit d5acb6aab2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -36,4 +36,11 @@ A node that can't be reached.
$ ./build/wakucanary --address=/ip4/8.210.222.231/tcp/1000/p2p/16Uiu2HAm4v86W3bmT1BiH6oSPzcsSr24iDQpSN5Qa992BCjjwgrD --protocol=store --protocol=filter
$ echo $?
1
```
Note that a domain name can also be used.
```console
$ ./build/wakucanary --address=/dns4/node-01.do-ams3.status.test.statusim.net/tcp/30303/p2p/16Uiu2HAkukebeXjTQ9QDBeNDWuGfbaSg79wkkhK4vPocLgR6QFDf --protocol=store --protocol=filter
$ echo $?
0
```

View File

@ -6,7 +6,9 @@ import
chronicles/topics_registry
import
libp2p/protocols/ping,
libp2p/crypto/[crypto, secp]
libp2p/crypto/[crypto, secp],
libp2p/nameresolving/nameresolver,
libp2p/nameresolving/dnsresolver
import
../../waku/v2/node/peer_manager/peer_manager,
../../waku/v2/utils/peers,
@ -81,6 +83,13 @@ proc areProtocolsSupported(
proc main(): Future[int] {.async.} =
let conf: WakuCanaryConf = WakuCanaryConf.load()
# create dns resolver
let
nameServers = @[
initTAddress(ValidIpAddress.init("1.1.1.1"), Port(53)),
initTAddress(ValidIpAddress.init("1.0.0.1"), Port(53))]
resolver: DnsResolver = DnsResolver.new(nameServers)
if conf.logLevel != LogLevel.NONE:
setLogLevel(conf.logLevel)
@ -103,7 +112,8 @@ proc main(): Future[int] {.async.} =
node = WakuNode.new(
nodeKey,
ValidIpAddress.init("0.0.0.0"),
Port(60000))
Port(60000),
nameResolver = resolver)
await node.start()