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 139139 "libp2p-secio" : " ~0.11.0" ,
140140 "libp2p-tcp" : " ~0.13.0" ,
141141 "libp2p-webrtc-star" : " ~0.15.5" ,
142- "libp2p-websocket-star" : " ~0.10 .0" ,
142+ "libp2p-websocket-star-multi " : " ~0.4 .0" ,
143143 "libp2p-websockets" : " ~0.12.0" ,
144144 "lodash" : " ^4.17.11" ,
145145 "mafmt" : " ^6.0.2" ,
Original file line number Diff line number Diff line change 22
33const WS = require ( 'libp2p-websockets' )
44const WebRTCStar = require ( 'libp2p-webrtc-star' )
5- const WebSocketStar = require ( 'libp2p-websocket-star' )
5+ const WebSocketStarMulti = require ( 'libp2p-websocket-star-multi ' )
66const Multiplex = require ( 'libp2p-mplex' )
77const SECIO = require ( 'libp2p-secio' )
88const Bootstrap = require ( 'libp2p-bootstrap' )
99const libp2p = require ( 'libp2p' )
1010const defaultsDeep = require ( '@nodeutils/defaults-deep' )
11+ const multiaddr = require ( 'multiaddr' )
1112
1213class Node extends libp2p {
1314 constructor ( _options ) {
1415 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 } )
1622
1723 const defaults = {
1824 modules : {
Original file line number Diff line number Diff line change 33const TCP = require ( 'libp2p-tcp' )
44const MulticastDNS = require ( 'libp2p-mdns' )
55const WS = require ( 'libp2p-websockets' )
6- const WebSocketStar = require ( 'libp2p-websocket-star' )
6+ const WebSocketStarMulti = require ( 'libp2p-websocket-star-multi ' )
77const Bootstrap = require ( 'libp2p-bootstrap' )
88const KadDHT = require ( 'libp2p-kad-dht' )
99const Multiplex = require ( 'libp2p-mplex' )
1010const SECIO = require ( 'libp2p-secio' )
1111const libp2p = require ( 'libp2p' )
1212const defaultsDeep = require ( '@nodeutils/defaults-deep' )
13+ const multiaddr = require ( 'multiaddr' )
1314
1415class Node extends libp2p {
1516 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 } )
1722
1823 const defaults = {
1924 modules : {
You can’t perform that action at this time.
0 commit comments