Skip to content

Commit b32e33a

Browse files
committed
chore: update docs
1 parent 30546be commit b32e33a

File tree

2 files changed

+57
-23
lines changed

2 files changed

+57
-23
lines changed

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,15 @@ Make sure you have installed all of the following prerequisites on your developm
7474

7575
## Documentation
7676

77-
- [IPFS Primer](https://dweb-primer.ipfs.io/)
78-
- [IPFS Docs](https://docs.ipfs.io/)
79-
- [Tutorials](https://proto.school)
80-
- [More examples](https://github.com/libp2p/js-libp2p-examples)
81-
- [API - Helia](https://ipfs.github.io/helia/modules/helia.html)
82-
- [API - @helia/unixfs](https://ipfs.github.io/helia-unixfs/modules/helia.html)
77+
- [js-libp2p docs](https://github.com/libp2p/js-libp2p/tree/master/doc)
78+
- [libp2p.io](https://libp2p.io)
79+
- [docs.libp2p.io](https://docs.libp2p.io)
80+
- [Specification (WIP)](https://github.com/libp2p/specs)
81+
- [Discussion Forums](https://discuss.libp2p.io)
82+
- Talks
83+
- [`libp2p <3 ethereum` at DEVCON2](https://archive.devcon.org/archive/watch/2/libp2p-devp2p-ipfs-and-ethereum-networking/)
84+
- Articles
85+
- [The overview of libp2p](https://github.com/libp2p/libp2p#description)
8386

8487
## Contribute
8588

examples/js-libp2p-example-circuit-relay/README.md

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# @libp2p/example-auto-relay <!-- omit in toc -->
1+
# @libp2p/example-circuit-relay <!-- omit in toc -->
22

33
[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
44
[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
@@ -19,15 +19,24 @@
1919

2020
## 0. Setup the example
2121

22-
Before moving into the examples, you should run `npm install` and `npm run build` on the top level `js-libp2p` folder, in order to install all the dependencies needed for this example. Once the install finishes, you should move into the example folder with `cd examples/auto-relay`.
22+
First of all run `npm install` in the example folder. This will install all
23+
required dependencies and you'll be ready to go.
2324

24-
This example comes with 3 main files. A `relay.js` file to be used in the first step, a `listener.js` file to be used in the second step and a `dialer.js` file to be used on the third step. All of these scripts will run their own libp2p node, which will interact with the previous ones. All nodes must be running in order for you to proceed.
25+
This example comes with 3 main files. A `relay.js` file to be used in the first
26+
step, a `listener.js` file to be used in the second step and a `dialer.js` file
27+
to be used on the third step. All of these scripts will run their own libp2p
28+
node, which will interact with the previous ones. All nodes must be running in
29+
order for you to proceed.
2530

2631
## 1. Set up a relay node
2732

28-
In the first step of this example, we need to configure and run a relay node in order for our target node to bind to for accepting inbound connections.
33+
In the first step of this example, we need to configure and run a relay node in
34+
order for our target node to bind to for accepting inbound connections.
2935

30-
The relay node will need to have its relay subsystem enabled, as well as its HOP capability. It can be configured as follows:
36+
The relay node will need to have a relay service added which will allow a
37+
limited number of remote peers to make relay reservations with it.
38+
39+
It can be configured as follows:
3140

3241
```js
3342
import { noise } from '@chainsafe/libp2p-noise'
@@ -80,9 +89,11 @@ Listening on:
8089

8190
## 2. Set up a listener node with `discoverRelays` Enabled
8291

83-
One of the typical use cases for Circuit Relay is nodes behind a NAT or browser nodes due to their inability to expose a public address.
92+
One of the typical use cases for Circuit Relay is nodes behind a NAT or browser
93+
nodes due to their inability to expose a public address.
8494

85-
For running a libp2p node that automatically discovers available relays, you can see the following:
95+
For running a libp2p node that automatically discovers available relays, you can
96+
see the following:
8697

8798
```js
8899
import { noise } from '@chainsafe/libp2p-noise'
@@ -129,7 +140,9 @@ node.addEventListener('self:peer:update', (evt) => {
129140
})
130141
```
131142

132-
As you can see in the code, we need to provide the relay address, `relayAddr`, as a process argument. This node will dial the provided relay address and automatically bind to it.
143+
As you can see in the code, we need to provide the relay address, `relayAddr`,
144+
as a process argument. This node will dial the provided relay address and
145+
automatically bind to it.
133146

134147
You should now run the following to start the node running Auto Relay:
135148

@@ -145,13 +158,19 @@ Connected to the HOP relay QmWDn2LY8nannvSWJzruUYoLZ4vV83vfCBwd8DipvdgQc3
145158
Advertising with a relay address of /ip4/192.168.1.120/tcp/61592/ws/p2p/QmWDn2LY8nannvSWJzruUYoLZ4vV83vfCBwd8DipvdgQc3/p2p-circuit/p2p/QmerrWofKF358JE6gv3z74cEAyL7z1KqhuUoVfGEynqjRm
146159
```
147160

148-
Per the address, it is possible to verify that the auto relay node is listening on the circuit relay node address.
161+
Per the address, it is possible to verify that the auto relay node is listening
162+
on the circuit relay node address.
149163

150-
Instead of dialing this relay manually, you could set up this node with the Bootstrap module and provide it in the bootstrap list. Moreover, you can use other `peer-discovery` modules to discover peers in the network and the node will automatically bind to the relays that support HOP until reaching the maximum number of listeners.
164+
Instead of dialing this relay manually, you could set up this node with the
165+
Bootstrap module and provide it in the bootstrap list. Moreover, you can use
166+
other `peer-discovery` modules to discover peers in the network and the node
167+
will automatically bind to the relays that support HOP until reaching the
168+
maximum number of listeners.
151169

152170
## 3. Set up a dialer node for testing connectivity
153171

154-
Now that you have a relay node and a node bound to that relay, you can test connecting to the auto relay node via the relay.
172+
Now that you have a relay node and a node bound to that relay, you can test
173+
connecting to the auto relay node via the relay.
155174

156175
```js
157176
import { createLibp2p } from 'libp2p'
@@ -177,26 +196,36 @@ const conn = await node.dial(autoRelayNodeAddr)
177196
console.log(`Connected to the auto relay node via ${conn.remoteAddr.toString()}`)
178197
```
179198

180-
You should now run the following to start the relay node using the listen address from step 2:
199+
You should now run the following to start the relay node using the listen
200+
address from step 2:
181201

182202
```sh
183203
node dialer.js /ip4/192.168.1.120/tcp/61592/ws/p2p/QmWDn2LY8nannvSWJzruUYoLZ4vV83vfCBwd8DipvdgQc3
184204
```
185205

186-
Once you start your test node, it should print out something similar to the following:
206+
Once you start your test node, it should print out something similar to the
207+
following:
187208

188209
```sh
189210
Node started: Qme7iEzDxFoFhhkrsrkHkMnM11aPYjysaehP4NZeUfVMKG
190211
Connected to the auto relay node via /ip4/192.168.1.120/tcp/61592/ws/p2p/QmWDn2LY8nannvSWJzruUYoLZ4vV83vfCBwd8DipvdgQc3/p2p-circuit/p2p/QmerrWofKF358JE6gv3z74cEAyL7z1KqhuUoVfGEynqjRm
191212
```
192213

193-
As you can see from the output, the remote address of the established connection uses the relayed connection.
214+
As you can see from the output, the remote address of the established connection
215+
uses the relayed connection.
194216

195217
## 4. What is next?
196218

197-
Before moving into production, there are a few things that you should take into account.
219+
Before moving into production, there are a few things that you should take into
220+
account.
198221

199-
A relay node should not advertise its private address in a real world scenario, as the node would not be reachable by others. You should provide an array of public addresses in the libp2p `addresses.announce` option. If you are using websockets, bear in mind that due to browser’s security policies you cannot establish unencrypted connection from secure context. The simplest solution is to setup SSL with nginx and proxy to the node and setup a domain name for the certificate.
222+
A relay node should not advertise its private address in a real world scenario,
223+
as the node would not be reachable by others. You should provide an array of
224+
public addresses in the libp2p `addresses.announce` option. If you are using
225+
websockets, bear in mind that due to browser’s security policies you cannot
226+
establish unencrypted connection from secure context. The simplest solution is
227+
to setup SSL with nginx and proxy to the node and setup a domain name for the
228+
certificate.
200229

201230
## License
202231

@@ -207,4 +236,6 @@ Licensed under either of
207236

208237
## Contribution
209238

210-
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
239+
Unless you explicitly state otherwise, any contribution intentionally submitted
240+
for inclusion in the work by you, as defined in the Apache-2.0 license, shall
241+
be dual licensed as above, without any additional terms or conditions.

0 commit comments

Comments
 (0)