Skip to content

Instantly share code, notes, and snippets.

@AcidLeroy
Created June 21, 2018 14:26
Show Gist options
  • Save AcidLeroy/bd90a05e481e35e1378359de6770a905 to your computer and use it in GitHub Desktop.
Save AcidLeroy/bd90a05e481e35e1378359de6770a905 to your computer and use it in GitHub Desktop.
http with discovery channel
const express = require('express')
const app = express()
const DC = require('discovery-channel')
const crypto = require('crypto')
app.get('/', (req, res) => {
console.log('Received a request')
res.send('Hello World')
})
const port = 30000
app.listen(port, () => {
console.log('Example app listening on port %s!', port)
let channel = DC({dht: true}) // set true to work over internet
let id = crypto.createHash('sha256').update(Date()).digest().toString('hex')
console.log('The id is =', id)
channel.join(id, port)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment