fix conn key conversion to shse.pubkey

This commit is contained in:
Andre Staltz 2023-07-20 19:49:01 +03:00
parent fe72a1a86e
commit 62ad921abb
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
1 changed files with 8 additions and 2 deletions

View File

@ -33,7 +33,7 @@ const makeTunnelPlugin = (hubs, local) => (/** @type {any}} */ msConfig) => {
pull.drain(async ({ address, key, details }) => {
if (!key) return
// TODO: once ssb-conn is replaced, we won't need this anymore:
const pubkey = bs58.encode(Buffer.from(key, 'base64'))
const pubkey = key.slice(1, -8) // not base64, it's @BASE58.ed25519
if (hubs.has(pubkey)) return
if (!details?.rpc) return
if (address.startsWith('tunnel:')) return
@ -61,7 +61,7 @@ const makeTunnelPlugin = (hubs, local) => (/** @type {any}} */ msConfig) => {
pull.drain(({ key }) => {
if (!key) return
// TODO: once ssb-conn is replaced, we won't need this anymore:
const pubkey = bs58.encode(Buffer.from(key, 'base64'))
const pubkey = key.slice(1, -8) // not base64, it's @BASE58.ed25519
if (!hubs.has(pubkey)) return
hubs.get(pubkey)?.close()
hubs.delete(pubkey)
@ -95,6 +95,12 @@ const makeTunnelPlugin = (hubs, local) => (/** @type {any}} */ msConfig) => {
let hubRPC = hubs.get(hub)?.rpc
// If no hub found, wait a second and try again
if (!hubRPC) {
await new Promise(resolve => setTimeout(resolve, 1000))
hubRPC = hubs.get(hub)?.rpc
}
// If no hub found, look up hub in connDB and connect to it
if (!hubRPC) {
for (const [msaddr] of local.conn.db().entries()) {