mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-07-09 13:51:34 +00:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
c7eac39012 | |||
9d5f2a35ae | |||
7477c5c4a4 | |||
ba275558bb | |||
9b32d25de9 | |||
3c16dbe93e | |||
2dbcc4b126 | |||
27481e7edc | |||
aa199362c2 | |||
3694e02eaa |
32
.travis.yml
32
.travis.yml
@ -1,32 +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.
|
|
||||||
sudo: false
|
|
||||||
language: node_js
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- node_js: 6
|
|
||||||
env: CXX=g++-4.8
|
|
||||||
- node_js: 8
|
|
||||||
env: CXX=g++-4.8
|
|
||||||
# - node_js: stable
|
|
||||||
# env: CXX=g++-4.8
|
|
||||||
|
|
||||||
script:
|
|
||||||
- npm run lint
|
|
||||||
- npm run test
|
|
||||||
- npm run coverage
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- export DISPLAY=:99.0
|
|
||||||
- sh -e /etc/init.d/xvfb start
|
|
||||||
|
|
||||||
after_success:
|
|
||||||
- npm run coverage-publish
|
|
||||||
|
|
||||||
addons:
|
|
||||||
firefox: 'latest'
|
|
||||||
apt:
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
packages:
|
|
||||||
- g++-4.8
|
|
20
CHANGELOG.md
20
CHANGELOG.md
@ -1,3 +1,23 @@
|
|||||||
|
<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)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add the ability to verify expected peer data ([aa19936](https://github.com/libp2p/js-libp2p-identify/commit/aa19936))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="0.7.1"></a>
|
<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)
|
## [0.7.1](https://github.com/libp2p/js-libp2p-identify/compare/v0.7.0...v0.7.1) (2018-04-30)
|
||||||
|
|
||||||
|
@ -13,6 +13,10 @@
|
|||||||
|
|
||||||
> libp2p Identify Protocol
|
> libp2p Identify Protocol
|
||||||
|
|
||||||
|
## Lead Maintainer
|
||||||
|
|
||||||
|
[Jacob Heun](https://github.com/jacobheun)
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
Identify is a STUN protocol, used by libp2p-swarm in order to broadcast and learn about the `ip:port` pairs a specific peer is available through and to know when a new stream muxer is established, so a conn can be reused.
|
Identify is a STUN protocol, used by libp2p-swarm in order to broadcast and learn about the `ip:port` pairs a specific peer is available through and to know when a new stream muxer is established, so a conn can be reused.
|
||||||
|
29
appveyor.yml
29
appveyor.yml
@ -1,29 +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.
|
|
||||||
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
|
|
15
circle.yml
15
circle.yml
@ -1,15 +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.
|
|
||||||
machine:
|
|
||||||
node:
|
|
||||||
version: stable
|
|
||||||
|
|
||||||
dependencies:
|
|
||||||
pre:
|
|
||||||
- google-chrome --version
|
|
||||||
- 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 install -f
|
|
||||||
- sudo apt-get install --only-upgrade lsb-base
|
|
||||||
- sudo dpkg -i google-chrome.deb
|
|
||||||
- google-chrome --version
|
|
24
package.json
24
package.json
@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "libp2p-identify",
|
"name": "libp2p-identify",
|
||||||
"version": "0.7.1",
|
"version": "0.7.4",
|
||||||
"description": "libp2p Identify Protocol",
|
"description": "libp2p Identify Protocol",
|
||||||
|
"leadMaintainer": "Jacob Heun <jacobheun@gmail.com>",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "aegir lint",
|
"lint": "aegir lint",
|
||||||
@ -14,7 +15,7 @@
|
|||||||
"release-major": "aegir release --type major",
|
"release-major": "aegir release --type major",
|
||||||
"coverage": "aegir coverage"
|
"coverage": "aegir coverage"
|
||||||
},
|
},
|
||||||
"pre-commit": [
|
"pre-push": [
|
||||||
"lint",
|
"lint",
|
||||||
"test"
|
"test"
|
||||||
],
|
],
|
||||||
@ -30,33 +31,34 @@
|
|||||||
"IPFS",
|
"IPFS",
|
||||||
"libp2p"
|
"libp2p"
|
||||||
],
|
],
|
||||||
"author": "David Dias <daviddias@ipfs.io>",
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/libp2p/js-libp2p-identify/issues"
|
"url": "https://github.com/libp2p/js-libp2p-identify/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/libp2p/js-libp2p-identify#readme",
|
"homepage": "https://github.com/libp2p/js-libp2p-identify#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"aegir": "^13.1.0",
|
"aegir": "^18.0.2",
|
||||||
"chai": "^4.1.2",
|
"chai": "^4.2.0",
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
"pre-commit": "^1.2.2",
|
|
||||||
"pull-pair": "^1.1.0"
|
"pull-pair": "^1.1.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"multiaddr": "^5.0.0",
|
"multiaddr": "^6.0.2",
|
||||||
"peer-id": "~0.10.7",
|
"peer-id": "~0.12.1",
|
||||||
"peer-info": "~0.14.1",
|
"peer-info": "~0.15.0",
|
||||||
"protons": "^1.0.1",
|
"protons": "^1.0.1",
|
||||||
"pull-length-prefixed": "^1.3.0",
|
"pull-length-prefixed": "^1.3.1",
|
||||||
"pull-stream": "^3.6.7"
|
"pull-stream": "^3.6.9"
|
||||||
},
|
},
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"David Dias <daviddias.p@gmail.com>",
|
"David Dias <daviddias.p@gmail.com>",
|
||||||
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
|
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
|
||||||
"Greenkeeper <support@greenkeeper.io>",
|
"Greenkeeper <support@greenkeeper.io>",
|
||||||
|
"Jacob Heun <jacobheun@gmail.com>",
|
||||||
|
"Jacob Heun <jake@andyet.net>",
|
||||||
"Maciej Krüger <mkg20001@gmail.com>",
|
"Maciej Krüger <mkg20001@gmail.com>",
|
||||||
"Richard Littauer <richard.littauer@gmail.com>",
|
"Richard Littauer <richard.littauer@gmail.com>",
|
||||||
|
"Vasco Santos <vasco.santos@moxy.studio>",
|
||||||
"ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ <victorbjelkholm@gmail.com>"
|
"ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ <victorbjelkholm@gmail.com>"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,13 @@ const lp = require('pull-length-prefixed')
|
|||||||
|
|
||||||
const msg = require('./message')
|
const msg = require('./message')
|
||||||
|
|
||||||
module.exports = (conn, callback) => {
|
module.exports = (conn, expectedPeerInfo, callback) => {
|
||||||
|
if (typeof expectedPeerInfo === 'function') {
|
||||||
|
callback = expectedPeerInfo
|
||||||
|
expectedPeerInfo = null
|
||||||
|
console.warn('WARNING: no expected peer info was given, identify will not be able to verify peer integrity')
|
||||||
|
}
|
||||||
|
|
||||||
pull(
|
pull(
|
||||||
conn,
|
conn,
|
||||||
lp.decode(),
|
lp.decode(),
|
||||||
@ -30,6 +36,10 @@ module.exports = (conn, callback) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const peerInfo = new PeerInfo(id)
|
const peerInfo = new PeerInfo(id)
|
||||||
|
if (expectedPeerInfo && expectedPeerInfo.id.toB58String() !== id.toB58String()) {
|
||||||
|
return callback(new Error('invalid peer'))
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
input.listenAddrs
|
input.listenAddrs
|
||||||
.map(multiaddr)
|
.map(multiaddr)
|
||||||
@ -59,7 +69,7 @@ function getObservedAddrs (input) {
|
|||||||
|
|
||||||
let addrs = input.observedAddr
|
let addrs = input.observedAddr
|
||||||
|
|
||||||
if (!Array.isArray(input.observedAddr)) {
|
if (!Array.isArray(addrs)) {
|
||||||
addrs = [addrs]
|
addrs = [addrs]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,3 +4,4 @@ exports = module.exports
|
|||||||
exports.multicodec = '/ipfs/id/1.0.0'
|
exports.multicodec = '/ipfs/id/1.0.0'
|
||||||
exports.listener = require('./listener')
|
exports.listener = require('./listener')
|
||||||
exports.dialer = require('./dialer')
|
exports.dialer = require('./dialer')
|
||||||
|
exports.message = require('./message')
|
||||||
|
@ -108,4 +108,34 @@ describe('identify.dialer', () => {
|
|||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should return an error with mismatched peerInfo data', (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
|
||||||
|
})
|
||||||
|
|
||||||
|
PeerInfo.create((err, info) => {
|
||||||
|
if (err) {
|
||||||
|
return done(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
pull(
|
||||||
|
pull.values([input]),
|
||||||
|
lp.encode(),
|
||||||
|
p[0]
|
||||||
|
)
|
||||||
|
|
||||||
|
identify.dialer(p[1], info, (err, peerInfo) => {
|
||||||
|
expect(err).to.exist()
|
||||||
|
expect(peerInfo).to.not.exist()
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user