Compare commits

...

10 Commits

Author SHA1 Message Date
66c8adb8bc chore: release version v0.7.6
License: MIT
Signed-off-by: Jacob Heun <jacobheun@gmail.com>
2019-03-20 18:49:02 +01:00
d0c68f63fe chore: update contributors 2019-03-20 18:49:01 +01:00
6a1e6493cb chore: add files to package.json
License: MIT
Signed-off-by: Jacob Heun <jacobheun@gmail.com>
2019-03-20 18:47:56 +01:00
89ed15e9d9 feat: add protocol support to identify (#51) 2019-03-20 18:45:46 +01:00
f3ee2f069b chore: use travis ci (#50)
* chore: use travis ci
* chore: update badges
2019-02-21 15:56:39 +01:00
01f8ee1574 chore: update badges for consistency across libp2p org 2019-02-21 12:33:15 +01:00
bb244ce392 chore: release version v0.7.5
License: MIT
Signed-off-by: Jacob Heun <jacobheun@gmail.com>
2019-01-10 14:43:08 +01:00
ef04b79983 chore: update contributors 2019-01-10 14:43:07 +01:00
308cd9ab2c chore: update deps 2019-01-10 14:41:29 +01:00
b8d2b3d651 fix: reduce bundle size 2019-01-10 14:41:29 +01:00
9 changed files with 150 additions and 30 deletions

43
.travis.yml Normal file
View 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

View File

@ -1,3 +1,23 @@
<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)

View File

@ -1,15 +1,14 @@
# js-libp2p-identify
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
[![Coverage Status](https://coveralls.io/repos/github/libp2p/js-libp2p-identify/badge.svg?branch=master)](https://coveralls.io/github/libp2p/js-libp2p-identify?branch=master)
[![Travis CI](https://travis-ci.org/libp2p/js-libp2p-identify.svg?branch=master)](https://travis-ci.org/libp2p/js-libp2p-identify)
[![Circle CI](https://circleci.com/gh/libp2p/js-libp2p-identify.svg?style=svg)](https://circleci.com/gh/libp2p/js-libp2p-identify)
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai)
[![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
[![](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)
[![](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-identify.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-identify)
[![](https://img.shields.io/travis/libp2p/js-libp2p-identify.svg?style=flat-square)](https://travis-ci.com/libp2p/js-libp2p-identify)
[![Dependency Status](https://david-dm.org/libp2p/js-libp2p-identify.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-identify)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
![](https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square)
![](https://img.shields.io/badge/Node.js-%3E%3D6.0.0-orange.svg?style=flat-square)
![](https://img.shields.io/badge/npm-%3E%3D6.0.0-orange.svg?style=flat-square)
![](https://img.shields.io/badge/Node.js-%3E%3D10.0.0-orange.svg?style=flat-square)
> libp2p Identify Protocol

2
ci/Jenkinsfile vendored
View File

@ -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()

View File

@ -1,9 +1,13 @@
{
"name": "libp2p-identify",
"version": "0.7.4",
"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,15 +41,15 @@
},
"homepage": "https://github.com/libp2p/js-libp2p-identify#readme",
"devDependencies": {
"aegir": "^18.0.2",
"aegir": "^18.1.0",
"chai": "^4.2.0",
"dirty-chai": "^2.0.1",
"pull-pair": "^1.1.0"
},
"dependencies": {
"multiaddr": "^6.0.2",
"peer-id": "~0.12.1",
"peer-info": "~0.15.0",
"multiaddr": "^6.0.4",
"peer-id": "~0.12.2",
"peer-info": "~0.15.1",
"protons": "^1.0.1",
"pull-length-prefixed": "^1.3.1",
"pull-stream": "^3.6.9"
@ -54,11 +58,13 @@
"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>"
]
}

View File

@ -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)
})
})

View File

@ -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
)

View File

@ -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]
)

View File

@ -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()
})