From 97bc793ca892d2c33e0aadc4f32376bf6b8c818e Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 23 Dec 2019 17:39:13 -0500 Subject: [PATCH] simplify websocket configuration even more --- server.js | 12 ++++++++---- www/common/outer/network-config.js | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/server.js b/server.js index 6fe11e06d..e086a0596 100644 --- a/server.js +++ b/server.js @@ -166,7 +166,7 @@ app.get('/api/config', function(req, res){ }, removeDonateButton: (config.removeDonateButton === true), allowSubscriptions: (config.allowSubscriptions === true), - websocketPath: config.useExternalWebsocket ? undefined : config.websocketPath, + websocketPath: config.websocketPath, httpUnsafeOrigin: config.httpUnsafeOrigin.replace(/^\s*/, ''), adminEmail: config.adminEmail, adminKeys: admins, @@ -234,7 +234,13 @@ var nt = nThen(function (w) { log = config.log = _log; })); }).nThen(function (w) { - if (config.useExternalWebsocket) { return; } + if (config.useExternalWebsocket) { + // if you plan to use an external websocket server + // then you don't need to load any API services other than the logger. + // Just abort. + w.abort(); + return; + } Storage.create(config, w(function (_store) { config.store = _store; })); @@ -264,7 +270,6 @@ var nt = nThen(function (w) { rpc = _rpc; })); }).nThen(function () { - if (config.useExternalWebsocket) { return; } var HK = require('./historyKeeper.js'); var hkConfig = { tasks: config.tasks, @@ -275,7 +280,6 @@ var nt = nThen(function (w) { }; historyKeeper = HK.create(hkConfig); }).nThen(function () { - if (config.useExternalWebsocket) { return; } var wsSrv = new WebSocketServer(wsConfig); NetfluxSrv.run(wsSrv, config, historyKeeper); }); diff --git a/www/common/outer/network-config.js b/www/common/outer/network-config.js index ff4c22870..3d3465ffe 100644 --- a/www/common/outer/network-config.js +++ b/www/common/outer/network-config.js @@ -4,7 +4,7 @@ define([ var Config = {}; Config.getWebsocketURL = function (origin) { - var path = ApiConfig.websocketPath; + var path = ApiConfig.websocketPath || '/cryptpad_websocket'; if (/^ws{1,2}:\/\//.test(path)) { return path; } var l = window.location;