This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +32
-3
lines changed
interface-ipfs-core/src/miscellaneous Expand file tree Collapse file tree 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:
6161- ` addresses: Multiaddr[] ` - A list of multiaddrs this node is listening on
6262- ` agentVersion: String ` - The agent version
6363- ` protocolVersion: String ` - The supported protocol version
64+ - ` protocols: String[] ` - The supported protocols
6465
6566### Example
6667
Original file line number Diff line number Diff line change @@ -44,5 +44,24 @@ module.exports = (common, options) => {
4444 expect ( Multiaddr . isMultiaddr ( ma ) ) . to . be . true ( )
4545 }
4646 } )
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+ } )
4766 } )
4867}
Original file line number Diff line number Diff line change @@ -475,6 +475,10 @@ describe('interface-ipfs-core tests', () => {
475475 {
476476 name : 'should include the interface-ipfs-core version' ,
477477 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'
478482 }
479483 ]
480484 } )
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ module.exports = {
1111 format : {
1212 alias : 'f' ,
1313 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> '
1515 } ,
1616 timeout : {
1717 type : 'string' ,
@@ -31,6 +31,7 @@ module.exports = {
3131 . replace ( '<pver>' , id . protocolVersion )
3232 . replace ( '<pubkey>' , id . publicKey )
3333 . replace ( '<addrs>' , ( id . addresses || [ ] ) . map ( addr => addr . toString ( ) ) . join ( '\n' ) )
34+ . replace ( '<protocols>' , ( id . protocols || [ ] ) . map ( protocol => protocol . toString ( ) ) . join ( '\n' ) )
3435 )
3536
3637 return
Original file line number Diff line number Diff line change @@ -9,10 +9,12 @@ module.exports = ({ peerId, libp2p }) => {
99 return withTimeoutOption ( async function id ( ) { // eslint-disable-line require-await
1010 const id = peerId . toB58String ( )
1111 let addresses = [ ]
12+ let protocols = [ ]
1213
1314 if ( libp2p ) {
1415 // only available while the node is running
1516 addresses = libp2p . transportManager . getAddrs ( )
17+ protocols = Array . from ( libp2p . upgrader . protocols . keys ( ) )
1618 }
1719
1820 return {
@@ -33,7 +35,8 @@ module.exports = ({ peerId, libp2p }) => {
3335 . sort ( )
3436 . map ( ma => multiaddr ( ma ) ) ,
3537 agentVersion : `js-ipfs/${ pkgversion } ` ,
36- protocolVersion : '9000'
38+ protocolVersion : '9000' ,
39+ protocols : protocols . sort ( )
3740 }
3841 } )
3942}
Original file line number Diff line number Diff line change @@ -38,7 +38,8 @@ module.exports = {
3838 PublicKey : id . publicKey ,
3939 Addresses : id . addresses ,
4040 AgentVersion : id . agentVersion ,
41- ProtocolVersion : id . protocolVersion
41+ ProtocolVersion : id . protocolVersion ,
42+ Protocols : id . protocols
4243 } )
4344 }
4445}
You can’t perform that action at this time.
0 commit comments