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

Async Crypto Endeavour #6

Merged
merged 8 commits into from
Nov 3, 2016
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions .aegir.js

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ node_modules
coverage

dist
lib
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ sudo: false
language: node_js
node_js:
- 4
- 5
- 6
- stable

# Make sure we have new NPM.
before_install:
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
[![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)
![](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/js-libp2p-identify.svg)](https://saucelabs.com/u/j
s-libp2p-identify)

> libp2p Identify Protocol

Expand Down
17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"name": "libp2p-identify",
"version": "0.2.0",
"description": "libp2p Identify Protocol",
"main": "lib/index.js",
"jsnext:main": "src/index.js",
"main": "src/index.js",
"scripts": {
"lint": "aegir-lint",
"build": "aegir-build",
Expand All @@ -21,7 +20,7 @@
"test"
],
"engines": {
"node": "^4.3.0"
"node": ">=4.0.0"
},
"repository": {
"type": "git",
Expand All @@ -38,22 +37,22 @@
},
"homepage": "https://github.com/libp2p/js-libp2p-identify#readme",
"devDependencies": {
"aegir": "^8.0.0",
"aegir": "^9.0.0",
"chai": "^3.5.0",
"pre-commit": "^1.1.3",
"pull-pair": "^1.1.0"
},
"dependencies": {
"multiaddr": "^2.0.2",
"multiaddr": "^2.0.3",
"peer-id": "^0.7.0",
"peer-info": "^0.7.0",
"peer-info": "^0.7.1",
"protocol-buffers": "^3.1.6",
"pull-length-prefixed": "^1.0.0",
"pull-stream": "^3.4.3"
"pull-length-prefixed": "^1.2.0",
"pull-stream": "^3.4.5"
},
"contributors": [
"David Dias <[email protected]>",
"dignifiedquire <[email protected]>",
"greenkeeperio-bot <[email protected]>"
]
}
}
19 changes: 12 additions & 7 deletions src/dialer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ module.exports = (conn, callback) => {

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

const id = PeerId.createFromPubKey(input.publicKey)
const info = new PeerInfo(id)
input.listenAddrs
.map(multiaddr)
.forEach((ma) => info.multiaddr.add(ma))

callback(null, info, getObservedAddrs(input))
PeerId.createFromPubKey(input.publicKey, (err, id) => {
if (err) {
return callback(err)
}

const info = new PeerInfo(id)
input.listenAddrs
.map(multiaddr)
.forEach((ma) => info.multiaddr.add(ma))

callback(null, info, getObservedAddrs(input))
})
})
)
}
Expand Down
8 changes: 7 additions & 1 deletion src/message/identify.proto → src/message.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
message Identify {
'use strict'

const protobuf = require('protocol-buffers')
const schema = new Buffer(`
message Identify {
// protocolVersion determines compatibility between peers
optional string protocolVersion = 5; // e.g. ipfs/1.0.0

Expand All @@ -23,3 +26,6 @@ message Identify {
// (DEPRECATED) protocols are the services this node is running
// repeated string protocols = 3;
}
`)

module.exports = protobuf(schema).Identify
8 changes: 0 additions & 8 deletions src/message/index.js

This file was deleted.

13 changes: 12 additions & 1 deletion test/dialer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,20 @@ const msg = require('../src/message')
const identify = require('../src')

describe('identify.dialer', () => {
let original
beforeEach((done) => {
PeerInfo.create((err, info) => {
if (err) {
return done(err)
}

original = info
done()
})
})

it('works', (done) => {
const p = pair()
const original = new PeerInfo()
original.multiaddr.add(multiaddr('/ip4/127.0.0.1/tcp/5002'))
const input = msg.encode({
protocolVersion: 'ipfs/0.1.0',
Expand Down
13 changes: 12 additions & 1 deletion test/listener.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,20 @@ const msg = require('../src/message')
const identify = require('../src')

describe('identify.listener', () => {
let info
beforeEach((done) => {
PeerInfo.create((err, _info) => {
if (err) {
return done(err)
}

info = _info
done()
})
})

it('works', (done) => {
const p = pair()
const info = new PeerInfo()
info.multiaddr.add(multiaddr('/ip4/127.0.0.1/tcp/5002'))
pull(
p[1],
Expand Down