mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-07-08 21:31:32 +00:00
Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
66c8adb8bc | |||
d0c68f63fe | |||
6a1e6493cb | |||
89ed15e9d9 | |||
f3ee2f069b | |||
01f8ee1574 | |||
bb244ce392 | |||
ef04b79983 | |||
308cd9ab2c | |||
b8d2b3d651 | |||
c7eac39012 | |||
9d5f2a35ae | |||
7477c5c4a4 | |||
ba275558bb | |||
9b32d25de9 | |||
3c16dbe93e |
43
.travis.yml
Normal file
43
.travis.yml
Normal file
@ -0,0 +1,43 @@
|
||||
language: node_js
|
||||
cache: npm
|
||||
stages:
|
||||
- check
|
||||
- test
|
||||
- cov
|
||||
|
||||
node_js:
|
||||
- '10'
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
script: npx nyc -s npm run test:node -- --bail
|
||||
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- os: windows
|
||||
cache: false
|
||||
|
||||
- stage: check
|
||||
script:
|
||||
- npx aegir commitlint --travis
|
||||
- npx aegir dep-check
|
||||
- npm run lint
|
||||
|
||||
- stage: test
|
||||
name: chrome
|
||||
addons:
|
||||
chrome: stable
|
||||
script: npx aegir test -t browser -t webworker
|
||||
|
||||
- stage: test
|
||||
name: firefox
|
||||
addons:
|
||||
firefox: latest
|
||||
script: npx aegir test -t browser -t webworker -- --browsers FirefoxHeadless
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
30
CHANGELOG.md
30
CHANGELOG.md
@ -1,3 +1,33 @@
|
||||
<a name="0.7.6"></a>
|
||||
## [0.7.6](https://github.com/libp2p/js-libp2p-identify/compare/v0.7.5...v0.7.6) (2019-03-20)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add protocol support to identify ([#51](https://github.com/libp2p/js-libp2p-identify/issues/51)) ([89ed15e](https://github.com/libp2p/js-libp2p-identify/commit/89ed15e))
|
||||
|
||||
|
||||
|
||||
<a name="0.7.5"></a>
|
||||
## [0.7.5](https://github.com/libp2p/js-libp2p-identify/compare/v0.7.4...v0.7.5) (2019-01-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* reduce bundle size ([b8d2b3d](https://github.com/libp2p/js-libp2p-identify/commit/b8d2b3d))
|
||||
|
||||
|
||||
|
||||
<a name="0.7.4"></a>
|
||||
## [0.7.4](https://github.com/libp2p/js-libp2p-identify/compare/v0.7.3...v0.7.4) (2019-01-04)
|
||||
|
||||
|
||||
|
||||
<a name="0.7.3"></a>
|
||||
## [0.7.3](https://github.com/libp2p/js-libp2p-identify/compare/v0.7.2...v0.7.3) (2018-11-26)
|
||||
|
||||
|
||||
|
||||
<a name="0.7.2"></a>
|
||||
## [0.7.2](https://github.com/libp2p/js-libp2p-identify/compare/v0.7.1...v0.7.2) (2018-07-23)
|
||||
|
||||
|
15
README.md
15
README.md
@ -1,15 +1,14 @@
|
||||
# js-libp2p-identify
|
||||
|
||||
[](http://ipn.io)
|
||||
[](http://ipfs.io/)
|
||||
[](http://webchat.freenode.net/?channels=%23ipfs)
|
||||
[](https://coveralls.io/github/libp2p/js-libp2p-identify?branch=master)
|
||||
[](https://travis-ci.org/libp2p/js-libp2p-identify)
|
||||
[](https://circleci.com/gh/libp2p/js-libp2p-identify)
|
||||
[](http://protocol.ai)
|
||||
[](http://libp2p.io/)
|
||||
[](http://webchat.freenode.net/?channels=%23libp2p)
|
||||
[](https://codecov.io/gh/libp2p/js-libp2p-identify)
|
||||
[](https://travis-ci.com/libp2p/js-libp2p-identify)
|
||||
[](https://david-dm.org/libp2p/js-libp2p-identify)
|
||||
[](https://github.com/feross/standard)
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
> libp2p Identify Protocol
|
||||
|
||||
|
2
ci/Jenkinsfile
vendored
2
ci/Jenkinsfile
vendored
@ -1,2 +0,0 @@
|
||||
// Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories.
|
||||
javascript()
|
23
package.json
23
package.json
@ -1,9 +1,13 @@
|
||||
{
|
||||
"name": "libp2p-identify",
|
||||
"version": "0.7.2",
|
||||
"version": "0.7.6",
|
||||
"description": "libp2p Identify Protocol",
|
||||
"leadMaintainer": "Jacob Heun <jacobheun@gmail.com>",
|
||||
"main": "src/index.js",
|
||||
"files": [
|
||||
"dist",
|
||||
"src"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "aegir lint",
|
||||
"build": "aegir build",
|
||||
@ -37,27 +41,30 @@
|
||||
},
|
||||
"homepage": "https://github.com/libp2p/js-libp2p-identify#readme",
|
||||
"devDependencies": {
|
||||
"aegir": "^15.0.0",
|
||||
"chai": "^4.1.2",
|
||||
"aegir": "^18.1.0",
|
||||
"chai": "^4.2.0",
|
||||
"dirty-chai": "^2.0.1",
|
||||
"pull-pair": "^1.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"multiaddr": "^5.0.0",
|
||||
"peer-id": "~0.10.7",
|
||||
"peer-info": "~0.14.1",
|
||||
"multiaddr": "^6.0.4",
|
||||
"peer-id": "~0.12.2",
|
||||
"peer-info": "~0.15.1",
|
||||
"protons": "^1.0.1",
|
||||
"pull-length-prefixed": "^1.3.0",
|
||||
"pull-stream": "^3.6.7"
|
||||
"pull-length-prefixed": "^1.3.1",
|
||||
"pull-stream": "^3.6.9"
|
||||
},
|
||||
"contributors": [
|
||||
"David Dias <daviddias.p@gmail.com>",
|
||||
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
|
||||
"Greenkeeper <support@greenkeeper.io>",
|
||||
"Hugo Dias <hugomrdias@gmail.com>",
|
||||
"Jacob Heun <jacobheun@gmail.com>",
|
||||
"Jacob Heun <jake@andyet.net>",
|
||||
"Maciej Krüger <mkg20001@gmail.com>",
|
||||
"Richard Littauer <richard.littauer@gmail.com>",
|
||||
"Vasco Santos <vasco.santos@moxy.studio>",
|
||||
"Yusef Napora <yusef@protocol.ai>",
|
||||
"ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ <victorbjelkholm@gmail.com>"
|
||||
]
|
||||
}
|
||||
|
@ -2,7 +2,9 @@
|
||||
const PeerInfo = require('peer-info')
|
||||
const PeerId = require('peer-id')
|
||||
const multiaddr = require('multiaddr')
|
||||
const pull = require('pull-stream')
|
||||
const pull = require('pull-stream/pull')
|
||||
const take = require('pull-stream/throughs/take')
|
||||
const collect = require('pull-stream/sinks/collect')
|
||||
const lp = require('pull-length-prefixed')
|
||||
|
||||
const msg = require('./message')
|
||||
@ -17,8 +19,8 @@ module.exports = (conn, expectedPeerInfo, callback) => {
|
||||
pull(
|
||||
conn,
|
||||
lp.decode(),
|
||||
pull.take(1),
|
||||
pull.collect((err, data) => {
|
||||
take(1),
|
||||
collect((err, data) => {
|
||||
if (err) {
|
||||
return callback(err)
|
||||
}
|
||||
@ -56,6 +58,9 @@ module.exports = (conn, expectedPeerInfo, callback) => {
|
||||
return callback(err)
|
||||
}
|
||||
|
||||
// Copy the protocols
|
||||
peerInfo.protocols = new Set(input.protocols)
|
||||
|
||||
callback(null, peerInfo, observedAddr)
|
||||
})
|
||||
})
|
||||
|
@ -1,6 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
const pull = require('pull-stream')
|
||||
const pull = require('pull-stream/pull')
|
||||
const values = require('pull-stream/sources/values')
|
||||
const lp = require('pull-length-prefixed')
|
||||
|
||||
const msg = require('./message')
|
||||
@ -21,11 +22,12 @@ module.exports = (conn, pInfoSelf) => {
|
||||
agentVersion: 'na',
|
||||
publicKey: publicKey,
|
||||
listenAddrs: pInfoSelf.multiaddrs.toArray().map((ma) => ma.buffer),
|
||||
observedAddr: observedAddrs ? observedAddrs.buffer : Buffer.from('')
|
||||
observedAddr: observedAddrs ? observedAddrs.buffer : Buffer.from(''),
|
||||
protocols: Array.from(pInfoSelf.protocols)
|
||||
})
|
||||
|
||||
pull(
|
||||
pull.values([msgSend]),
|
||||
values([msgSend]),
|
||||
lp.encode(),
|
||||
conn
|
||||
)
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* eslint-env mocha */
|
||||
'use strict'
|
||||
|
||||
const pull = require('pull-stream')
|
||||
const pull = require('pull-stream/pull')
|
||||
const values = require('pull-stream/sources/values')
|
||||
const chai = require('chai')
|
||||
const dirtyChai = require('dirty-chai')
|
||||
const expect = chai.expect
|
||||
@ -32,16 +33,20 @@ describe('identify.dialer', () => {
|
||||
it('works', (done) => {
|
||||
const p = pair()
|
||||
original.multiaddrs.add(multiaddr('/ip4/127.0.0.1/tcp/5002'))
|
||||
original.protocols.add('/echo/1.0.0')
|
||||
original.protocols.add('/ping/1.0.0')
|
||||
|
||||
const input = msg.encode({
|
||||
protocolVersion: 'ipfs/0.1.0',
|
||||
agentVersion: 'na',
|
||||
publicKey: original.id.pubKey.bytes,
|
||||
listenAddrs: [multiaddr('/ip4/127.0.0.1/tcp/5002').buffer],
|
||||
observedAddr: multiaddr('/ip4/127.0.0.1/tcp/5001').buffer
|
||||
observedAddr: multiaddr('/ip4/127.0.0.1/tcp/5001').buffer,
|
||||
protocols: Array.from(original.protocols)
|
||||
})
|
||||
|
||||
pull(
|
||||
pull.values([input]),
|
||||
values([input]),
|
||||
lp.encode(),
|
||||
p[0]
|
||||
)
|
||||
@ -57,6 +62,44 @@ describe('identify.dialer', () => {
|
||||
expect(observedAddrs)
|
||||
.to.eql([multiaddr('/ip4/127.0.0.1/tcp/5001')])
|
||||
|
||||
expect(info.protocols).to.eql(original.protocols)
|
||||
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should handle missing protocols', (done) => {
|
||||
const p = pair()
|
||||
original.multiaddrs.add(multiaddr('/ip4/127.0.0.1/tcp/5002'))
|
||||
|
||||
const input = msg.encode({
|
||||
protocolVersion: 'ipfs/0.1.0',
|
||||
agentVersion: 'na',
|
||||
publicKey: original.id.pubKey.bytes,
|
||||
listenAddrs: [multiaddr('/ip4/127.0.0.1/tcp/5002').buffer],
|
||||
observedAddr: multiaddr('/ip4/127.0.0.1/tcp/5001').buffer,
|
||||
protocols: Array.from(original.protocols)
|
||||
})
|
||||
|
||||
pull(
|
||||
values([input]),
|
||||
lp.encode(),
|
||||
p[0]
|
||||
)
|
||||
|
||||
identify.dialer(p[1], (err, info, observedAddrs) => {
|
||||
expect(err).to.not.exist()
|
||||
expect(info.id.pubKey.bytes)
|
||||
.to.eql(original.id.pubKey.bytes)
|
||||
|
||||
expect(info.multiaddrs.toArray())
|
||||
.to.eql(original.multiaddrs.toArray())
|
||||
|
||||
expect(observedAddrs)
|
||||
.to.eql([multiaddr('/ip4/127.0.0.1/tcp/5001')])
|
||||
|
||||
expect(Array.from(info.protocols)).to.eql([])
|
||||
|
||||
done()
|
||||
})
|
||||
})
|
||||
@ -73,7 +116,7 @@ describe('identify.dialer', () => {
|
||||
})
|
||||
|
||||
pull(
|
||||
pull.values([input]),
|
||||
values([input]),
|
||||
lp.encode(),
|
||||
p[0]
|
||||
)
|
||||
@ -97,7 +140,7 @@ describe('identify.dialer', () => {
|
||||
})
|
||||
|
||||
pull(
|
||||
pull.values([input]),
|
||||
values([input]),
|
||||
lp.encode(),
|
||||
p[0]
|
||||
)
|
||||
@ -126,7 +169,7 @@ describe('identify.dialer', () => {
|
||||
}
|
||||
|
||||
pull(
|
||||
pull.values([input]),
|
||||
values([input]),
|
||||
lp.encode(),
|
||||
p[0]
|
||||
)
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* eslint-env mocha */
|
||||
'use strict'
|
||||
|
||||
const pull = require('pull-stream')
|
||||
const pull = require('pull-stream/pull')
|
||||
const collect = require('pull-stream/sinks/collect')
|
||||
const chai = require('chai')
|
||||
const dirtyChai = require('dirty-chai')
|
||||
const expect = chai.expect
|
||||
@ -25,6 +26,9 @@ describe('identify.listener', () => {
|
||||
return done(err)
|
||||
}
|
||||
|
||||
_info.protocols.add('/echo/1.0.0')
|
||||
_info.protocols.add('/chat/1.0.0')
|
||||
|
||||
info = _info
|
||||
done()
|
||||
})
|
||||
@ -38,7 +42,7 @@ describe('identify.listener', () => {
|
||||
pull(
|
||||
p[1],
|
||||
lp.decode(),
|
||||
pull.collect((err, result) => {
|
||||
collect((err, result) => {
|
||||
expect(err).to.not.exist()
|
||||
|
||||
const input = msg.decode(result[0])
|
||||
@ -50,7 +54,7 @@ describe('identify.listener', () => {
|
||||
publicKey: info.id.pubKey.bytes,
|
||||
listenAddrs: [multiaddr('/ip4/127.0.0.1/tcp/5002').buffer],
|
||||
observedAddr: multiaddr('/ip4/127.0.0.1/tcp/5001').buffer,
|
||||
protocols: []
|
||||
protocols: ['/echo/1.0.0', '/chat/1.0.0']
|
||||
})
|
||||
done()
|
||||
})
|
||||
|
Reference in New Issue
Block a user