Use either HTTP or HTTPS.

If HTTPS is enabled, RLGWebD will not use insecure HTTP.
This commit is contained in:
John "Elwin" Edwards 2017-01-08 16:17:11 -05:00
parent 2e9d5071d9
commit 5b790718d8
2 changed files with 15 additions and 16 deletions

23
rlgwebd
View file

@ -16,8 +16,7 @@ var WebSocketServer = require("websocket").server;
/* Default options */ /* Default options */
var rlgwebd_options = { var rlgwebd_options = {
control_socket: "/var/run/rlgwebd.sock", control_socket: "/var/run/rlgwebd.sock",
http_port: 8080, port: 8080,
https_port: 8081,
chrootDir: "/var/dgl/", chrootDir: "/var/dgl/",
username: "rodney", username: "rodney",
static_root: "/var/www/" static_root: "/var/www/"
@ -1288,19 +1287,21 @@ ctlServer.listen(rlgwebd_options.control_socket, function () {
tslog("Could not drop permissions: %s", err); tslog("Could not drop permissions: %s", err);
process.exit(1); process.exit(1);
} }
if (rlgwebd_options.use_https) {
httpServer = https.createServer(tls_options, webHandler);
httpServer.listen(rlgwebd_options.port);
tslog('rlgwebd running on port %d (TLS)', rlgwebd_options.port);
wsServer = new WebSocketServer({"httpServer": httpServer});
wsServer.on("request", wsHandler);
tslog('Secure WebSockets are online');
}
else {
httpServer = http.createServer(webHandler); httpServer = http.createServer(webHandler);
httpServer.listen(rlgwebd_options.http_port); httpServer.listen(rlgwebd_options.port);
tslog('rlgwebd running on port %d', rlgwebd_options.http_port); tslog('rlgwebd running on port %d', rlgwebd_options.port);
wsServer = new WebSocketServer({"httpServer": httpServer}); wsServer = new WebSocketServer({"httpServer": httpServer});
wsServer.on("request", wsHandler); wsServer.on("request", wsHandler);
tslog('WebSockets are online'); tslog('WebSockets are online');
if (rlgwebd_options.use_https) {
var httpsServer = https.createServer(tls_options, webHandler);
httpsServer.listen(rlgwebd_options.https_port);
tslog('TLS running on port %d', rlgwebd_options.https_port);
var wssServer = new WebSocketServer({"httpServer": httpsServer});
wssServer.on("request", wsHandler);
tslog('Secure WebSockets are online');
} }
progressWatcher = startProgressWatcher(); progressWatcher = startProgressWatcher();
setInterval(pushStatus, 40000); setInterval(pushStatus, 40000);

View file

@ -5,9 +5,7 @@
# Location of the socket for start/stop commands # Location of the socket for start/stop commands
#control_socket = /var/run/rlgwebd.sock #control_socket = /var/run/rlgwebd.sock
# Port number to bind # Port number to bind
#http_port = 8080 #port = 8080
# Port number for HTTPS
#https_port = 8081
# Path to the dgamelaunch installation to chroot into # Path to the dgamelaunch installation to chroot into
# If you change this, change the Makefile too # If you change this, change the Makefile too
#chrootDir = /var/dgl/ #chrootDir = /var/dgl/