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

Commit

Permalink
fix: return error if dialing ma without id
Browse files Browse the repository at this point in the history
  • Loading branch information
mkg20001 committed Jun 22, 2018
1 parent 4238cb8 commit 2a5832c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ class WebRTCStar {

callback = callback ? once(callback) : noop

let b58 = ma.split('ipfs/').pop()
let peerId = ma.getPeerId()

log('dialing %s (id=%s)', ma, b58)
log('dialing %s (id=%s)', ma, peerId)

if (!peerId) {
return callback(new Error('Cannot dial peer: No Id provided!'))
}

const spOptions = { initiator: true, trickle: false }

Expand All @@ -61,7 +65,7 @@ class WebRTCStar {

channel.on('signal', (signal) => {
log('dial#%s got signal', ma)
this.exchange.request(Id.createFromB58String(b58), 'webrtc', Buffer.from(JSON.stringify({signal})), (err, result) => {
this.exchange.request(Id.createFromB58String(peerId), 'webrtc', Buffer.from(JSON.stringify({signal})), (err, result) => {
if (err) {
log('dial#%s exchange failed %s', ma, err)
return callback(err)
Expand Down

0 comments on commit 2a5832c

Please sign in to comment.