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

Commit 4efaa3c

Browse files
committed
feat: rework circuit relay for protobufs
1 parent 4326ea6 commit 4efaa3c

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/connection.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ module.exports = function connection (swarm) {
9595
},
9696

9797
enableRelayDialing (config) {
98+
config = config ||
99+
{
100+
circuit: {
101+
enabled: false
102+
}
103+
}
104+
98105
swarm.relay = true
99106
swarm.transport.add(Circuit.tag, new Circuit.Dialer(swarm, config))
100107
},

src/handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ module.exports = function process (swarm) {
1010
return (pi, protocol, proxyConn) => {
1111
const b58Id = pi.id.toB58String()
1212

13+
const ms = new multistream.Dialer()
1314
function cryptoDial (conn, cb) {
14-
const ms = new multistream.Dialer()
1515
ms.handle(conn, (err) => {
1616
if (err) {
1717
return cb(err)

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function Swarm (peerInfo, peerBook) {
7070
return myTransports.filter((ts) => this.transports[ts].filter(myAddrs).length > 0)
7171
// push Circuit to be the last proto to be dialed
7272
.sort((a) => {
73-
return a.tag && a.tag === 'Circuit' ? -1 : 0
73+
return a.tag && a.tag === 'Circuit' ? -1 : 1
7474
})
7575
}
7676

0 commit comments

Comments
 (0)