@libp2p/webrtc 5.1.1 → 5.2.0-2b49a5f74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -56,7 +56,6 @@ import { circuitRelayTransport, circuitRelayServer } from '@libp2p/circuit-relay
56
56
  import { identify } from '@libp2p/identify'
57
57
  import { webRTC } from '@libp2p/webrtc'
58
58
  import { webSockets } from '@libp2p/websockets'
59
- import * as filters from '@libp2p/websockets/filters'
60
59
  import { WebRTC } from '@multiformats/multiaddr-matcher'
61
60
  import delay from 'delay'
62
61
  import { pipe } from 'it-pipe'
@@ -70,10 +69,13 @@ const relay = await createLibp2p({
70
69
  listen: ['/ip4/127.0.0.1/tcp/0/ws']
71
70
  },
72
71
  transports: [
73
- webSockets({filter: filters.all})
72
+ webSockets()
74
73
  ],
75
74
  connectionEncrypters: [noise()],
76
75
  streamMuxers: [yamux()],
76
+ connectionGater: {
77
+ denyDialMultiaddr: () => false
78
+ },
77
79
  services: {
78
80
  identify: identify(),
79
81
  relay: circuitRelayServer()
@@ -91,12 +93,15 @@ const listener = await createLibp2p({
91
93
  ]
92
94
  },
93
95
  transports: [
94
- webSockets({filter: filters.all}),
96
+ webSockets(),
95
97
  webRTC(),
96
98
  circuitRelayTransport()
97
99
  ],
98
100
  connectionEncrypters: [noise()],
99
101
  streamMuxers: [yamux()],
102
+ connectionGater: {
103
+ denyDialMultiaddr: () => false
104
+ },
100
105
  services: {
101
106
  identify: identify(),
102
107
  echo: echo()
@@ -128,12 +133,15 @@ while (true) {
128
133
  // direct WebRTC connection
129
134
  const dialer = await createLibp2p({
130
135
  transports: [
131
- webSockets({filter: filters.all}),
136
+ webSockets(),
132
137
  webRTC(),
133
138
  circuitRelayTransport()
134
139
  ],
135
140
  connectionEncrypters: [noise()],
136
141
  streamMuxers: [yamux()],
142
+ connectionGater: {
143
+ denyDialMultiaddr: () => false
144
+ },
137
145
  services: {
138
146
  identify: identify(),
139
147
  echo: echo()
@@ -162,9 +170,22 @@ await pipe(
162
170
 
163
171
  ## Example - WebRTC Direct
164
172
 
165
- At the time of writing WebRTC Direct is dial-only in browsers and unsupported in Node.js.
173
+ WebRTC Direct allows a client to establish a WebRTC connection to a server
174
+ without using a relay to first exchange SDP messages.
175
+
176
+ Instead the server listens on a public UDP port and embeds its certificate
177
+ hash in the published multiaddr. It derives the client's SDP offer based on
178
+ the incoming IP/port of STUN messages sent to this public port.
179
+
180
+ The client derives the server's SDP answer based on the information in the
181
+ multiaddr so no SDP handshake via a third party is required.
182
+
183
+ Full details of the connection protocol can be found in the [WebRTC Direct spec](https://github.com/libp2p/specs/blob/master/webrtc/webrtc-direct.md).
184
+
185
+ Browsers cannot listen on WebRTC Direct addresses since they cannot open
186
+ ports, but they can dial all spec-compliant servers.
166
187
 
167
- The only implementation that supports a WebRTC Direct listener is go-libp2p and it's not yet enabled by default.
188
+ Node.js/go and rust-libp2p can listen on and dial WebRTC Direct addresses.
168
189
 
169
190
  ```TypeScript
170
191
  import { createLibp2p } from 'libp2p'