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) => { app.get('/', (req, reply) => {
if (peer.hub.numMembers() === 0) { if (peer.hub.numMembers() === 0) {
const { port, pubkey, token } = peer.hub.getBootstrap() const { tcpPort, shseCredentials } = peer.hub.getBootstrap()
reply.view('bootstrap.ejs', { port, pubkey, token }) reply.view('bootstrap.ejs', { tcpPort, shseCredentials })
} else { } else {
reply.view('homepage.ejs', { markdown: homepageHTML }) reply.view('homepage.ejs', { markdown: homepageHTML })
} }

View File

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

View File

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

View File

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