Skip to content

Commit

Permalink
chore(wakucanary): update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
alrevuelta committed Oct 6, 2022
1 parent 00cf72e commit 445c7b3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
26 changes: 22 additions & 4 deletions tools/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
## waku canary tool

TODO: Attempt to dial a node at a given listening address
Attempts to dial a peer and asserts it supports a given set of protocols.

```console
The following options are available:

--address Multiaddress of the peer node to attemp to dial.
--timeout Timeout to consider that the connection failed [=chronos.seconds(10)].
--protocol Protocol required to be supported: store,static,lightpush,filter (can be used
multiple times).
```

The tool can be built as:

```console
$ make wakucanary
```

TODO:
And used as follows. A reachable node that supports both `store` and `filter` protocols.


```console
$ ./build/wakucanary --address=/ip4/8.210.222.231/tcp/30303/p2p/16Uiu2HAm4v86W3bmT1BiH6oSPzcsSr24iDQpSN5Qa992BCjjwgrD --protocol=store --protocol=filter
$ echo $?
0
```

A node that can't be reached.
```console
./build/wakucanary --staticnode:<multiaddr_to_test>
./build/wakucanary --storenode:<multiaddr_to_test>
$ ./build/wakucanary --address=/ip4/8.210.222.231/tcp/1000/p2p/16Uiu2HAm4v86W3bmT1BiH6oSPzcsSr24iDQpSN5Qa992BCjjwgrD --protocol=store --protocol=filter
$ echo $?
1
```
12 changes: 5 additions & 7 deletions tools/wakucanary/wakucanary.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import
../../waku/v2/utils/peers

# protocols and their tag
const protocolsTable = {
const ProtocolsTable = {
"store": "/vac/waku/store/",
"static": "/vac/waku/relay/",
"lightpush": "/vac/waku/lightpush/",
Expand All @@ -35,7 +35,7 @@ type
name: "timeout" }: chronos.Duration

protocols* {.
desc: "Protocol required to be supported (can be used multiple times)"
desc: "Protocol required to be supported: store,static,lightpush,filter (can be used multiple times)"
name: "protocol" }: seq[string]

proc parseCmdArg*(T: type chronos.Duration, p: TaintedString): T =
Expand All @@ -56,7 +56,7 @@ proc areProtocolsSupported(

for nodeProtocol in nodeProtocols:
for rawProtocol in rawProtocols:
let protocolTag = protocolsTable[rawProtocol]
let protocolTag = ProtocolsTable[rawProtocol]
if nodeProtocol.startsWith(protocolTag):
info "Supported protocol ok:", expected=protocolTag, supported=nodeProtocol
numOfSupportedProt += 1
Expand All @@ -72,10 +72,8 @@ proc main(): Future[int] {.async.} =

# ensure input protocols are valid
for p in conf.protocols:
if p notin protocolsTable:
# TODO: this raises SIGBUS: Illegal storage access
#error "invalid protocol:", protocol=p, valid=toSeq(protocolsTable.keys())
error "invalid protocol:", protocol=p, valid=protocolsTable
if p notin ProtocolsTable:
error "invalid protocol:", protocol=p, valid=ProtocolsTable
raise newException(ConfigurationError, "Invalid cli flag values: " & p)

info "Cli flags:",
Expand Down

0 comments on commit 445c7b3

Please sign in to comment.