Skip to content

Commit

Permalink
Merge pull request libp2p#26 from diasdavid/feature/filter-addrs
Browse files Browse the repository at this point in the history
filter the multiaddrs that are passed to avoid collision
  • Loading branch information
daviddias committed Mar 15, 2016
2 parents 4036ea4 + b83e5dd commit 8615a50
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
"chai": "^3.5.0",
"istanbul": "^0.4.2",
"libp2p-spdy": "^0.2.3",
"libp2p-tcp": "^0.3.0",
"libp2p-tcp": "^0.4.0",
"mocha": "^2.4.5",
"multiaddr": "^1.1.1",
"multiaddr": "^1.3.0",
"peer-id": "^0.6.0",
"peer-info": "^0.6.0",
"pre-commit": "^1.1.2",
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ function Swarm (peerInfo) {
multiaddrs = [multiaddrs]
}

// TODO a) filter the multiaddrs that are actually valid for this transport (use a func from the transport itself) (maybe even make the transport do that)
// a) filter the multiaddrs that are actually valid for this transport (use a func from the transport itself) (maybe even make the transport do that)
multiaddrs = t.filter(multiaddrs)

// b) if multiaddrs.length = 1, return the conn from the
// transport, otherwise, create a passthrough
Expand Down
1 change: 1 addition & 0 deletions tests/swarm-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ describe('transport - tcp', function () {

it('dial to set of multiaddr, only one is available', (done) => {
const conn = swarmA.transport.dial('tcp', [
multiaddr('/ip4/127.0.0.1/tcp/9910/websockets'), // not valid on purpose
multiaddr('/ip4/127.0.0.1/tcp/9910'),
multiaddr('/ip4/127.0.0.1/tcp/9999'),
multiaddr('/ip4/127.0.0.1/tcp/9309')
Expand Down

0 comments on commit 8615a50

Please sign in to comment.