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

Commit

Permalink
feat: adding relay (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
dryajov committed Apr 7, 2017
1 parent 6403f28 commit efa43b2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/dial.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ module.exports = function dial (swarm) {
return proxyConn

function attemptDial (pi, cb) {
const tKeys = swarm.availableTransports(pi)
let tKeys = swarm.availableTransports(pi)

if (tKeys.length === 0) {
return cb(new Error('No available transport to dial to'))
if (this.relay) {
// force relay if it's enabled
tKeys = ['Circuit']
// create a generic relay addres
pi.multiaddrs.addSafe(`/p2p-circuit/ipfs/${pi.peerInfo.id}`)
} else {
return cb(new Error('No available transport to dial to'))
}
}

nextTransport(tKeys.shift())
Expand Down

0 comments on commit efa43b2

Please sign in to comment.