From ae634095efd1b3dc5bcb4c512a293604812e1461 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Fri, 4 Dec 2020 13:56:41 +0100 Subject: [PATCH] chore: apply suggestions from code review Co-authored-by: Jacob Heun --- README.md | 15 ++++++++------- test/index.spec.js | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 908574c..cbe649a 100644 --- a/README.md +++ b/README.md @@ -54,22 +54,23 @@ After installing the relay server, you can use its binary. It accepts several ar libp2p-relay-server [--peerId ] [--listenMultiaddrs ... ] [--announceMultiaddrs ... ] [--metricsMultiaddr ] [--disableMetrics] [--disablePubsubDiscovery] ``` -The main configuration you should focus are the `PeerId` and the `Multiaddrs`, which are detailed next. +The main configuration you *should* include are the `PeerId` and `Multiaddrs`, which are detailed next. Using a consistent PeerId will ensure your node's identity is consistent across restarts, and the Multiaddrs will allow you to appropriate bind your local and external addresses so that other peers can connect to you. #### PeerId You can create a [PeerId](https://github.com/libp2p/js-peer-id) via its [CLI](https://github.com/libp2p/js-peer-id#cli). +Once you have a generated PeerId json file, you can start the relay with that PeerId by specifying its path via the `--peerId` flag: ```sh -libp2p-relay-server --peerId id.json +libp2p-relay-server --peerId /path/to/peer-id.json ``` #### Multiaddrs -You can specify the libp2p rendezvous server listen and announce multiaddrs. This server is configured with [libp2p-tcp](https://github.com/libp2p/js-libp2p-tcp) and [libp2p-websockets](https://github.com/libp2p/js-libp2p-websockets) and addresses with this transports should be used. It can always be modified via the API. +You can specify the libp2p rendezvous server listen and announce multiaddrs. This server is configured with [libp2p-tcp](https://github.com/libp2p/js-libp2p-tcp) and [libp2p-websockets](https://github.com/libp2p/js-libp2p-websockets), so you will only be able to specify addresses for these transports. ```sh -libp2p-relay-server --peerId id.json --listenMultiaddrs '/ip4/127.0.0.1/tcp/15002/ws' '/ip4/127.0.0.1/tcp/8000' --announceMultiaddrs '/dns4/test.io/tcp/443/wss/p2p/12D3KooWAuEpJKhCAfNcHycKcZCv9Qy69utLAJ3MobjKpsoKbrGA' '/dns6/test.io/tcp/443/wss/p2p/12D3KooWAuEpJKhCAfNcHycKcZCv9Qy69utLAJ3MobjKpsoKbrGA' +libp2p-relay-server --peerId /path/to/peer-id.json --listenMultiaddrs '/ip4/127.0.0.1/tcp/15002/ws' '/ip4/127.0.0.1/tcp/8000' --announceMultiaddrs '/dns4/test.io/tcp' '/dns4/test.io/tcp/443/wss' ``` By default it listens on `/ip4/127.0.0.1/tcp/15003/ws` and has no announce multiaddrs specified. @@ -81,7 +82,7 @@ When running the relay server in Docker, you can configure the same parameters v ```sh PEER_ID='./id.json' LISTEN_MULTIADDRS='/ip4/127.0.0.1/tcp/15002/ws,/ip4/127.0.0.1/tcp/8000' -ANNOUNCE_MULTIADDRS='/dns4/test.io/tcp/443/wss/p2p/12D3KooWAuEpJKhCAfNcHycKcZCv9Qy69utLAJ3MobjKpsoKbrGA,/dns6/test.io/tcp/443/wss/p2p/12D3KooWAuEpJKhCAfNcHycKcZCv9Qy69utLAJ3MobjKpsoKbrGA' +ANNOUNCE_MULTIADDRS='/dns4/test.io/tcp/443/wss,/dns6/test.io/tcp/443/wss' ``` Please note that you should expose expose the used ports with the docker run command. The default ports used are `8003` for the metrics and `150003` for the websockets listener. @@ -135,7 +136,7 @@ DISABLE_METRICS='true' DISABLE_PUBSUB_DISCOVERY='true' ``` -Please note that you should expose expose the used ports with the docker run command. The default ports used are `8003` for the metrics and `150003` for the websockets listener. +Please note that you should expose the used ports with the docker run command. The default ports used are `8003` for the metrics and `150003` for the websockets listener. Example: @@ -146,7 +147,7 @@ docker run -p 8003:8003 -p 15002:15002 -p 8000:8000 -e LISTEN_MULTIADDRS='/ip4/1 ### Debug -You can debug the relay by setting the `DEBUG` environment variable. For instance, you can set it to `libp2p*`. +You can debug the relay by setting the `DEBUG` environment variable. For instance, you can set it to `libp2p*`. These logs can be noisy so you may wish to tune the namespaces that are logging, see the [Debug module](https://github.com/visionmedia/debug) for detailed usage. ## Contribute diff --git a/test/index.spec.js b/test/index.spec.js index a9e1eae..5a1c176 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -41,7 +41,7 @@ describe('Relay Server', () => { }) it('can specify announceMultiaddrs for the relay', async () => { - const announceAddresses = ['/dns4/test.io/tcp/443/wss/p2p/12D3KooWAuEpJKhCAfNcHycKcZCv9Qy69utLAJ3MobjKpsoKbrGA'] + const announceAddresses = ['/dns4/test.io/tcp/443/wss'] relay = await createRelayServer({ peerId,