This repository was archived by the owner on Feb 12, 2024. It is now read-only.
Commit 1b6cf60 1 parent 63d4d35 commit 1b6cf60 Copy full SHA for 1b6cf60
File tree 6 files changed +32
-3
lines changed
interface-ipfs-core/src/miscellaneous
6 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ The Peer identity has the following properties:
61
61
- ` addresses: Multiaddr[] ` - A list of multiaddrs this node is listening on
62
62
- ` agentVersion: String ` - The agent version
63
63
- ` protocolVersion: String ` - The supported protocol version
64
+ - ` protocols: String[] ` - The supported protocols
64
65
65
66
### Example
66
67
Original file line number Diff line number Diff line change @@ -44,5 +44,24 @@ module.exports = (common, options) => {
44
44
expect ( Multiaddr . isMultiaddr ( ma ) ) . to . be . true ( )
45
45
}
46
46
} )
47
+
48
+ it ( 'should have protocols property' , async ( ) => {
49
+ const res = await ipfs . id ( )
50
+
51
+ expect ( res ) . to . have . a . property ( 'protocols' ) . that . is . an ( 'array' )
52
+
53
+ expect ( res . protocols ) . to . have . members ( [
54
+ '/floodsub/1.0.0' ,
55
+ '/ipfs/bitswap/1.0.0' ,
56
+ '/ipfs/bitswap/1.1.0' ,
57
+ '/ipfs/bitswap/1.2.0' ,
58
+ '/ipfs/id/1.0.0' ,
59
+ '/ipfs/id/push/1.0.0' ,
60
+ '/ipfs/ping/1.0.0' ,
61
+ '/libp2p/circuit/relay/0.1.0' ,
62
+ '/meshsub/1.0.0' ,
63
+ '/meshsub/1.1.0'
64
+ ] )
65
+ } )
47
66
} )
48
67
}
Original file line number Diff line number Diff line change @@ -475,6 +475,10 @@ describe('interface-ipfs-core tests', () => {
475
475
{
476
476
name : 'should include the interface-ipfs-core version' ,
477
477
reason : 'TODO not implemented in go-ipfs yet'
478
+ } ,
479
+ {
480
+ name : 'should have protocols property' ,
481
+ reason : 'TODO not implemented in go-ipfs yet'
478
482
}
479
483
]
480
484
} )
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ module.exports = {
11
11
format : {
12
12
alias : 'f' ,
13
13
type : 'string' ,
14
- describe : 'Print Node ID info in the given format. Allowed tokens: <id> <aver> <pver> <pubkey> <addrs>'
14
+ describe : 'Print Node ID info in the given format. Allowed tokens: <id> <aver> <pver> <pubkey> <addrs> <protocols> '
15
15
} ,
16
16
timeout : {
17
17
type : 'string' ,
@@ -31,6 +31,7 @@ module.exports = {
31
31
. replace ( '<pver>' , id . protocolVersion )
32
32
. replace ( '<pubkey>' , id . publicKey )
33
33
. replace ( '<addrs>' , ( id . addresses || [ ] ) . map ( addr => addr . toString ( ) ) . join ( '\n' ) )
34
+ . replace ( '<protocols>' , ( id . protocols || [ ] ) . map ( protocol => protocol . toString ( ) ) . join ( '\n' ) )
34
35
)
35
36
36
37
return
Original file line number Diff line number Diff line change @@ -9,10 +9,12 @@ module.exports = ({ peerId, libp2p }) => {
9
9
return withTimeoutOption ( async function id ( ) { // eslint-disable-line require-await
10
10
const id = peerId . toB58String ( )
11
11
let addresses = [ ]
12
+ let protocols = [ ]
12
13
13
14
if ( libp2p ) {
14
15
// only available while the node is running
15
16
addresses = libp2p . transportManager . getAddrs ( )
17
+ protocols = Array . from ( libp2p . upgrader . protocols . keys ( ) )
16
18
}
17
19
18
20
return {
@@ -33,7 +35,8 @@ module.exports = ({ peerId, libp2p }) => {
33
35
. sort ( )
34
36
. map ( ma => multiaddr ( ma ) ) ,
35
37
agentVersion : `js-ipfs/${ pkgversion } ` ,
36
- protocolVersion : '9000'
38
+ protocolVersion : '9000' ,
39
+ protocols : protocols . sort ( )
37
40
}
38
41
} )
39
42
}
Original file line number Diff line number Diff line change @@ -38,7 +38,8 @@ module.exports = {
38
38
PublicKey : id . publicKey ,
39
39
Addresses : id . addresses ,
40
40
AgentVersion : id . agentVersion ,
41
- ProtocolVersion : id . protocolVersion
41
+ ProtocolVersion : id . protocolVersion ,
42
+ Protocols : id . protocols
42
43
} )
43
44
}
44
45
}
You can’t perform that action at this time.
0 commit comments