simplify server websocket configuration

pull/1/head
ansuz 5 years ago
parent 31ec784de6
commit 2dfbb522b0

@ -17,9 +17,6 @@ sedeasy() {
} }
# Configure # Configure
[ -n "$USE_SSL" ] && echo "Using secure websockets: $USE_SSL" \
&& sedeasy "useSecureWebsockets: [^,]*," "useSecureWebsockets: ${USE_SSL}," cfg/config.js
[ -n "$STORAGE" ] && echo "Using storage adapter: $STORAGE" \ [ -n "$STORAGE" ] && echo "Using storage adapter: $STORAGE" \
&& sedeasy "storage: [^,]*," "storage: ${STORAGE}," cfg/config.js && sedeasy "storage: [^,]*," "storage: ${STORAGE}," cfg/config.js

@ -13,9 +13,6 @@ var nThen = require("nthen");
var config = require("./lib/load-config"); var config = require("./lib/load-config");
var websocketPort = config.websocketPort || config.httpPort;
var useSecureWebsockets = config.useSecureWebsockets || false;
// This is stuff which will become available to replify // This is stuff which will become available to replify
const debuggableStore = new WeakMap(); const debuggableStore = new WeakMap();
const debuggable = function (name, x) { const debuggable = function (name, x) {
@ -211,9 +208,6 @@ app.get('/api/config', function(req, res){
removeDonateButton: (config.removeDonateButton === true), removeDonateButton: (config.removeDonateButton === true),
allowSubscriptions: (config.allowSubscriptions === true), allowSubscriptions: (config.allowSubscriptions === true),
websocketPath: config.useExternalWebsocket ? undefined : config.websocketPath, websocketPath: config.useExternalWebsocket ? undefined : config.websocketPath,
// FIXME don't send websocketURL if websocketPath is provided. deprecated.
websocketURL:'ws' + ((useSecureWebsockets) ? 's' : '') + '://' + host + ':' +
websocketPort + '/cryptpad_websocket',
httpUnsafeOrigin: config.httpUnsafeOrigin.replace(/^\s*/, ''), httpUnsafeOrigin: config.httpUnsafeOrigin.replace(/^\s*/, ''),
adminEmail: config.adminEmail, adminEmail: config.adminEmail,
adminKeys: admins, adminKeys: admins,
@ -327,10 +321,6 @@ var nt = nThen(function (w) {
historyKeeper = HK.create(hkConfig); historyKeeper = HK.create(hkConfig);
}).nThen(function () { }).nThen(function () {
if (config.useExternalWebsocket) { return; } if (config.useExternalWebsocket) { return; }
if (websocketPort !== config.httpPort) {
log.debug("setting up a new websocket server");
wsConfig = { port: websocketPort};
}
var wsSrv = new WebSocketServer(wsConfig); var wsSrv = new WebSocketServer(wsConfig);
NetfluxSrv.run(wsSrv, config, historyKeeper); NetfluxSrv.run(wsSrv, config, historyKeeper);
}); });

@ -4,7 +4,6 @@ define([
var Config = {}; var Config = {};
Config.getWebsocketURL = function (origin) { Config.getWebsocketURL = function (origin) {
if (!ApiConfig.websocketPath) { return ApiConfig.websocketURL; }
var path = ApiConfig.websocketPath; var path = ApiConfig.websocketPath;
if (/^ws{1,2}:\/\//.test(path)) { return path; } if (/^ws{1,2}:\/\//.test(path)) { return path; }

Loading…
Cancel
Save