diff --git a/lib/plugin-hub.cjs b/lib/plugin-hub.cjs index 6c8a75b..47b757f 100644 --- a/lib/plugin-hub.cjs +++ b/lib/plugin-hub.cjs @@ -1,3 +1,4 @@ +const bs58 = require('bs58') const cat = require('pull-cat') const Notify = require('pull-notify') const pull = require('pull-stream') @@ -81,11 +82,12 @@ module.exports = { return { attendants() { - const clientId = this.id - if (clientId && clientId !== sstack.id) { - debug('welcome %s', clientId) - if (!attendants.has(clientId)) { - attendants.set(clientId, sstack.peers[clientId][0]) + const clientPubkey = bs58.encode(Buffer.from(this.id, 'base64')) + const clientRPC = sstack.peers[this.id][0] + if (clientPubkey && clientPubkey !== sstack.pubkey) { + debug('welcome %s', clientPubkey) + if (!attendants.has(clientPubkey)) { + attendants.set(clientPubkey, clientRPC) notifyAttendants([...attendants.keys()]) } } @@ -102,7 +104,7 @@ module.exports = { if (attendants.has(target)) { // prettier-ignore debug('received tunnel request for target %s from %s', target, this.id) - const origin = this.id + const origin = bs58.encode(Buffer.from(this.id, 'base64')) return attendants.get(target).hubClient.connect(origin, () => {}) } else { // prettier-ignore