Skip to content

Commit 7f60b57

Browse files
p-shahiachingbrainmaschad
authored
docs: add archive notice to webrtc star and direct (#1488)
* chore: add archive notice to webrtc star and direct * remove refs to star and direct * docs: archive removal of webrtc-star and webrtc-direct * wip * wip * docs: update config readme * chore: move examples to libp2p-in-the-browser * chore: update links --------- Co-authored-by: Alex Potsides <alex@achingbrain.net> Co-authored-by: chad <chad.nehemiah94@gmail.com>
1 parent 69c93ac commit 7f60b57

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+55
-116
lines changed

doc/CONFIGURATION.md

+32-76
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
- [Examples](#examples)
1616
- [Basic setup](#basic-setup)
1717
- [Customizing Peer Discovery](#customizing-peer-discovery)
18-
- [Setup webrtc transport and discovery](#setup-webrtc-transport-and-discovery)
1918
- [Customizing Pubsub](#customizing-pubsub)
2019
- [Customizing DHT](#customizing-dht)
2120
- [Setup with Content and Peer Routing](#setup-with-content-and-peer-routing)
@@ -70,10 +69,10 @@ Bear in mind that a **transport** and **connection encryption** module are **req
7069
7170
Some available transports are:
7271

73-
- [@libp2p/tcp](https://github.com/libp2p/js-libp2p-tcp) (not available in browsers)
74-
- [@libp2p/webrtc](https://github.com/libp2p/js-libp2p-webrtc)
75-
- [@libp2p/websockets](https://github.com/libp2p/js-libp2p-websockets)
76-
- [@libp2p/webtransport](https://github.com/libp2p/js-libp2p-webtransport) (Work in Progress)
72+
- [@libp2p/tcp](https://github.com/libp2p/tree/master/packages/transport-tcp) (not available in browsers)
73+
- [@libp2p/webrtc](https://github.com/libp2p/js-libp2p/tree/master/packages/transport-webrtc)
74+
- [@libp2p/websockets](https://github.com/libp2p/js-libp2p/tree/master/packages/transport-websockets)
75+
- [@libp2p/webtransport](https://github.com/libp2p/js-libp2p/tree/master/packages/transport-webtransport)
7776

7877
If none of the available transports fulfils your needs, you can create a libp2p compatible transport. A libp2p transport just needs to be compliant with the [Transport Interface](https://github.com/libp2p/js-interfaces/tree/master/src/transport).
7978

@@ -88,7 +87,7 @@ If you want to know more about libp2p transports, you should read the following
8887
8988
Some available stream multiplexers are:
9089

91-
- [@libp2p/mplex](https://github.com/libp2p/js-libp2p-mplex)
90+
- [@libp2p/mplex](https://github.com/libp2p/js-libp2p/tree/master/packages/stream-multiplexer-mplex)
9291
- [@chainsafe/libp2p-yamux](https://github.com/chainsafe/js-libp2p-yamux)
9392

9493
Some transports such as WebRTC and WebTransport come with their own built-in stream multiplexing capabilities.
@@ -127,14 +126,11 @@ If you want to know more about libp2p connection encryption, you should read the
127126
128127
Some available peer discovery modules are:
129128

130-
- [@libp2p/mdns](https://github.com/libp2p/js-libp2p-mdns)
131-
- [@libp2p/bootstrap](https://github.com/libp2p/js-libp2p-bootstrap)
132-
- [@libp2p/kad-dht](https://github.com/libp2p/js-libp2p-kad-dht)
133-
- [@libp2p/webrtc-star](https://github.com/libp2p/js-libp2p-webrtc-star)
129+
- [@libp2p/mdns](https://github.com/libp2p/js-libp2ptree/master/packages/peer-discovery-mdns)
130+
- [@libp2p/bootstrap](https://github.com/libp2p/js-libp2p/tree/master/packages/peer-discovery-bootstrap)
131+
- [@libp2p/kad-dht](https://github.com/libp2p/js-libp2p/tree/master/packages/kad-dht)
134132
- [@chainsafe/discv5](https://github.com/chainsafe/discv5)
135133

136-
**Note**: `peer-discovery` services within transports (such as `js-libp2p-webrtc-star`) are automatically gathered from the `transport`, via it's `discovery` property. As such, they do not need to be added in the discovery modules. However, these transports can also be configured and disabled as the other ones.
137-
138134
If none of the available peer discovery protocols fulfills your needs, you can create a libp2p compatible one. A libp2p peer discovery protocol just needs to be compliant with the [Peer Discovery Interface](https://github.com/libp2p/js-interfaces/tree/master/src/peer-discovery).
139135

140136
If you want to know more about libp2p peer discovery, you should read the following content:
@@ -147,7 +143,7 @@ If you want to know more about libp2p peer discovery, you should read the follow
147143
148144
Some available content routing modules are:
149145

150-
- [@libp2p/kad-dht](https://github.com/libp2p/js-libp2p-kad-dht)
146+
- [@libp2p/kad-dht](https://github.com/libp2p/js-libp2p/tree/master/packages/kad-dht)
151147
- [@libp2p/delegated-content-routing](https://github.com/libp2p/js-libp2p-delegated-content-routing)
152148
- [@libp2p/ipni-content-routing](https://github.com/libp2p/js-ipni-content-routing)
153149

@@ -163,7 +159,7 @@ If you want to know more about libp2p content routing, you should read the follo
163159
164160
Some available peer routing modules are:
165161

166-
- [@libp2p/kad-dht](https://github.com/libp2p/js-libp2p-kad-dht)
162+
- [@libp2p/kad-dht](https://github.com/libp2p/js-libp2p/tree/master/packages/kad-dht)
167163
- [@libp2p/delegated-peer-routing](https://github.com/libp2p/js-libp2p-delegated-peer-routing)
168164

169165
If none of the available peer routing protocols fulfills your needs, you can create a libp2p compatible one. A libp2p peer routing protocol just needs to be compliant with the [Peer Routing Interface](https://github.com/libp2p/js-interfaces/tree/master/src/peer-routing). **(WIP: This module is not yet implemented)**
@@ -176,7 +172,7 @@ If you want to know more about libp2p peer routing, you should read the followin
176172

177173
> A DHT can provide content and peer routing capabilities in a p2p system, as well as peer discovery capabilities.
178174
179-
The DHT implementation currently available is [@libp2p/kad-dht](https://github.com/libp2p/js-libp2p-kad-dht). This implementation is largely based on the Kademlia whitepaper, augmented with notions from S/Kademlia, Coral and mainlineDHT.
175+
The DHT implementation currently available is [@libp2p/kad-dht](https://github.com/libp2p/js-libp2p/tree/master/packages/kad-dht). This implementation is largely based on the Kademlia whitepaper, augmented with notions from S/Kademlia, Coral and mainlineDHT.
180176

181177
If this DHT implementation does not fulfill your needs and you want to create or use your own implementation, please get in touch with us through a github issue. We plan to work on improving the ability to bring your own DHT in a future release.
182178

@@ -301,36 +297,6 @@ const node = await createLibp2p({
301297
})
302298
```
303299

304-
#### Setup webrtc transport and discovery
305-
306-
```js
307-
import { createLibp2p } from 'libp2p'
308-
import { webSockets } from '@libp2p/websockets'
309-
import { webRTCStar } from '@libp2p/webrtc-star'
310-
import { mplex } from '@libp2p/mplex'
311-
import { yamux } from '@chainsafe/libp2p-yamux'
312-
import { noise } from '@chainsafe/libp2p-noise'
313-
314-
const webRtc = webRTCStar()
315-
316-
const node = await createLibp2p({
317-
transports: [
318-
webSockets(),
319-
webRtc.transport
320-
],
321-
peerDiscovery: [
322-
webRtc.discovery
323-
],
324-
streamMuxers: [
325-
yamux(),
326-
mplex()
327-
],
328-
connectionEncryption: [
329-
noise()
330-
]
331-
})
332-
```
333-
334300
#### Customizing Pubsub
335301

336302
Before a peer can subscribe to a topic it must find other peers and establish network connections with them. The pub/sub system doesn’t have any way to discover peers by itself. Instead, it relies upon the application to find new peers on its behalf, a process called ambient peer discovery.
@@ -898,66 +864,56 @@ const node = await createLibp2p({
898864

899865
#### Customizing Transports
900866

901-
Some Transports can be passed additional options when they are created. For example, `libp2p-webrtc-star` accepts an optional, custom `wrtc` implementation. In addition to libp2p passing itself and an `Upgrader` to handle connection upgrading, libp2p will also pass the options, if they are provided, from `config.transport`.
867+
Some Transports can be passed additional options when they are created. For example, [webRTC](../packages/transport-webrtc) accepts optional [DataChannel Options](https://github.com/libp2p/js-libp2p/blob/master/packages/transport-webrtc/src/stream.ts#L13-L17). In addition to libp2p passing itself and an `Upgrader` to handle connection upgrading, libp2p will also pass the options, if they are provided, from `config.transport`.
902868

903869
```js
904870
import { createLibp2p } from 'libp2p'
905-
import { webRTCStar } from '@libp2p/webrtc-star'
906-
import { mplex } from '@libp2p/mplex'
907871
import { yamux } from '@chainsafe/libp2p-yamux'
908872
import { noise } from '@chainsafe/libp2p-noise'
909-
import wrtc from 'wrtc'
873+
import { webRTC } from '@libp2p/webrtc'
910874

911-
const webRTC = webRTCStar({
912-
wrtc
913-
})
914875

915876
const node = await createLibp2p({
916877
transports: [
917-
webRTC.transport
918-
],
919-
peerDiscovery: [
920-
webRTC.discovery
878+
webRTC({
879+
dataChannel: {
880+
maxMessageSize: 10
881+
}
882+
})
921883
],
922884
streamMuxers: [
923-
yamux(),
924-
mplex()
885+
yamux()
925886
],
926887
connectionEncryption: [
927888
noise()
928889
]
929890
})
930891
```
931892

932-
During Libp2p startup, transport listeners will be created for the configured listen multiaddrs. Some transports support custom listener options and you can set them using the `listenerOptions` in the transport configuration. For example, [libp2p-webrtc-star](https://github.com/libp2p/js-libp2p-webrtc-star) transport listener supports the configuration of its underlying [simple-peer](https://github.com/feross/simple-peer) ice server(STUN/TURN) config as follows:
893+
During Libp2p startup, transport listeners will be created for the configured listen multiaddrs. Some transports support custom listener options and you can set them using the `listenerOptions` in the transport configuration. For example, [webRTC](../packages/transport-webrtc) transport listener supports the configuration of ice servers (STUN/TURN) config as follows:
933894

934895
```js
935-
const webRTC = webRTCStar({
936-
listenerOptions: {
937-
config: {
938-
iceServers: [
939-
{"urls": ["turn:YOUR.TURN.SERVER:3478"], "username": "YOUR.USER", "credential": "YOUR.PASSWORD"},
940-
{"urls": ["stun:YOUR.STUN.SERVER:3478"], "username": "", "credential": ""}]
941-
}
942-
}
943-
})
944-
945896
const node = await createLibp2p({
946897
transports: [
947-
webRTC.transport
948-
],
949-
peerDiscovery: [
950-
webRTC.discovery
898+
webRTC({
899+
rtcConfiguration: {
900+
iceServers:[{
901+
urls: [
902+
'stun:stun.l.google.com:19302',
903+
'stun:global.stun.twilio.com:3478'
904+
]
905+
}]
906+
}
907+
})
951908
],
952909
streamMuxers: [
953-
yamux(),
954-
mplex()
910+
yamux()
955911
],
956912
connectionEncryption: [
957913
noise()
958914
],
959915
addresses: {
960-
listen: ['/dns4/your-wrtc-star.pub/tcp/443/wss/p2p-webrtc-star'] // your webrtc dns multiaddr
916+
listen: ['/webrtc'] // your webrtc dns multiaddr
961917
}
962918
})
963919
```

doc/GETTING_STARTED.md

-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ For each discovered peer libp2p will emit a `peer:discovery` event which include
197197
Looking at the [available peer discovery](./CONFIGURATION.md#peer-discovery) protocols, there are several options to be considered:
198198
- If you already know the addresses of some other network peers, you should consider using `@libp2p/bootstrap` as this is the easiest way of getting your peer into the network.
199199
- If it is likely that you will have other peers on your local network, `@libp2p/mdns` is a must if you're node is not running in the browser. It allows peers to discover each other when on the same local network.
200-
- If your application is browser based you can use the `@libp2p/webrtc-star` Transport, which includes a rendezvous based peer sharing service.
201200
- A random walk approach can be used via `@libp2p/kad-dht`, to crawl the network and find new peers along the way.
202201

203202
For this guide we will configure `@libp2p/bootstrap` as this is useful for joining the public network.

doc/production/README.md

+12-22
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,36 @@ This guide aims to guide you from using the public infrastructure into setting u
88

99
## Table of Contents
1010

11-
* [Joining the Network](#joining-the-network)
12-
* [Connecting to Nodes with connectivity limitations](#connecting-to-nodes-with-connectivity-limitations)
13-
* [`webrtc-star` servers](#webrtc-star-servers)
14-
* [Circuit Relay](#circuit-relay)
15-
* [Querying the network from the browser](#querying-the-network-from-the-browser)
16-
* [Others](#others)
17-
* [SSL](#ssl)
11+
- [Production](#production)
12+
- [Table of Contents](#table-of-contents)
13+
- [Joining the Network](#joining-the-network)
14+
- [Connecting to Nodes with connectivity limitations](#connecting-to-nodes-with-connectivity-limitations)
15+
- [Querying the network from the browser](#querying-the-network-from-the-browser)
16+
- [Others](#others)
17+
- [SSL](#ssl)
1818

1919
## Joining the Network
2020

2121
Once a libp2p node stars, it will need to connect to a set of peers in order to establish its overlay network.
2222

2323
Currently `js-libp2p` is not the best choice for being a bootstrap node. Its DHT needs to be improved, in order to become an effective server to enable other nodes to properly bootstrap their network.
2424

25-
Setting up a fleet of [`go-libp2p`](https://github.com/libp2p/go-libp2p) nodes is the recommended way to proceed here.
25+
Setting up a fleet of [`go-libp2p`](https://github.com/libp2p/go-libp2p) nodes is the recommended way to proceed here.
2626

2727
## Connecting to Nodes with connectivity limitations
2828

2929
While the libp2p core codebase aims to work in multiple environments, there are some limitations that are not possible to overcome at the time of writing. These limitations include browser nodes, nodes behind NAT, reverse proxies, firewalls, or lack of compatible transports.
3030

31-
In the browser, libp2p supports two transports: `websockets` and `webrtc-star`. Nowadays, browsers do not support listening for connections, but only to dial known addresses. `webrtc-star` servers can be used to enable libp2p nodes to discover other nodes running on the browser and to help them establish a connection.
31+
In the browser, libp2p supports three transports: `WebSockets`, `WebRTC`, and `WebTransport`.
3232

33-
For nodes that cannot be dialed (including browser), circuit relay nodes should be used.
34-
35-
### `webrtc-star` servers
36-
37-
Regarding `webRTC` connections, a set of star servers are needed to act as a rendezvous point, where peers can learn about other peers (`peer-discovery`), as well as exchange their SDP offers (signaling data).
38-
39-
You can read on how to setup your own star servers in [libp2p/js-libp2p-webrtc-star/DEPLOYMENT.md](https://github.com/libp2p/js-libp2p-webrtc-star/blob/master/DEPLOYMENT.md).
40-
41-
It is worth pointing out that with new discovery protocols on the way, as well as support for distributed signaling, the star servers should be deprecated on the long run.
42-
43-
### Circuit Relay
33+
- [WebSockets](https://github.com/libp2p/js-libp2p/tree/master/packages/transport-websockets) is generally used as a full-duplex communication protocol over a single TCP connection, allowing for real-time data transfer between the client and the server.
34+
- [WebRTC](https://github.com/libp2p/js-libp2p/tree/master/packages/transport-webrtc) is primarly geared towards facilitating browser-to-browser connections. It also enables browsers to connect to public server nodes without those server nodes providing a TLS certificate within the browser's trustchain. This differs from the `WebSockets` transport as the browser requires the remote to have a trusted TLS certificate. Please note that webRTC iss currently not supported by [go-libp2p](https://github.com/libp2p/go-libp2p/issues/2009) but this is in development.
35+
- [WebTransport](https://github.com/libp2p/js-libp2p/tree/master/packages/transport-webtransport) is a way for browsers to establish a stream-multiplexed and bidirectional connection to servers, that uses QUIC to offer an alternative to WebSocket. It exhibits all the advantages of QUIC over TCP, including faster handshakes, no head-of-line blocking, and being future-proof. Browsers cannot listen for WebTransport connections since it is similar to TCP in that it requires opening sockets on the host machine which is forbidden by the browser security model.
4436

4537
Libp2p nodes acting as circuit relay aim to establish connectivity between libp2p nodes (e.g. IPFS nodes) that wouldn't otherwise be able to establish a direct connection to each other.
4638

4739
A relay is needed in situations where nodes are behind NAT, reverse proxies, firewalls and/or simply don't support the same transports (e.g. go-libp2p vs. browser-libp2p). The circuit relay protocol exists to overcome those scenarios. Nodes with the `auto-relay` feature enabled can automatically bind themselves on a relay to listen for connections on their behalf.
4840

49-
You can use [libp2p/js-libp2p-relay-server](https://github.com/libp2p/js-libp2p-relay-server) to setup your own relay server. This also includes an easy to customize Docker setup for a HOP Relay.
50-
5141
## Querying the network from the browser
5242

5343
Libp2p nodes in scenarios such as browser environment and constrained devices will not be an efficient node in the libp2p DHT overlay, as a consequence of their known limitations regarding connectivity and performance.

examples/README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@ Let us know if you find any issues, or if you want to contribute and add a new t
1818

1919
## Other examples
2020

21-
- [Running libp2p in the Browser](./libp2p-in-the-browser)
2221
- Running libp2p in the Electron (future)
2322
- [The standard echo net example with libp2p](./echo)
2423
- [A simple chat app with libp2p](./chat)
2524

26-
For go-libp2p examples, check out https://github.com/libp2p/go-libp2p-examples#examples-and-tutorials
25+
## libp2p in the Browser
26+
There are a number of ways libp2p can be used in the browser. Here are some examples:
27+
28+
- [webRTC](./libp2p-in-the-browser/webrtc/README.md)
29+
- [websockets](./libp2p-in-the-browser/websockets/README.md)
30+
- [webtransport](./libp2p-in-the-browser/webtransport/README.md)
31+
32+
There is also an tutorial of how all of these transports can be [universally connected](https://github.com/libp2p/universal-connectivity/tree/main)

examples/discovery-mechanisms/README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,7 @@ This is really useful when running libp2p in constrained environments like a bro
300300

301301
There are plenty more Peer Discovery Mechanisms out there, you can:
302302

303-
- Find one in [@libp2p/webrtc-star](https://github.com/libp2p/js-libp2p-webrtc-star). Yes, a transport with discovery capabilities! This happens because WebRTC requires a rendezvous point for peers to exchange [SDP](https://tools.ietf.org/html/rfc4317) offer, which means we have one or more points that can introduce peers to each other. Think of it as MulticastDNS for the Web, as in MulticastDNS only works in LAN.
304-
- Any DHT will offer you a discovery capability. You can simple *random-walk* the routing tables to find other peers to connect to. For example [@libp2p/kad-dht](https://github.com/libp2p/js-libp2p-kad-dht) can be used for peer discovery. An example of how to configure it to enable random walks can be found [here](https://github.com/libp2p/js-libp2p/blob/v0.28.4/doc/CONFIGURATION.md#customizing-dht).
303+
- Any DHT will offer you a discovery capability. You can simple _random-walk_ the routing tables to find other peers to connect to. For example [@libp2p/kad-dht](https://github.com/libp2p/js-libp2p/tree/master/packages/kad-dht) can be used for peer discovery. An example of how to configure it to enable random walks can be found [here](https://github.com/libp2p/js-libp2p/blob/v0.28.4/doc/CONFIGURATION.md#customizing-dht).
305304
- You can create your own Discovery service, a registry, a list, a radio beacon, you name it!
306305

307306
## License

0 commit comments

Comments
 (0)