0.0.002
ddat interop with dat js cable interop with cabal js ddat's frontend = dat-thang cable fe = cable-thang dillo support based on cel's dillo-dat bootstrap node xplatform support Signed-off-by: divo <418@cryspace.space>
This commit is contained in:
1 parent
f0f91540be
commit
b735900f2e
323 files changed
+134347
-343
No files matched your search
@@ -0,0 +1,33 @@
|
||||
'use strict'
|
||||
|
||||
// Run a public Cabal-compatible HyperDHT bootstrap node in the foreground.
|
||||
// Put this under a service manager and advertise the reachable IPv4 host/UDP port.
|
||||
const { loadCabalCore } = require('./cable_hyperswarm')
|
||||
|
||||
async function main () {
|
||||
const host = process.argv[2]
|
||||
const port = Number(process.argv[3])
|
||||
if (!host || !Number.isInteger(port) || port < 1 || port > 65535) {
|
||||
throw new Error('usage: cable bootstrap serve <public-ipv4-host> <udp-port>')
|
||||
}
|
||||
const { requireCabal } = loadCabalCore()
|
||||
const DHT = requireCabal('hyperdht')
|
||||
const node = DHT.bootstrapper(port, host)
|
||||
await node.ready()
|
||||
const address = node.address()
|
||||
process.stdout.write('Cabal Hyperswarm bootstrap serving ' + host + ':' + address.port +
|
||||
' (bound ' + address.host + ':' + address.port + ')\n')
|
||||
const close = async () => {
|
||||
try { await node.destroy() } finally { process.exit(0) }
|
||||
}
|
||||
process.once('SIGINT', close)
|
||||
process.once('SIGTERM', close)
|
||||
}
|
||||
|
||||
if (require.main === module) main().catch(err => {
|
||||
process.stderr.write((err && err.stack) || String(err))
|
||||
process.stderr.write('\n')
|
||||
process.exitCode = 1
|
||||
})
|
||||
|
||||
module.exports = { main }
|
||||
Reference in new issue
Block a user