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

[Proposal] Feat/circuit interop #78

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
},
"dependencies": {
"interface-connection": "~0.3.2",
"interface-transport": "^0.3.4",
"ip-address": "^5.8.6",
"lodash.includes": "^4.3.0",
"lodash.isfunction": "^3.0.8",
Expand All @@ -61,4 +62,4 @@
"Richard Littauer <[email protected]>",
"Stephen Whitmore <[email protected]>"
]
}
}
12 changes: 11 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ const log = debug('libp2p:tcp:dial')
const createListener = require('./listener')

module.exports = class TCP {
get priority () {
return 1 // TODO: move to a constants file that all transports can share
}

set priority (val) {
throw new Error('Priority is read only!')
}

dial (ma, options, cb) {
if (isFunction(options)) {
cb = options
Expand Down Expand Up @@ -67,7 +75,9 @@ module.exports = class TCP {
multiaddrs = [multiaddrs]
}
return multiaddrs.filter((ma) => {
if (includes(ma.protoNames(), 'ipfs')) {
if (includes(ma.protoNames(), 'p2p-circuit')) {
return false
} else if (includes(ma.protoNames(), 'ipfs')) {
ma = ma.decapsulate('ipfs')
}
return mafmt.TCP.matches(ma)
Expand Down