Mercurial > hg > rlgwebd
comparison rlgwebd @ 204:a200b313870d
Use either HTTP or HTTPS.
If HTTPS is enabled, RLGWebD will not use insecure HTTP.
author | John "Elwin" Edwards |
---|---|
date | Sun, 08 Jan 2017 16:17:11 -0500 |
parents | 5491ca3a335b |
children | 04c2a895b679 |
comparison
equal
deleted
inserted
replaced
203:5491ca3a335b | 204:a200b313870d |
---|---|
14 var WebSocketServer = require("websocket").server; | 14 var WebSocketServer = require("websocket").server; |
15 | 15 |
16 /* Default options */ | 16 /* Default options */ |
17 var rlgwebd_options = { | 17 var rlgwebd_options = { |
18 control_socket: "/var/run/rlgwebd.sock", | 18 control_socket: "/var/run/rlgwebd.sock", |
19 http_port: 8080, | 19 port: 8080, |
20 https_port: 8081, | |
21 chrootDir: "/var/dgl/", | 20 chrootDir: "/var/dgl/", |
22 username: "rodney", | 21 username: "rodney", |
23 static_root: "/var/www/" | 22 static_root: "/var/www/" |
24 }; | 23 }; |
25 | 24 |
1286 } | 1285 } |
1287 catch (err) { | 1286 catch (err) { |
1288 tslog("Could not drop permissions: %s", err); | 1287 tslog("Could not drop permissions: %s", err); |
1289 process.exit(1); | 1288 process.exit(1); |
1290 } | 1289 } |
1291 httpServer = http.createServer(webHandler); | |
1292 httpServer.listen(rlgwebd_options.http_port); | |
1293 tslog('rlgwebd running on port %d', rlgwebd_options.http_port); | |
1294 wsServer = new WebSocketServer({"httpServer": httpServer}); | |
1295 wsServer.on("request", wsHandler); | |
1296 tslog('WebSockets are online'); | |
1297 if (rlgwebd_options.use_https) { | 1290 if (rlgwebd_options.use_https) { |
1298 var httpsServer = https.createServer(tls_options, webHandler); | 1291 httpServer = https.createServer(tls_options, webHandler); |
1299 httpsServer.listen(rlgwebd_options.https_port); | 1292 httpServer.listen(rlgwebd_options.port); |
1300 tslog('TLS running on port %d', rlgwebd_options.https_port); | 1293 tslog('rlgwebd running on port %d (TLS)', rlgwebd_options.port); |
1301 var wssServer = new WebSocketServer({"httpServer": httpsServer}); | 1294 wsServer = new WebSocketServer({"httpServer": httpServer}); |
1302 wssServer.on("request", wsHandler); | 1295 wsServer.on("request", wsHandler); |
1303 tslog('Secure WebSockets are online'); | 1296 tslog('Secure WebSockets are online'); |
1297 } | |
1298 else { | |
1299 httpServer = http.createServer(webHandler); | |
1300 httpServer.listen(rlgwebd_options.port); | |
1301 tslog('rlgwebd running on port %d', rlgwebd_options.port); | |
1302 wsServer = new WebSocketServer({"httpServer": httpServer}); | |
1303 wsServer.on("request", wsHandler); | |
1304 tslog('WebSockets are online'); | |
1304 } | 1305 } |
1305 progressWatcher = startProgressWatcher(); | 1306 progressWatcher = startProgressWatcher(); |
1306 setInterval(pushStatus, 40000); | 1307 setInterval(pushStatus, 40000); |
1307 }); | 1308 }); |
1308 | 1309 |