diff --git a/NetfluxWebsocketSrv.js b/NetfluxWebsocketSrv.js index 98d79f72f..02a8f8b19 100644 --- a/NetfluxWebsocketSrv.js +++ b/NetfluxWebsocketSrv.js @@ -14,7 +14,12 @@ let historyKeeperKeys = {}; const now = function () { return (new Date()).getTime(); }; +const socketSendable = function (socket) { + return socket && socket.readyState === 1; +}; + const sendMsg = function (ctx, user, msg) { + if (!socketSendable(user.socket)) { return; } try { if (ctx.config.logToStdout) { console.log('<' + JSON.stringify(msg)); } user.socket.send(JSON.stringify(msg)); @@ -272,7 +277,7 @@ let run = module.exports.run = function (storage, socketServer, config) { }); }, 5000); socketServer.on('connection', function(socket) { - if(socket.upgradeReq.url !== '/cryptpad_websocket') { return; } + if(socket.upgradeReq.url !== (config.websocketPath || '/cryptpad_websocket')) { return; } let conn = socket.upgradeReq.connection; let user = { addr: conn.remoteAddress + '|' + conn.remotePort, diff --git a/config.js.dist b/config.js.dist index e88b06b0a..c75748508 100644 --- a/config.js.dist +++ b/config.js.dist @@ -9,8 +9,22 @@ module.exports = { // the port on which your httpd will listen httpPort: 3000, - // the port used for websockets - websocketPort: 3000, + + /* your server's websocket url is configurable + (default: '/cryptpad_websocket') + + websocketPath can be relative, of the form '/path/to/websocket' + or absolute, specifying a particular URL + + 'wss://cryptpad.fr:3000/cryptpad_websocket' + */ + websocketPath: '/cryptpad_websocket', + + /* it is assumed that your websocket will bind to the same port as http + you can override this behaviour by supplying a number via websocketPort + */ + //websocketPort: 3000, + /* Cryptpad can log activity to stdout * This may be useful for debugging diff --git a/customize.dist/application_config.js b/customize.dist/application_config.js index 058d2c1d9..d7e9141c1 100644 --- a/customize.dist/application_config.js +++ b/customize.dist/application_config.js @@ -4,7 +4,7 @@ define(function() { /* Select the buttons displayed on the main page to create new collaborative sessions * Existing types : pad, code, poll, slide */ - config.availablePadTypes = ['pad', 'code', 'poll']; + config.availablePadTypes = ['pad', 'code', 'poll', 'slide']; return config; }); diff --git a/customize.dist/index.html b/customize.dist/index.html index acaed958b..32e09f4f2 100644 --- a/customize.dist/index.html +++ b/customize.dist/index.html @@ -57,8 +57,12 @@