Compare commits

...

5 Commits

Author SHA1 Message Date
2673ae48b0 chore: release version v0.11.1 2017-10-13 17:17:16 +02:00
9a4425f5ba chore: update contributors 2017-10-13 17:17:16 +02:00
50d6a7b7cf chre: fix linting 2017-10-13 17:17:11 +02:00
0a515f8fda chore: update deps and CI config 2017-10-13 17:15:36 +02:00
11c4f451f4 feat: relay filtering
* feat: filter IPFS addrs correctly

* feat: mafmt addrs now support /ipfs no need for ad-hoc filtering

* feat: skip p2p-circuit addresses
2017-10-13 17:13:28 +02:00
5 changed files with 236 additions and 22 deletions

198
CHANGELOG.md Normal file
View File

@ -0,0 +1,198 @@
<a name="0.11.1"></a>
## [0.11.1](https://github.com/libp2p/js-libp2p-tcp/compare/v0.11.0...v0.11.1) (2017-10-13)
### Features
* relay filtering ([11c4f45](https://github.com/libp2p/js-libp2p-tcp/commit/11c4f45))
<a name="0.11.0"></a>
# [0.11.0](https://github.com/libp2p/js-libp2p-tcp/compare/v0.10.2...v0.11.0) (2017-09-03)
### Features
* p2p addrs situation ([#82](https://github.com/libp2p/js-libp2p-tcp/issues/82)) ([a54bb83](https://github.com/libp2p/js-libp2p-tcp/commit/a54bb83))
<a name="0.10.2"></a>
## [0.10.2](https://github.com/libp2p/js-libp2p-tcp/compare/v0.10.1...v0.10.2) (2017-07-22)
<a name="0.10.1"></a>
## [0.10.1](https://github.com/libp2p/js-libp2p-tcp/compare/v0.10.0...v0.10.1) (2017-04-13)
### Bug Fixes
* catch errors on incomming sockets ([e204517](https://github.com/libp2p/js-libp2p-tcp/commit/e204517))
<a name="0.10.0"></a>
# [0.10.0](https://github.com/libp2p/js-libp2p-tcp/compare/v0.9.4...v0.10.0) (2017-03-27)
### Bug Fixes
* **dial:** proper error handling on dial ([#77](https://github.com/libp2p/js-libp2p-tcp/issues/77)) ([4d4f295](https://github.com/libp2p/js-libp2p-tcp/commit/4d4f295))
<a name="0.9.4"></a>
## [0.9.4](https://github.com/libp2p/js-libp2p-tcp/compare/v0.9.3...v0.9.4) (2017-03-21)
<a name="0.9.3"></a>
## [0.9.3](https://github.com/libp2p/js-libp2p-tcp/compare/v0.9.2...v0.9.3) (2017-02-09)
<a name="0.9.2"></a>
## [0.9.2](https://github.com/libp2p/js-libp2p-tcp/compare/v0.9.1...v0.9.2) (2017-02-09)
<a name="0.9.1"></a>
## [0.9.1](https://github.com/libp2p/js-libp2p-tcp/compare/v0.9.0...v0.9.1) (2016-11-03)
<a name="0.9.0"></a>
# [0.9.0](https://github.com/libp2p/js-libp2p-tcp/compare/v0.8.1...v0.9.0) (2016-11-03)
### Bug Fixes
* **deps:** remove unused pull dep ([06689e3](https://github.com/libp2p/js-libp2p-tcp/commit/06689e3))
<a name="0.8.1"></a>
## [0.8.1](https://github.com/libp2p/js-libp2p-tcp/compare/v0.8.0...v0.8.1) (2016-09-06)
<a name="0.8.0"></a>
# [0.8.0](https://github.com/libp2p/js-libp2p-tcp/compare/v0.7.4...v0.8.0) (2016-09-06)
### Features
* **deps:** update to published deps ([da8ee21](https://github.com/libp2p/js-libp2p-tcp/commit/da8ee21))
* **pull:** migration to pull-streams ([5e89a26](https://github.com/libp2p/js-libp2p-tcp/commit/5e89a26))
* **readme:** add pull-streams documentation ([d9f65e0](https://github.com/libp2p/js-libp2p-tcp/commit/d9f65e0))
<a name="0.7.4"></a>
## [0.7.4](https://github.com/libp2p/js-libp2p-tcp/compare/v0.7.3...v0.7.4) (2016-08-03)
<a name="0.7.3"></a>
## [0.7.3](https://github.com/libp2p/js-libp2p-tcp/compare/v0.7.2...v0.7.3) (2016-06-26)
<a name="0.7.2"></a>
## [0.7.2](https://github.com/libp2p/js-libp2p-tcp/compare/v0.7.1...v0.7.2) (2016-06-23)
<a name="0.7.1"></a>
## [0.7.1](https://github.com/libp2p/js-libp2p-tcp/compare/v0.7.0...v0.7.1) (2016-06-23)
### Bug Fixes
* error was passed in duplicate ([9ac5cca](https://github.com/libp2p/js-libp2p-tcp/commit/9ac5cca))
<a name="0.7.0"></a>
# [0.7.0](https://github.com/libp2p/js-libp2p-tcp/compare/v0.6.2...v0.7.0) (2016-06-22)
<a name="0.6.2"></a>
## [0.6.2](https://github.com/libp2p/js-libp2p-tcp/compare/v0.6.1...v0.6.2) (2016-06-01)
### Bug Fixes
* address cr ([2ed01e8](https://github.com/libp2p/js-libp2p-tcp/commit/2ed01e8))
* destroy hanging connections after timeout ([4a12169](https://github.com/libp2p/js-libp2p-tcp/commit/4a12169))
<a name="0.6.1"></a>
## [0.6.1](https://github.com/libp2p/js-libp2p-tcp/compare/v0.6.0...v0.6.1) (2016-05-29)
<a name="0.6.0"></a>
# [0.6.0](https://github.com/libp2p/js-libp2p-tcp/compare/v0.5.3...v0.6.0) (2016-05-22)
<a name="0.5.3"></a>
## [0.5.3](https://github.com/libp2p/js-libp2p-tcp/compare/v0.5.2...v0.5.3) (2016-05-22)
<a name="0.5.2"></a>
## [0.5.2](https://github.com/libp2p/js-libp2p-tcp/compare/v0.5.1...v0.5.2) (2016-05-09)
<a name="0.5.1"></a>
## [0.5.1](https://github.com/libp2p/js-libp2p-tcp/compare/v0.5.0...v0.5.1) (2016-05-08)
<a name="0.5.0"></a>
# [0.5.0](https://github.com/libp2p/js-libp2p-tcp/compare/v0.4.0...v0.5.0) (2016-04-25)
<a name="0.4.0"></a>
# [0.4.0](https://github.com/libp2p/js-libp2p-tcp/compare/v0.3.0...v0.4.0) (2016-03-14)
<a name="0.3.0"></a>
# [0.3.0](https://github.com/libp2p/js-libp2p-tcp/compare/v0.2.1...v0.3.0) (2016-03-10)
<a name="0.2.1"></a>
## [0.2.1](https://github.com/libp2p/js-libp2p-tcp/compare/v0.2.0...v0.2.1) (2016-03-04)
<a name="0.2.0"></a>
# [0.2.0](https://github.com/libp2p/js-libp2p-tcp/compare/v0.1.2...v0.2.0) (2016-03-04)
<a name="0.1.2"></a>
## [0.1.2](https://github.com/libp2p/js-libp2p-tcp/compare/v0.1.1...v0.1.2) (2015-10-29)
<a name="0.1.1"></a>
## [0.1.1](https://github.com/libp2p/js-libp2p-tcp/compare/v0.1.0...v0.1.1) (2015-09-17)
<a name="0.1.0"></a>
# 0.1.0 (2015-09-16)

View File

@ -6,8 +6,12 @@ dependencies:
pre: pre:
- google-chrome --version - google-chrome --version
- curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb - curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- for v in $(curl http://archive.ubuntu.com/ubuntu/pool/main/n/nss/ | grep "href=" | grep "libnss3.*deb\"" -o | grep -o "libnss3.*deb" | grep "3.28" | grep "14.04"); do curl -L -o $v http://archive.ubuntu.com/ubuntu/pool/main/n/nss/$v; done && rm libnss3-tools*_i386.deb libnss3-dev*_i386.deb
- sudo dpkg -i google-chrome.deb || true - sudo dpkg -i google-chrome.deb || true
- sudo dpkg -i libnss3*.deb || true
- sudo apt-get update - sudo apt-get update
- sudo apt-get install -f || true
- sudo dpkg -i libnss3*.deb
- sudo apt-get install -f - sudo apt-get install -f
- sudo apt-get install --only-upgrade lsb-base - sudo apt-get install --only-upgrade lsb-base
- sudo dpkg -i google-chrome.deb - sudo dpkg -i google-chrome.deb

View File

@ -1,16 +1,16 @@
{ {
"name": "libp2p-tcp", "name": "libp2p-tcp",
"version": "0.11.0", "version": "0.11.1",
"description": "Node.js implementation of the TCP module that libp2p uses, which implements the interface-connection and interface-transport interfaces", "description": "Node.js implementation of the TCP module that libp2p uses, which implements the interface-connection and interface-transport interfaces",
"main": "src/index.js", "main": "src/index.js",
"scripts": { "scripts": {
"lint": "aegir-lint", "lint": "aegir lint",
"test": "aegir-test --env node", "test": "aegir test --target node",
"release": "aegir-release --env no-build", "release": "aegir release --no-build",
"release-minor": "aegir-release --type minor --env no-build", "release-minor": "aegir release --type minor --no-build",
"release-major": "aegir-release --type major --env no-build", "release-major": "aegir-release --type major --no-build",
"coverage": "aegir-coverage", "coverage": "aegir coverage",
"coverage-publish": "aegir-coverage publish" "coverage-publish": "aegir coverage --provider coveralls"
}, },
"pre-commit": [ "pre-commit": [
"lint", "lint",
@ -34,26 +34,27 @@
"npm": ">=3.0.0" "npm": ">=3.0.0"
}, },
"devDependencies": { "devDependencies": {
"aegir": "^11.0.2", "aegir": "^12.0.8",
"chai": "^4.1.2", "chai": "^4.1.2",
"dirty-chai": "^2.0.1", "dirty-chai": "^2.0.1",
"interface-transport": "~0.3.5", "interface-transport": "~0.3.5",
"lodash.isfunction": "^3.0.8", "lodash.isfunction": "^3.0.8",
"pre-commit": "^1.2.2", "pre-commit": "^1.2.2",
"pull-stream": "^3.6.0" "pull-stream": "^3.6.1"
}, },
"dependencies": { "dependencies": {
"interface-connection": "~0.3.2", "interface-connection": "~0.3.2",
"ip-address": "^5.8.8", "ip-address": "^5.8.8",
"lodash.includes": "^4.3.0", "lodash.includes": "^4.3.0",
"lodash.isfunction": "^3.0.8", "lodash.isfunction": "^3.0.8",
"mafmt": "^3.0.0", "mafmt": "^3.0.1",
"multiaddr": "^3.0.0", "multiaddr": "^3.0.1",
"once": "^1.4.0", "once": "^1.4.0",
"stream-to-pull-stream": "^1.7.2" "stream-to-pull-stream": "^1.7.2"
}, },
"contributors": [ "contributors": [
"David Dias <daviddias.p@gmail.com>", "David Dias <daviddias.p@gmail.com>",
"Dmitriy Ryajov <dryajov@gmail.com>",
"Evan Schwartz <evan.mark.schwartz@gmail.com>", "Evan Schwartz <evan.mark.schwartz@gmail.com>",
"Friedel Ziegelmayer <dignifiedquire@gmail.com>", "Friedel Ziegelmayer <dignifiedquire@gmail.com>",
"Greenkeeper <support@greenkeeper.io>", "Greenkeeper <support@greenkeeper.io>",
@ -62,4 +63,4 @@
"Richard Littauer <richard.littauer@gmail.com>", "Richard Littauer <richard.littauer@gmail.com>",
"Stephen Whitmore <stephen.whitmore@gmail.com>" "Stephen Whitmore <stephen.whitmore@gmail.com>"
] ]
} }

View File

@ -67,10 +67,16 @@ class TCP {
if (!Array.isArray(multiaddrs)) { if (!Array.isArray(multiaddrs)) {
multiaddrs = [multiaddrs] multiaddrs = [multiaddrs]
} }
return multiaddrs.filter((ma) => { return multiaddrs.filter((ma) => {
if (includes(ma.protoNames(), 'p2p-circuit')) {
return false
}
if (includes(ma.protoNames(), 'ipfs')) { if (includes(ma.protoNames(), 'ipfs')) {
ma = ma.decapsulate('ipfs') ma = ma.decapsulate('ipfs')
} }
return mafmt.TCP.matches(ma) return mafmt.TCP.matches(ma)
}) })
} }

View File

@ -144,7 +144,7 @@ describe('dial', () => {
listener = tcp.createListener((conn) => { listener = tcp.createListener((conn) => {
pull( pull(
conn, conn,
pull.map((x) => new Buffer(x.toString() + '!')), pull.map((x) => Buffer.from(x.toString() + '!')),
conn conn
) )
}) })
@ -161,7 +161,7 @@ describe('dial', () => {
tcp.dial(ma), tcp.dial(ma),
pull.collect((err, values) => { pull.collect((err, values) => {
expect(err).to.not.exist() expect(err).to.not.exist()
expect(values).to.eql([new Buffer('hey!')]) expect(values).to.eql([Buffer.from('hey!')])
done() done()
}) })
) )
@ -190,7 +190,7 @@ describe('dial', () => {
pull.collect((err, values) => { pull.collect((err, values) => {
expect(err).to.not.exist() expect(err).to.not.exist()
expect(values).to.be.eql([new Buffer('hey')]) expect(values).to.be.eql([Buffer.from('hey')])
listener.close(done) listener.close(done)
}) })
@ -254,7 +254,7 @@ describe('dial', () => {
conn, conn,
pull.collect((err, res) => { pull.collect((err, res) => {
expect(err).to.not.exist() expect(err).to.not.exist()
expect(res).to.be.eql([new Buffer('hey!')]) expect(res).to.be.eql([Buffer.from('hey!')])
done() done()
}) })
) )
@ -273,8 +273,11 @@ describe('filter addrs', () => {
const mh2 = multiaddr('/ip4/127.0.0.1/udp/9090') const mh2 = multiaddr('/ip4/127.0.0.1/udp/9090')
const mh3 = multiaddr('/ip4/127.0.0.1/tcp/9090/http') const mh3 = multiaddr('/ip4/127.0.0.1/tcp/9090/http')
const mh4 = multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw') const mh4 = multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw')
const mh5 = multiaddr('/ip4/127.0.0.1/tcp/9090/http/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw')
const mh6 = multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw' +
'/p2p-circuit/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw')
const valid = tcp.filter([mh1, mh2, mh3, mh4]) const valid = tcp.filter([mh1, mh2, mh3, mh4, mh5, mh6])
expect(valid.length).to.equal(2) expect(valid.length).to.equal(2)
expect(valid[0]).to.deep.equal(mh1) expect(valid[0]).to.deep.equal(mh1)
expect(valid[1]).to.deep.equal(mh4) expect(valid[1]).to.deep.equal(mh4)
@ -349,6 +352,7 @@ describe('valid Connection', () => {
const conn = tcp.dial(ma) const conn = tcp.dial(ma)
pull(conn, pull.onEnd(endHandler)) pull(conn, pull.onEnd(endHandler))
function endHandler () { function endHandler () {
conn.getPeerInfo((err, peerInfo) => { conn.getPeerInfo((err, peerInfo) => {
expect(err).to.exist() expect(err).to.exist()
@ -375,6 +379,7 @@ describe('valid Connection', () => {
const conn = tcp.dial(ma) const conn = tcp.dial(ma)
pull(conn, pull.onEnd(endHandler)) pull(conn, pull.onEnd(endHandler))
function endHandler () { function endHandler () {
conn.setPeerInfo('arroz') conn.setPeerInfo('arroz')
conn.getPeerInfo((err, peerInfo) => { conn.getPeerInfo((err, peerInfo) => {
@ -420,7 +425,7 @@ describe('Connection wrap', () => {
connWrap, connWrap,
pull.collect((err, chunks) => { pull.collect((err, chunks) => {
expect(err).to.not.exist() expect(err).to.not.exist()
expect(chunks).to.be.eql([new Buffer('hey')]) expect(chunks).to.be.eql([Buffer.from('hey')])
connWrap.getPeerInfo((err, peerInfo) => { connWrap.getPeerInfo((err, peerInfo) => {
expect(err).to.not.exist() expect(err).to.not.exist()
@ -439,7 +444,7 @@ describe('Connection wrap', () => {
connWrap, connWrap,
pull.collect((err, chunks) => { pull.collect((err, chunks) => {
expect(err).to.not.exist() expect(err).to.not.exist()
expect(chunks).to.be.eql([new Buffer('hey')]) expect(chunks).to.be.eql([Buffer.from('hey')])
done() done()
}) })
) )
@ -465,7 +470,7 @@ describe('Connection wrap', () => {
connWrap, connWrap,
pull.collect((err, chunks) => { pull.collect((err, chunks) => {
expect(err).to.not.exist() expect(err).to.not.exist()
expect(chunks).to.be.eql([new Buffer('hey')]) expect(chunks).to.be.eql([Buffer.from('hey')])
done() done()
}) })
) )
@ -492,7 +497,7 @@ describe('Connection wrap', () => {
connWrap3, connWrap3,
pull.collect((err, chunks) => { pull.collect((err, chunks) => {
expect(err).to.not.exist() expect(err).to.not.exist()
expect(chunks).to.be.eql([new Buffer('hey')]) expect(chunks).to.be.eql([Buffer.from('hey')])
connWrap3.getPeerInfo((err, peerInfo) => { connWrap3.getPeerInfo((err, peerInfo) => {
expect(err).to.not.exist() expect(err).to.not.exist()
expect(peerInfo).to.equal('inner doll') expect(peerInfo).to.equal('inner doll')