Skip to content
This repository was archived by the owner on Aug 23, 2019. It is now read-only.

Commit 9bcc505

Browse files
dignifiedquiredaviddias
authored andcommitted
Async Crypto Endeavour (#6)
1 parent c34f2a1 commit 9bcc505

File tree

10 files changed

+75
-53
lines changed

10 files changed

+75
-53
lines changed

.aegir.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,3 @@ node_modules
3131
coverage
3232

3333
dist
34-
lib

.travis.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
21
sudo: false
32
language: node_js
4-
node_js:
5-
- 4
6-
- 5
3+
matrix:
4+
include:
5+
- node_js: 4
6+
env: CXX=g++-4.8
7+
- node_js: 6
8+
env:
9+
- SAUCE=true
10+
- CXX=g++-4.8
11+
- node_js: stable
12+
env: CXX=g++-4.8
713

814
# Make sure we have new NPM.
915
before_install:
@@ -14,12 +20,17 @@ script:
1420
- npm test
1521
- npm run coverage
1622

17-
addons:
18-
firefox: 'latest'
19-
2023
before_script:
2124
- export DISPLAY=:99.0
2225
- sh -e /etc/init.d/xvfb start
2326

2427
after_success:
25-
- npm run coverage-publish
28+
- npm run coverage-publish
29+
30+
addons:
31+
firefox: 'latest'
32+
apt:
33+
sources:
34+
- ubuntu-toolchain-r-test
35+
packages:
36+
- g++-4.8

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
[![Travis CI](https://travis-ci.org/libp2p/js-libp2p-identify.svg?branch=master)](https://travis-ci.org/libp2p/js-libp2p-identify)
88
[![Circle CI](https://circleci.com/gh/libp2p/js-libp2p-identify.svg?style=svg)](https://circleci.com/gh/libp2p/js-libp2p-identify)
99
[![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)
10+
![](https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square)
11+
![](https://img.shields.io/badge/Node.js-%3E%3D4.0.0-orange.svg?style=flat-square)
12+
13+
[![Sauce Test Status](https://saucelabs.com/browser-matrix/libp2p-js-identify.svg)](https://saucelabs.com/u/libp2p-js-identify)
1014

1115
> libp2p Identify Protocol
1216

package.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
"name": "libp2p-identify",
33
"version": "0.2.0",
44
"description": "libp2p Identify Protocol",
5-
"main": "lib/index.js",
6-
"jsnext:main": "src/index.js",
5+
"main": "src/index.js",
76
"scripts": {
87
"lint": "aegir-lint",
98
"build": "aegir-build",
@@ -21,7 +20,7 @@
2120
"test"
2221
],
2322
"engines": {
24-
"node": "^4.3.0"
23+
"node": ">=4.0.0"
2524
},
2625
"repository": {
2726
"type": "git",
@@ -38,22 +37,22 @@
3837
},
3938
"homepage": "https://github.com/libp2p/js-libp2p-identify#readme",
4039
"devDependencies": {
41-
"aegir": "^8.0.0",
40+
"aegir": "^9.0.1",
4241
"chai": "^3.5.0",
4342
"pre-commit": "^1.1.3",
4443
"pull-pair": "^1.1.0"
4544
},
4645
"dependencies": {
47-
"multiaddr": "^2.0.2",
48-
"peer-id": "^0.7.0",
49-
"peer-info": "^0.7.0",
46+
"multiaddr": "^2.0.3",
47+
"peer-id": "^0.8.0",
48+
"peer-info": "^0.8.0",
5049
"protocol-buffers": "^3.1.6",
51-
"pull-length-prefixed": "^1.0.0",
52-
"pull-stream": "^3.4.3"
50+
"pull-length-prefixed": "^1.2.0",
51+
"pull-stream": "^3.5.0"
5352
},
5453
"contributors": [
5554
"David Dias <[email protected]>",
5655
"dignifiedquire <[email protected]>",
5756
"greenkeeperio-bot <[email protected]>"
5857
]
59-
}
58+
}

src/dialer.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@ module.exports = (conn, callback) => {
1919

2020
const input = msg.decode(data[0])
2121

22-
const id = PeerId.createFromPubKey(input.publicKey)
23-
const info = new PeerInfo(id)
24-
input.listenAddrs
25-
.map(multiaddr)
26-
.forEach((ma) => info.multiaddr.add(ma))
27-
28-
callback(null, info, getObservedAddrs(input))
22+
PeerId.createFromPubKey(input.publicKey, (err, id) => {
23+
if (err) {
24+
return callback(err)
25+
}
26+
27+
const info = new PeerInfo(id)
28+
input.listenAddrs
29+
.map(multiaddr)
30+
.forEach((ma) => info.multiaddr.add(ma))
31+
32+
callback(null, info, getObservedAddrs(input))
33+
})
2934
})
3035
)
3136
}

src/message/identify.proto renamed to src/message.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
message Identify {
1+
'use strict'
22

3+
const protobuf = require('protocol-buffers')
4+
const schema = new Buffer(`
5+
message Identify {
36
// protocolVersion determines compatibility between peers
47
optional string protocolVersion = 5; // e.g. ipfs/1.0.0
58
@@ -23,3 +26,6 @@ message Identify {
2326
// (DEPRECATED) protocols are the services this node is running
2427
// repeated string protocols = 3;
2528
}
29+
`)
30+
31+
module.exports = protobuf(schema).Identify

src/message/index.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/dialer.spec.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,20 @@ const msg = require('../src/message')
1212
const identify = require('../src')
1313

1414
describe('identify.dialer', () => {
15+
let original
16+
beforeEach((done) => {
17+
PeerInfo.create((err, info) => {
18+
if (err) {
19+
return done(err)
20+
}
21+
22+
original = info
23+
done()
24+
})
25+
})
26+
1527
it('works', (done) => {
1628
const p = pair()
17-
const original = new PeerInfo()
1829
original.multiaddr.add(multiaddr('/ip4/127.0.0.1/tcp/5002'))
1930
const input = msg.encode({
2031
protocolVersion: 'ipfs/0.1.0',

test/listener.spec.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,20 @@ const msg = require('../src/message')
1212
const identify = require('../src')
1313

1414
describe('identify.listener', () => {
15+
let info
16+
beforeEach((done) => {
17+
PeerInfo.create((err, _info) => {
18+
if (err) {
19+
return done(err)
20+
}
21+
22+
info = _info
23+
done()
24+
})
25+
})
26+
1527
it('works', (done) => {
1628
const p = pair()
17-
const info = new PeerInfo()
1829
info.multiaddr.add(multiaddr('/ip4/127.0.0.1/tcp/5002'))
1930
pull(
2031
p[1],

0 commit comments

Comments
 (0)