diff --git a/README.md b/README.md index 2a46533..ea16e6b 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ const s = l.connect(hash(Buffer.from('a topic to connect on'))) If you just want to spin up a tunneling server you can run the following cli ``` sh -npm install -g @hyperswarm/tunnel +npm install -g @hyperswarm/cli hyperswarm-tunnel-server --port 10000 ``` diff --git a/package.json b/package.json index 386558e..f9b0335 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,6 @@ "devDependencies": { "standard": "^14.3.1" }, - "bin": { - "hyperswarm-tunnel-server": "./server-bin.js" - }, "scripts": { "test": "standard" }, diff --git a/server-bin.js b/server-bin.js deleted file mode 100755 index 1181c50..0000000 --- a/server-bin.js +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env node - -const { Remote } = require('./') - -const r = new Remote() - -r.listen(port()) - -r.on('forward-listening', function (port, topic) { - console.log('Announcing ' + topic.toString('hex') + ' ' + port) -}) - -r.on('forward-close', function (port, topic) { - console.log('Unannouncing ' + topic.toString('hex') + ' ' + port) -}) - -r.on('forward-connect', function (socket, topic) { - console.log('Doing a lookup for ' + topic.toString('hex')) -}) - -r.on('listening', function () { - console.log('Listening on port ' + r.address().port) -}) - -const a = announce() -if (a) r.announce(a) - -r.on('network-close', () => process.exit()) - -process.once('SIGINT', function () { - r.destroy() -}) - -process.once('SIGTERM', function () { - r.destroy() -}) - -function port () { - let i = process.argv.indexOf('-p') - if (i === -1) i = process.argv.indexOf('--port') - if (i === -1) return 0 - return Number(process.argv[i + 1]) || 0 -} - -function announce () { - let i = process.argv.indexOf('-a') - if (i === -1) i = process.argv.indexOf('--announce') - if (i === -1) return null - return Buffer.from(process.argv[i + 1], 'hex') -}