Compare commits

..

37 Commits

Author SHA1 Message Date
b216471f44 chore: release version v0.7.1 2018-04-30 19:10:05 +01:00
10f4cb969d chore: update contributors 2018-04-30 19:10:05 +01:00
f3fd734a2a chore: update deps 2018-04-30 19:08:25 +01:00
28d915ebb6 Fix libp2p/js-libp2p#179 - Don't crash when receiving invalid data 2018-04-30 19:07:24 +01:00
fb59bf2bf5 chore: release version v0.7.0 2018-04-05 17:54:12 +01:00
d0ae8b6267 chore: update contributors 2018-04-05 17:54:12 +01:00
4b01fbebf9 chore: update deps 2018-04-05 17:52:05 +01:00
4f095a0543 chore: release version v0.6.3 2018-01-27 18:41:49 -08:00
aba09a4f30 chore: update contributors 2018-01-27 18:41:48 -08:00
90e88742b0 chore: update deps 2018-01-27 18:40:18 -08:00
fc492c6739 chore: release version v0.6.2 2018-01-07 15:09:08 +00:00
21d74401ed chore: update contributors 2018-01-07 15:09:08 +00:00
d5374f0167 chore: update gitignore 2018-01-07 15:08:45 +00:00
f73fe2502b chore: updating CI files (#43)
* Updating CI files

This commit updates all CI scripts to the latest version

* chore: update deps

* bump timeouts for key gen

* kick to make circle spin with trusty

* travis can be really slow
2018-01-07 15:07:51 +00:00
2d6c0ed3f7 chore: release version v0.6.1 2017-09-07 10:42:47 +01:00
ae0cd81ed9 chore: update contributors 2017-09-07 10:42:47 +01:00
4ac25c9f32 feat: replace protocol-buffers with protons (#42)
* feat: replace protocol-buffers with protons

Ref https://github.com/ipfs/js-ipfs/issues/991

* feat: upgrade to aegir@12
2017-09-07 10:39:56 +01:00
52fdf7b40c chore: release version v0.6.0 2017-09-03 12:17:39 +01:00
8ca5f60f42 chore: update contributors 2017-09-03 12:17:39 +01:00
b8f77ea5ed feat: p2p addrs situation (#41)
* chore: update gitignore

* chore: update CI

* chore: update deps
2017-09-03 12:16:32 +01:00
7e6f3f2e22 chore: release version v0.5.0 2017-07-22 13:53:29 -07:00
f9a35dd8a4 chore: update contributors 2017-07-22 13:53:29 -07:00
a2d2c953bc chore: update deps 2017-07-22 13:50:26 -07:00
e836bb7ff0 chore: update deps 2017-07-20 11:11:59 -07:00
f686a3a010 chore: release version v0.4.2 2017-07-08 21:24:29 +01:00
92946a59c3 chore: update contributors 2017-07-08 21:24:29 +01:00
65e8fd5f24 chore: update deps 2017-07-08 21:21:27 +01:00
f07b35f4d4 chore: release version v0.4.1 2017-04-06 15:26:16 -04:00
85f601f809 chore: update contributors 2017-04-06 15:26:15 -04:00
bb6d3dfc36 fix: if conn was closed, don't crash just because identify didn't get any data (#40) 2017-04-06 15:14:37 -04:00
4312acf49a chore: release version v0.4.0 2017-03-30 14:20:11 +01:00
45c0e957c3 chore: update contributors 2017-03-30 14:20:10 +01:00
7d4294b279 Feat/new peer info (#39)
* chore: update deps

* feat: peer-info rave
2017-03-30 14:17:25 +01:00
228c2b09de chore: release version v0.3.3 2017-03-21 15:17:06 +00:00
faa5433f8d chore: update contributors 2017-03-21 15:17:06 +00:00
de53a00e4d chore: update aegir 2017-03-21 15:16:31 +00:00
cf45341754 chore(package): update aegir to version 10.0.0 (#32)
https://greenkeeper.io/
2017-02-13 18:03:30 -08:00
15 changed files with 325 additions and 125 deletions

42
.gitignore vendored
View File

@ -1,33 +1,13 @@
package-lock.json
yarn.lock
docs
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
coverage
**/node_modules
**/*.log
test/setup/tmp-disposable-nodes-addrs.json
dist
coverage
**/*.swp
examples/sub-module/**/bundle.js
examples/sub-module/**/*-minified.js
examples/sub-module/*-bundle.js

View File

@ -1,23 +1,19 @@
# 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.
sudo: false
language: node_js
matrix:
include:
- node_js: 4
env: CXX=g++-4.8
- node_js: 6
env:
- SAUCE=true
- CXX=g++-4.8
- node_js: stable
env: CXX=g++-4.8
# Make sure we have new NPM.
before_install:
- npm install -g npm
- node_js: 8
env: CXX=g++-4.8
# - node_js: stable
# env: CXX=g++-4.8
script:
- npm run lint
- npm test
- npm run test
- npm run coverage
before_script:
@ -33,4 +29,4 @@ addons:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
- g++-4.8

121
CHANGELOG.md Normal file
View File

@ -0,0 +1,121 @@
<a name="0.7.1"></a>
## [0.7.1](https://github.com/libp2p/js-libp2p-identify/compare/v0.7.0...v0.7.1) (2018-04-30)
<a name="0.7.0"></a>
# [0.7.0](https://github.com/libp2p/js-libp2p-identify/compare/v0.6.3...v0.7.0) (2018-04-05)
<a name="0.6.3"></a>
## [0.6.3](https://github.com/libp2p/js-libp2p-identify/compare/v0.6.2...v0.6.3) (2018-01-28)
<a name="0.6.2"></a>
## [0.6.2](https://github.com/libp2p/js-libp2p-identify/compare/v0.6.1...v0.6.2) (2018-01-07)
<a name="0.6.1"></a>
## [0.6.1](https://github.com/libp2p/js-libp2p-identify/compare/v0.6.0...v0.6.1) (2017-09-07)
### Features
* replace protocol-buffers with protons ([#42](https://github.com/libp2p/js-libp2p-identify/issues/42)) ([4ac25c9](https://github.com/libp2p/js-libp2p-identify/commit/4ac25c9))
<a name="0.6.0"></a>
# [0.6.0](https://github.com/libp2p/js-libp2p-identify/compare/v0.5.0...v0.6.0) (2017-09-03)
### Features
* p2p addrs situation ([#41](https://github.com/libp2p/js-libp2p-identify/issues/41)) ([b8f77ea](https://github.com/libp2p/js-libp2p-identify/commit/b8f77ea))
<a name="0.5.0"></a>
# [0.5.0](https://github.com/libp2p/js-libp2p-identify/compare/v0.4.2...v0.5.0) (2017-07-22)
<a name="0.4.2"></a>
## [0.4.2](https://github.com/libp2p/js-libp2p-identify/compare/v0.4.1...v0.4.2) (2017-07-08)
<a name="0.4.1"></a>
## [0.4.1](https://github.com/libp2p/js-libp2p-identify/compare/v0.4.0...v0.4.1) (2017-04-06)
### Bug Fixes
* if conn was closed, don't crash just because identify didn't get any data ([#40](https://github.com/libp2p/js-libp2p-identify/issues/40)) ([bb6d3df](https://github.com/libp2p/js-libp2p-identify/commit/bb6d3df))
<a name="0.4.0"></a>
# [0.4.0](https://github.com/libp2p/js-libp2p-identify/compare/v0.3.3...v0.4.0) (2017-03-30)
<a name="0.3.3"></a>
## [0.3.3](https://github.com/libp2p/js-libp2p-identify/compare/v0.3.2...v0.3.3) (2017-03-21)
<a name="0.3.2"></a>
## [0.3.2](https://github.com/libp2p/js-libp2p-identify/compare/v0.3.1...v0.3.2) (2017-02-09)
<a name="0.3.1"></a>
## [0.3.1](https://github.com/libp2p/js-libp2p-identify/compare/v0.3.0...v0.3.1) (2017-01-11)
### Bug Fixes
* remove deprecation notice from identify protobuf ([38171cd](https://github.com/libp2p/js-libp2p-identify/commit/38171cd))
<a name="0.3.0"></a>
# [0.3.0](https://github.com/libp2p/js-libp2p-identify/compare/v0.2.0...v0.3.0) (2016-11-03)
<a name="0.2.0"></a>
# [0.2.0](https://github.com/libp2p/js-libp2p-identify/compare/v0.1.3...v0.2.0) (2016-09-06)
### Features
* **api:** move to pull-streams ([3b751c2](https://github.com/libp2p/js-libp2p-identify/commit/3b751c2))
* **readme:** documentationa and cleanup of code ([82bc0f2](https://github.com/libp2p/js-libp2p-identify/commit/82bc0f2))
<a name="0.1.3"></a>
## [0.1.3](https://github.com/libp2p/js-libp2p-identify/compare/v0.1.2...v0.1.3) (2016-08-03)
<a name="0.1.2"></a>
## [0.1.2](https://github.com/libp2p/js-libp2p-identify/compare/v0.1.1...v0.1.2) (2016-06-27)
<a name="0.1.1"></a>
## [0.1.1](https://github.com/libp2p/js-libp2p-identify/compare/v0.1.0...v0.1.1) (2016-06-27)
<a name="0.1.0"></a>
# 0.1.0 (2016-06-27)

View File

@ -6,11 +6,10 @@
[![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)
[![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)
[![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%3D4.0.0-orange.svg?style=flat-square)
[![Sauce Test Status](https://saucelabs.com/browser-matrix/libp2p-js-identify.svg)](https://saucelabs.com/u/libp2p-js-identify)
![](https://img.shields.io/badge/Node.js-%3E%3D6.0.0-orange.svg?style=flat-square)
> libp2p Identify Protocol

29
appveyor.yml Normal file
View File

@ -0,0 +1,29 @@
# 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.
version: "{build}"
environment:
matrix:
- nodejs_version: "6"
- nodejs_version: "8"
matrix:
fast_finish: true
install:
# Install Node.js
- ps: Install-Product node $env:nodejs_version
# Upgrade npm
- npm install -g npm
# Output our current versions for debugging
- node --version
- npm --version
# Install our package dependencies
- npm install
test_script:
- npm run test:node
build: off

2
ci/Jenkinsfile vendored Normal file
View File

@ -0,0 +1,2 @@
// 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,4 +1,4 @@
# 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.
machine:
node:
version: stable
@ -6,8 +6,10 @@ machine:
dependencies:
pre:
- google-chrome --version
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
- sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
- curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- sudo dpkg -i google-chrome.deb || true
- sudo apt-get update
- sudo apt-get --only-upgrade install google-chrome-stable
- google-chrome --version
- sudo apt-get install -f
- sudo apt-get install --only-upgrade lsb-base
- sudo dpkg -i google-chrome.deb
- google-chrome --version

View File

@ -1,26 +1,26 @@
{
"name": "libp2p-identify",
"version": "0.3.2",
"version": "0.7.1",
"description": "libp2p Identify Protocol",
"main": "src/index.js",
"scripts": {
"lint": "aegir-lint",
"build": "aegir-build",
"test": "aegir-test",
"test:node": "aegir-test --env node",
"test:browser": "aegir-test --env browser",
"release": "aegir-release",
"release-minor": "aegir-release --type minor",
"release-major": "aegir-release --type major",
"coverage": "aegir-coverage",
"coverage-publish": "aegir-coverage publish"
"lint": "aegir lint",
"build": "aegir build",
"test": "aegir test",
"test:node": "aegir test -t node",
"test:browser": "aegir test -t browser",
"release": "aegir release",
"release-minor": "aegir release --type minor",
"release-major": "aegir release --type major",
"coverage": "aegir coverage"
},
"pre-commit": [
"lint",
"test"
],
"engines": {
"node": ">=4.0.0"
"node": ">=6.0.0",
"npm": ">=3.0.0"
},
"repository": {
"type": "git",
@ -37,23 +37,26 @@
},
"homepage": "https://github.com/libp2p/js-libp2p-identify#readme",
"devDependencies": {
"aegir": "^10.0.0",
"chai": "^3.5.0",
"aegir": "^13.1.0",
"chai": "^4.1.2",
"dirty-chai": "^2.0.1",
"pre-commit": "^1.2.2",
"pull-pair": "^1.1.0"
},
"dependencies": {
"multiaddr": "^2.2.1",
"peer-id": "~0.8.2",
"peer-info": "~0.8.3",
"protocol-buffers": "^3.2.1",
"pull-length-prefixed": "^1.2.0",
"pull-stream": "^3.5.0"
"multiaddr": "^5.0.0",
"peer-id": "~0.10.7",
"peer-info": "~0.14.1",
"protons": "^1.0.1",
"pull-length-prefixed": "^1.3.0",
"pull-stream": "^3.6.7"
},
"contributors": [
"David Dias <daviddias.p@gmail.com>",
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
"Greenkeeper <support@greenkeeper.io>",
"Richard Littauer <richard.littauer@gmail.com>"
"Maciej Krüger <mkg20001@gmail.com>",
"Richard Littauer <richard.littauer@gmail.com>",
"ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ <victorbjelkholm@gmail.com>"
]
}
}

View File

@ -17,6 +17,11 @@ module.exports = (conn, callback) => {
return callback(err)
}
// connection got closed graciously
if (data.length === 0) {
return callback(new Error('conn was closed, did not receive data'))
}
const input = msg.decode(data[0])
PeerId.createFromPubKey(input.publicKey, (err, id) => {
@ -24,12 +29,24 @@ module.exports = (conn, callback) => {
return callback(err)
}
const info = new PeerInfo(id)
input.listenAddrs
.map(multiaddr)
.forEach((ma) => info.multiaddr.add(ma))
const peerInfo = new PeerInfo(id)
try {
input.listenAddrs
.map(multiaddr)
.forEach((ma) => peerInfo.multiaddrs.add(ma))
} catch (err) {
return callback(err)
}
callback(null, info, getObservedAddrs(input))
let observedAddr
try {
observedAddr = getObservedAddrs(input)
} catch (err) {
return callback(err)
}
callback(null, peerInfo, observedAddr)
})
})
)

View File

@ -11,7 +11,7 @@ module.exports = (conn, pInfoSelf) => {
if (err) { return }
observedAddrs = observedAddrs[0]
let publicKey = new Buffer(0)
let publicKey = Buffer.alloc(0)
if (pInfoSelf.id.pubKey) {
publicKey = pInfoSelf.id.pubKey.bytes
}
@ -20,8 +20,8 @@ module.exports = (conn, pInfoSelf) => {
protocolVersion: 'ipfs/0.1.0',
agentVersion: 'na',
publicKey: publicKey,
listenAddrs: pInfoSelf.multiaddrs.map((ma) => ma.buffer),
observedAddr: observedAddrs ? observedAddrs.buffer : new Buffer('')
listenAddrs: pInfoSelf.multiaddrs.toArray().map((ma) => ma.buffer),
observedAddr: observedAddrs ? observedAddrs.buffer : Buffer.from('')
})
pull(

View File

@ -1,7 +1,7 @@
'use strict'
const protobuf = require('protocol-buffers')
const schema = new Buffer(`
const protons = require('protons')
const schema = `
message Identify {
// protocolVersion determines compatibility between peers
optional string protocolVersion = 5; // e.g. ipfs/1.0.0
@ -25,6 +25,6 @@ message Identify {
repeated string protocols = 3;
}
`)
`
module.exports = protobuf(schema).Identify
module.exports = protons(schema).Identify

15
test/basic.spec.js Normal file
View File

@ -0,0 +1,15 @@
/* eslint-env mocha */
'use strict'
const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const identify = require('../src')
describe('basic', () => {
it('multicodec', () => {
expect(identify.multicodec).to.eql('/ipfs/id/1.0.0')
})
})

View File

@ -2,7 +2,10 @@
'use strict'
const pull = require('pull-stream')
const expect = require('chai').expect
const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const pair = require('pull-pair/duplex')
const PeerInfo = require('peer-info')
const lp = require('pull-length-prefixed')
@ -13,7 +16,9 @@ const identify = require('../src')
describe('identify.dialer', () => {
let original
beforeEach((done) => {
beforeEach(function (done) {
this.timeout(20 * 1000)
PeerInfo.create((err, info) => {
if (err) {
return done(err)
@ -26,7 +31,7 @@ describe('identify.dialer', () => {
it('works', (done) => {
const p = pair()
original.multiaddr.add(multiaddr('/ip4/127.0.0.1/tcp/5002'))
original.multiaddrs.add(multiaddr('/ip4/127.0.0.1/tcp/5002'))
const input = msg.encode({
protocolVersion: 'ipfs/0.1.0',
agentVersion: 'na',
@ -42,24 +47,63 @@ describe('identify.dialer', () => {
)
identify.dialer(p[1], (err, info, observedAddrs) => {
expect(err).to.not.exist
expect(
info.id.pubKey.bytes
).to.be.eql(
original.id.pubKey.bytes
)
expect(err).to.not.exist()
expect(info.id.pubKey.bytes)
.to.eql(original.id.pubKey.bytes)
expect(
info.multiaddrs
).to.be.eql(
original.multiaddrs
)
expect(info.multiaddrs.toArray())
.to.eql(original.multiaddrs.toArray())
expect(
observedAddrs
).to.be.eql(
[multiaddr('/ip4/127.0.0.1/tcp/5001')]
)
expect(observedAddrs)
.to.eql([multiaddr('/ip4/127.0.0.1/tcp/5001')])
done()
})
})
it('does not crash with invalid listen addresses', (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: [Buffer.from('ffac010203')],
observedAddr: Buffer.from('ffac010203')
})
pull(
pull.values([input]),
lp.encode(),
p[0]
)
identify.dialer(p[1], (err, info, observedAddrs) => {
expect(err).to.exist()
done()
})
})
it('does not crash with invalid observed address', (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: Buffer.from('ffac010203')
})
pull(
pull.values([input]),
lp.encode(),
p[0]
)
identify.dialer(p[1], (err, info, observedAddrs) => {
expect(err).to.exist()
done()
})

View File

@ -1,16 +0,0 @@
/* eslint-env mocha */
'use strict'
const expect = require('chai').expect
const identify = require('../src')
describe('identify', () => {
it('multicodec', () => {
expect(
identify.multicodec
).to.be.eql(
'/ipfs/id/1.0.0'
)
})
})

View File

@ -2,7 +2,10 @@
'use strict'
const pull = require('pull-stream')
const expect = require('chai').expect
const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const pair = require('pull-pair/duplex')
const PeerInfo = require('peer-info')
const lp = require('pull-length-prefixed')
@ -13,7 +16,10 @@ const identify = require('../src')
describe('identify.listener', () => {
let info
beforeEach((done) => {
beforeEach(function (done) {
this.timeout(20 * 1000)
PeerInfo.create((err, _info) => {
if (err) {
return done(err)
@ -26,12 +32,14 @@ describe('identify.listener', () => {
it('works', (done) => {
const p = pair()
info.multiaddr.add(multiaddr('/ip4/127.0.0.1/tcp/5002'))
info.multiaddrs.add(multiaddr('/ip4/127.0.0.1/tcp/5002'))
pull(
p[1],
lp.decode(),
pull.collect((err, result) => {
expect(err).to.not.exist
expect(err).to.not.exist()
const input = msg.decode(result[0])
expect(