update join command inspired by multiformats

This commit is contained in:
Andre Staltz 2024-01-10 18:56:48 +02:00
parent 11c0756157
commit 4febda05ef
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
4 changed files with 10 additions and 11 deletions

View File

@ -22,8 +22,8 @@ app.register(fastifyStatic, { root: staticsPath })
app.get('/', (req, reply) => {
if (peer.hub.numMembers() === 0) {
const { port, pubkey, token } = peer.hub.getBootstrap()
reply.view('bootstrap.ejs', { port, pubkey, token })
const { tcpPort, shseCredentials } = peer.hub.getBootstrap()
reply.view('bootstrap.ejs', { tcpPort, shseCredentials })
} else {
reply.view('homepage.ejs', { markdown: homepageHTML })
}

View File

@ -125,10 +125,9 @@ module.exports = {
},
getBootstrap() {
const port = config.global.connections.incoming.net[0].port
const pubkey = peer.shse.pubkey
const token = 'none'
return { port, pubkey, token }
const tcpPort = config.global.connections.incoming.net[0].port
const shseCredentials = peer.shse.pubkey
return { tcpPort, shseCredentials }
},
}
},

View File

@ -7,8 +7,9 @@ window.addEventListener('focus', () => {
})
const host = window.location.hostname
const { port, pubkey, token } = window.hubInvite
const uri = `ppppp://invite/join/${host}/${port}/${pubkey}/${token}`
const hostFormat = /[a-zA-Z]/.test(window.location.hostname) ? 'dns' : 'ip4';
const { tcpPort, shseCredentials } = window.hubInvite
const uri = `ppppp://invite/join/${hostFormat}/${host}/tcp/${tcpPort}/shse/${shseCredentials}`
const inviteLinkElem = document.getElementById('invite')
inviteLinkElem.href = uri

View File

@ -16,9 +16,8 @@
</article>
<script>
window.hubInvite = {
port: '<%= port %>',
pubkey: '<%= pubkey %>',
token: '<%= token %>',
tcpPort: '<%= tcpPort %>',
shseCredentials: '<%= shseCredentials %>',
};
</script>
<script src="/bootstrap.js"></script>