This repository was archived by the owner on Apr 24, 2023. It is now read-only.
File tree 7 files changed +22
-104
lines changed
7 files changed +22
-104
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 3
3
"version" : " 0.15.1" ,
4
4
"description" : " libp2p WebRTC transport that includes a discovery mechanism provided by the signalling-star" ,
5
5
"main" : " src/index.js" ,
6
- "bin" : {
7
- "webrtc-star" : " src/sig-server/bin.js" ,
8
- "star-sig" : " src/sig-server/bin.js" ,
9
- "star-signal" : " src/sig-server/bin.js"
10
- },
11
6
"scripts" : {
12
- "star-signal" : " node src/sig-server/bin.js" ,
13
7
"lint" : " aegir lint" ,
14
8
"build" : " aegir build" ,
15
9
"test" : " aegir test -t node -t browser" ,
60
54
"class-is" : " ^1.1.0" ,
61
55
"debug" : " ^3.1.0" ,
62
56
"detect-node" : " ^2.0.3" ,
63
- "epimetheus" : " ^1.0.55" ,
64
- "hapi" : " ^16.6.2" ,
65
- "inert" : " ^4.2.1" ,
66
57
"interface-connection" : " ~0.3.2" ,
67
58
"mafmt" : " ^6.0.0" ,
68
59
"minimist" : " ^1.2.0" ,
69
60
"multiaddr" : " ^5.0.0" ,
70
61
"once" : " ^1.4.0" ,
71
62
"peer-id" : " ~0.10.7" ,
72
- "peer-info" : " ~0.14.1" ,
73
63
"pull-stream" : " ^3.6.8" ,
74
64
"simple-peer" : " ^9.1.2" ,
75
- "socket.io" : " ^2.1.1" ,
76
- "socket.io-client" : " ^2.1.1" ,
77
- "stream-to-pull-stream" : " ^1.7.2" ,
78
65
"webrtcsupport" : " github:ipfs/webrtcsupport"
79
66
},
80
67
"contributors" : [
Original file line number Diff line number Diff line change @@ -21,6 +21,25 @@ const setImmediate = require('async/setImmediate')
21
21
const once = require ( 'once' )
22
22
const noop = once ( ( ) => { } )
23
23
24
+ function cleanMultiaddr ( maStr ) {
25
+ const legacy = '/libp2p-webrtc-star'
26
+
27
+ if ( maStr . indexOf ( legacy ) !== - 1 ) {
28
+ maStr = maStr . substring ( legacy . length , maStr . length )
29
+ let ma = multiaddr ( maStr )
30
+ const tuppleIPFS = ma . stringTuples ( ) . filter ( ( tupple ) => {
31
+ return tupple [ 0 ] === 421 // ipfs code
32
+ } ) [ 0 ]
33
+
34
+ ma = ma . decapsulate ( 'ipfs' )
35
+ ma = ma . encapsulate ( '/p2p-webrtc-star' )
36
+ ma = ma . encapsulate ( `/ipfs/${ tuppleIPFS [ 1 ] } ` )
37
+ maStr = ma . toString ( )
38
+ }
39
+
40
+ return maStr
41
+ }
42
+
24
43
class WebRTCStar {
25
44
constructor ( options ) {
26
45
options = options || { }
@@ -39,9 +58,11 @@ class WebRTCStar {
39
58
options = { }
40
59
}
41
60
61
+ ma = cleanMultiaddr ( String ( ma ) )
62
+
42
63
callback = callback ? once ( callback ) : noop
43
64
44
- let b58 = ma . toString ( ) . split ( 'ipfs/' ) . pop ( )
65
+ let b58 = ma . split ( 'ipfs/' ) . pop ( )
45
66
46
67
log ( 'dialing %s %s' , ma , b58 )
47
68
You can’t perform that action at this time.
0 commit comments