Skip to content
This repository was archived by the owner on Apr 24, 2023. It is now read-only.

feat: skip p2p-circuit addresses #15

Merged
merged 3 commits into from
Oct 16, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,12 @@ class WebRTCDirect {
if (!Array.isArray(multiaddrs)) {
multiaddrs = [multiaddrs]
}

return multiaddrs.filter((ma) => {
if (ma.protoNames().indexOf('p2p-circuit') > -1) {
return false
}

return mafmt.WebRTCDirect.matches(ma)
})
}
Expand Down
4 changes: 3 additions & 1 deletion test/filter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ describe('filter', () => {
multiaddr('/ip4/1.2.3.4/tcp/3456/http/p2p-webrtc-direct'),
multiaddr('/ip4/127.0.0.1/tcp/9090/ws'),
multiaddr('/ip4/127.0.0.1/tcp/9090/ws/p2p-webrtc-direct/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo2'),
multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4')
multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4'),
multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4' +
'/p2p-circuit/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo5')
]

const filtered = wd.filter(maArr)
Expand Down