Commit 423dc940 authored by Neil Gershenfeld's avatar Neil Gershenfeld

add auth

parent 1d1cc1b5
#!/bin/bash
cd ~/git/screen
sudo node screen.js 80 10 10 1234
......@@ -18,13 +18,17 @@
//
// command line
//
if (process.argv.length != 5) {
console.log("node screen.js server_port server_update_rate_ms client_update_rate_ms")
if ((process.argv.length < 5) || (process.argv.length > 6)) {
console.log("node screen.js server_port server_update_rate_ms client_update_rate_ms [code]")
process.exit()
}
var port = parseInt(process.argv[2])
var server_delay = parseFloat(process.argv[3])
var client_delay = parseFloat(process.argv[4])
if (process.argv.length == 6)
var code = process.argv[5]
else
var code = "''"
//
// requires
//
......@@ -56,7 +60,9 @@ http.createServer(function(request,response) {
if (url == '/') {
fs.readFile('viewer.html',function(err,data){
response.writeHead(200,{'Content-Type':'text/html'});
response.end(data)
var str = data.toString()
str = str.replace('CODE',code)
response.end(str)
})
}
else if (url == '/img') {
......
<html>
<body>
<div id="page">
<img id="img" alt="waiting for screen transmission to start"><br>
<a href="screen.js">screen.js</a>
<a href="viewer.html">viewer.html</a>
</div>
<script type="text/javascript">
//
// viewer.html
// screen.js content viewer
// Neil Gershenfeld
// 2/9/17
// 2/26/19
//
var client_delay
initialize()
update()
var code = CODE
insecure_auth()
function insecure_auth() {
if (code == '') {
initialize()
update()
}
else {
var resp = prompt('screencast code?')
if (resp == code) {
initialize()
update()
}
else {
document.body.removeChild(document.getElementById('page'))
document.write('incorrect code')
}
}
}
function initialize() {
var req = new XMLHttpRequest()
req.open('GET','/initvars',true);
......@@ -48,8 +67,8 @@ function update() {
req.addEventListener('loadend',function(evt) {
if (evt.loaded == 0) {
req.abort()
document.getElementById("img").alt = 'screen transmission ended'
document.getElementById("img").src = ''
document.body.removeChild(document.getElementById('page'))
document.write('screen transmission ended')
}
else {
var url = window.URL.createObjectURL(req.response)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment