mirror of https://codeberg.org/pzp/pzp-hub.git
update join command inspired by multiformats
This commit is contained in:
parent
11c0756157
commit
4febda05ef
|
@ -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 })
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 }
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in New Issue