This repository has been archived by the owner on Aug 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6cbcf23
commit d1e337e
Showing
8 changed files
with
177 additions
and
29,569 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,12 +47,12 @@ | |
"libp2p-tcp": "^0.7.4", | ||
"libp2p-webrtc-star": "^0.3.2", | ||
"libp2p-websockets": "^0.7.1", | ||
"pre-commit": "^1.1.2", | ||
"pre-commit": "^1.1.3", | ||
"stream-pair": "^1.0.3", | ||
"webrtcsupport": "^2.2.0" | ||
}, | ||
"dependencies": { | ||
"babel-runtime": "^6.6.1", | ||
"babel-runtime": "^6.9.0", | ||
"bl": "^1.1.2", | ||
"browserify-zlib": "github:ipfs/browserify-zlib", | ||
"debug": "^2.2.0", | ||
|
@@ -61,8 +61,9 @@ | |
"ip-address": "^5.8.0", | ||
"length-prefixed-stream": "^1.5.0", | ||
"libp2p-identify": "^0.1.3", | ||
"libp2p-secio": "^0.3.0", | ||
"lodash.contains": "^2.4.3", | ||
"multiaddr": "^2.0.0", | ||
"multiaddr": "^2.0.2", | ||
"multistream-select": "^0.9.0", | ||
"peer-id": "^0.7.0", | ||
"peer-info": "^0.7.0", | ||
|
@@ -77,4 +78,4 @@ | |
"Richard Littauer <[email protected]>", | ||
"dignifiedquire <[email protected]>" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict' | ||
|
||
const SecureSession = require('libp2p-secio').SecureSession | ||
|
||
exports = module.exports | ||
|
||
exports.create = (local, insecure) => { | ||
const session = new SecureSession(local, local.privKey, insecure) | ||
return session.secureStream() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
secio: '/secio/1.0.0', | ||
plaintext: '/plaintext/1.0.0' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,128 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
describe('secio conn upgrade (on TCP)', function () { | ||
this.timeout(20000) | ||
const expect = require('chai').expect | ||
|
||
it.skip('add', (done) => {}) | ||
it.skip('dial', (done) => {}) | ||
it.skip('tls on a muxed stream (not the full conn)', (done) => {}) | ||
const parallel = require('run-parallel') | ||
const multiaddr = require('multiaddr') | ||
const Peer = require('peer-info') | ||
const TCP = require('libp2p-tcp') | ||
const multiplex = require('libp2p-spdy') | ||
|
||
const Swarm = require('../src') | ||
|
||
describe.skip('secio conn upgrade (on TCP)', function () { | ||
this.timeout(60 * 1000) | ||
|
||
var swarmA | ||
var peerA | ||
var swarmB | ||
var peerB | ||
var swarmC | ||
var peerC | ||
|
||
before((done) => { | ||
peerA = new Peer() | ||
peerB = new Peer() | ||
peerC = new Peer() | ||
|
||
// console.log('peer A', peerA.id.toB58String()) | ||
// console.log('peer B', peerB.id.toB58String()) | ||
// console.log('peer C', peerC.id.toB58String()) | ||
|
||
peerA.multiaddr.add(multiaddr('/ip4/127.0.0.1/tcp/9001')) | ||
peerB.multiaddr.add(multiaddr('/ip4/127.0.0.1/tcp/9002')) | ||
peerC.multiaddr.add(multiaddr('/ip4/127.0.0.1/tcp/9003')) | ||
|
||
swarmA = new Swarm(peerA) | ||
swarmB = new Swarm(peerB) | ||
swarmC = new Swarm(peerC) | ||
|
||
swarmA.encrypt = true | ||
swarmB.encrypt = true | ||
swarmC.encrypt = true | ||
|
||
swarmA.transport.add('tcp', new TCP()) | ||
swarmB.transport.add('tcp', new TCP()) | ||
swarmC.transport.add('tcp', new TCP()) | ||
|
||
parallel([ | ||
(cb) => swarmA.transport.listen('tcp', {}, null, cb), | ||
(cb) => swarmB.transport.listen('tcp', {}, null, cb), | ||
(cb) => swarmC.transport.listen('tcp', {}, null, cb) | ||
], done) | ||
}) | ||
|
||
after((done) => { | ||
console.log('closing connections') | ||
parallel([ | ||
(cb) => swarmA.close(cb), | ||
(cb) => swarmB.close(cb), | ||
(cb) => swarmC.close(cb) | ||
], (err) => { | ||
console.log('after', err) | ||
done() | ||
}) | ||
}) | ||
|
||
it('add', () => { | ||
swarmA.connection.addStreamMuxer(multiplex) | ||
swarmB.connection.addStreamMuxer(multiplex) | ||
swarmC.connection.addStreamMuxer(multiplex) | ||
}) | ||
|
||
it('handle + dial on protocol', (done) => { | ||
swarmB.handle('/abacaxi/1.0.0', (conn) => { | ||
conn.pipe(conn) | ||
}) | ||
|
||
swarmA.dial(peerB, '/abacaxi/1.0.0', (err, conn) => { | ||
expect(err).to.not.exist | ||
expect(Object.keys(swarmA.muxedConns).length).to.equal(1) | ||
conn.end() | ||
|
||
conn.on('data', () => {}) // let it flow.. let it flooooow | ||
conn.on('end', done) | ||
}) | ||
}) | ||
|
||
it.skip('dial to warm conn', (done) => { | ||
swarmB.dial(peerA, (err) => { | ||
expect(err).to.not.exist | ||
expect(Object.keys(swarmB.conns).length).to.equal(0) | ||
expect(Object.keys(swarmB.muxedConns).length).to.equal(1) | ||
done() | ||
}) | ||
}) | ||
|
||
it.skip('dial on protocol, reuse warmed conn', (done) => { | ||
swarmA.handle('/papaia/1.0.0', (conn) => { | ||
conn.pipe(conn) | ||
conn.on('error', (err) => { throw err }) | ||
}) | ||
|
||
swarmB.dial(peerA, '/papaia/1.0.0', (err, conn) => { | ||
expect(err).to.not.exist | ||
expect(Object.keys(swarmB.conns).length).to.equal(0) | ||
expect(Object.keys(swarmB.muxedConns).length).to.equal(1) | ||
conn.end() | ||
conn.on('error', (err) => { throw err }) | ||
conn.on('data', () => {}) // let it flow.. let it flooooow | ||
conn.on('end', done) | ||
}) | ||
}) | ||
|
||
it.skip('enable identify to reuse incomming muxed conn', (done) => { | ||
swarmA.connection.reuse() | ||
swarmC.connection.reuse() | ||
|
||
swarmC.dial(peerA, (err) => { | ||
expect(err).to.not.exist | ||
setTimeout(() => { | ||
expect(Object.keys(swarmC.muxedConns).length).to.equal(1) | ||
expect(Object.keys(swarmA.muxedConns).length).to.equal(2) | ||
done() | ||
}, 500) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.