Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function reconnect () {
if(timer) return
console.error('waiting to reconnect')
timer = setTimeout(function () {
timer = null
connect()
}, 500 + Math.random() * 1000)
}
PortalClient(
keys,
{
remote: portal,
caps: config.caps,
manifest: {
tunnel: {connect: 'duplex'}
}
}, function (err, rpc) {
if(err) {
console.error(err)
return reconnect()
}
console.error('connecting to tunnel:', target)
var stream = rpc.tunnel.connect({
target: '@'+target.split(':').pop()+'.ed25519',
port: 0
})
pull(
stream.source,
Client(toBuffer(target.split(':').pop()), function (err, stream) {
}
//var portal = process.argv[2]
//var target = process.argv[3]
function toSodiumKeys(keys) {
if(!keys || !keys.public) return null
console.log(keys)
return {
publicKey: toBuffer(keys.public),
secretKey: toBuffer(keys.private)
}
}
console.log('target:', target)
console.log('keys:', keys)
var Client = TunnelClient(toSodiumKeys(keys), toBuffer(config.caps.shs), timeout)
var timer
;(function connect () {
console.error('connecting to portal:', portal)
function reconnect () {
if(timer) return
console.error('waiting to reconnect')
timer = setTimeout(function () {
timer = null
connect()
}, 500 + Math.random() * 1000)
}
PortalClient(
return new Promise((resolve, reject) => {
client(data.keys, {
remote: data.remote,
caps: config.caps,
manifest: data.manifest
}, (err, s) => {
if (err) {
reject("Connecting to sbot, <a href="\"#/setup\"">go back to setup</a> and check your settings. Also, make sure <i>sbot</i> is running (is scuttle-shell icon appearing on your machine?).");
} else {
resolve({sbot: s, remote: data.remote, keys: data.keys, manifest: data.manifest});
}
});
});
};