This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 139
139
"libp2p-secio" : " ~0.11.0" ,
140
140
"libp2p-tcp" : " ~0.13.0" ,
141
141
"libp2p-webrtc-star" : " ~0.15.5" ,
142
- "libp2p-websocket-star" : " ~0.10 .0" ,
142
+ "libp2p-websocket-star-multi " : " ~0.4 .0" ,
143
143
"libp2p-websockets" : " ~0.12.0" ,
144
144
"lodash" : " ^4.17.11" ,
145
145
"mafmt" : " ^6.0.2" ,
Original file line number Diff line number Diff line change 2
2
3
3
const WS = require ( 'libp2p-websockets' )
4
4
const WebRTCStar = require ( 'libp2p-webrtc-star' )
5
- const WebSocketStar = require ( 'libp2p-websocket-star' )
5
+ const WebSocketStarMulti = require ( 'libp2p-websocket-star-multi ' )
6
6
const Multiplex = require ( 'libp2p-mplex' )
7
7
const SECIO = require ( 'libp2p-secio' )
8
8
const Bootstrap = require ( 'libp2p-bootstrap' )
9
9
const libp2p = require ( 'libp2p' )
10
10
const defaultsDeep = require ( '@nodeutils/defaults-deep' )
11
+ const multiaddr = require ( 'multiaddr' )
11
12
12
13
class Node extends libp2p {
13
14
constructor ( _options ) {
14
15
const wrtcstar = new WebRTCStar ( { id : _options . peerInfo . id } )
15
- const wsstar = new WebSocketStar ( { id : _options . peerInfo . id } )
16
+
17
+ // this can be replaced once optional listening is supported with the below code. ref: https://github.com/libp2p/interface-transport/issues/41
18
+ // const wsstar = new WebSocketStar({ id: _options.peerInfo.id })
19
+ const wsstarServers = _options . peerInfo . multiaddrs . toArray ( ) . map ( String ) . filter ( addr => addr . includes ( 'p2p-websocket-star' ) )
20
+ _options . peerInfo . multiaddrs . replace ( wsstarServers . map ( multiaddr ) , '/p2p-websocket-star' ) // the ws-star-multi module will replace this with the chosen ws-star servers
21
+ const wsstar = new WebSocketStarMulti ( { servers : wsstarServers , id : _options . peerInfo . id , ignore_no_online : ! wsstarServers . length || _options . wsStarIgnoreErrors } )
16
22
17
23
const defaults = {
18
24
modules : {
Original file line number Diff line number Diff line change 3
3
const TCP = require ( 'libp2p-tcp' )
4
4
const MulticastDNS = require ( 'libp2p-mdns' )
5
5
const WS = require ( 'libp2p-websockets' )
6
- const WebSocketStar = require ( 'libp2p-websocket-star' )
6
+ const WebSocketStarMulti = require ( 'libp2p-websocket-star-multi ' )
7
7
const Bootstrap = require ( 'libp2p-bootstrap' )
8
8
const KadDHT = require ( 'libp2p-kad-dht' )
9
9
const Multiplex = require ( 'libp2p-mplex' )
10
10
const SECIO = require ( 'libp2p-secio' )
11
11
const libp2p = require ( 'libp2p' )
12
12
const defaultsDeep = require ( '@nodeutils/defaults-deep' )
13
+ const multiaddr = require ( 'multiaddr' )
13
14
14
15
class Node extends libp2p {
15
16
constructor ( _options ) {
16
- const wsstar = new WebSocketStar ( { id : _options . peerInfo . id } )
17
+ // this can be replaced once optional listening is supported with the below code. ref: https://github.com/libp2p/interface-transport/issues/41
18
+ // const wsstar = new WebSocketStar({ id: _options.peerInfo.id })
19
+ const wsstarServers = _options . peerInfo . multiaddrs . toArray ( ) . map ( String ) . filter ( addr => addr . includes ( 'p2p-websocket-star' ) )
20
+ _options . peerInfo . multiaddrs . replace ( wsstarServers . map ( multiaddr ) , '/p2p-websocket-star' ) // the ws-star-multi module will replace this with the chosen ws-star servers
21
+ const wsstar = new WebSocketStarMulti ( { servers : wsstarServers , id : _options . peerInfo . id , ignore_no_online : ! wsstarServers . length || _options . wsStarIgnoreErrors } )
17
22
18
23
const defaults = {
19
24
modules : {
You can’t perform that action at this time.
0 commit comments