-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates README. Adds localStorage.clear() (patch)
- Loading branch information
Showing
6 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const port = 8000 | ||
const Gun = require('gun') | ||
|
||
function hasValidToken (msg) { | ||
return msg && msg.headers && msg.headers.token && msg.headers.token === 'thisIsTheTokenForReals' | ||
} | ||
|
||
// Add listener | ||
Gun.on('opt', function (ctx) { | ||
if (ctx.once) { | ||
return | ||
} | ||
// Check all incoming traffic | ||
ctx.on('in', function (msg) { | ||
var to = this.to | ||
// restrict everything with invalid tokens | ||
if (msg.put || msg.get) { | ||
if (hasValidToken(msg)) { | ||
console.log('okay') | ||
to.next(msg) | ||
} else { | ||
console.log('not okay') | ||
console.log(msg) | ||
} | ||
} else { | ||
console.log(msg) | ||
to.next(msg) | ||
} | ||
}) | ||
}) | ||
|
||
const server = require('http').createServer((req, res) => { | ||
// filters gun requests! | ||
if (Gun.serve(req, res)) { | ||
return | ||
} | ||
}) | ||
|
||
Gun({ | ||
file: 'data.json', | ||
web: server | ||
}) | ||
|
||
server.listen(port) | ||
|
||
console.log('Server started on port ' + port + ' with /gun') | ||
console.log('Use CTRL + C to stop it') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
localStorage.clear() | ||
|
||
function init () { | ||
addListener(document.getElementById('gunForm'), 'submit', addLine) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
localStorage.clear() | ||
|
||
function init () { | ||
addListener(document.getElementById('gunForm'), 'submit', addLine) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
const tunnelUrl = 'https://3fa07bc7.ngrok.io' | ||
const tunnelUrl = 'https://4f9d3630.ngrok.io' |