Merge branch 'config-sockets' into soon
This commit is contained in:
commit
2ac1b02572
@ -277,7 +277,7 @@ let run = module.exports.run = function (storage, socketServer, config) {
|
|||||||
});
|
});
|
||||||
}, 5000);
|
}, 5000);
|
||||||
socketServer.on('connection', function(socket) {
|
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 conn = socket.upgradeReq.connection;
|
||||||
let user = {
|
let user = {
|
||||||
addr: conn.remoteAddress + '|' + conn.remotePort,
|
addr: conn.remoteAddress + '|' + conn.remotePort,
|
||||||
|
|||||||
@ -9,8 +9,22 @@ module.exports = {
|
|||||||
|
|
||||||
// the port on which your httpd will listen
|
// the port on which your httpd will listen
|
||||||
httpPort: 3000,
|
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
|
/* Cryptpad can log activity to stdout
|
||||||
* This may be useful for debugging
|
* This may be useful for debugging
|
||||||
|
|||||||
@ -56,10 +56,9 @@ app.get('/api/config', function(req, res){
|
|||||||
var host = req.headers.host.replace(/\:[0-9]+/, '');
|
var host = req.headers.host.replace(/\:[0-9]+/, '');
|
||||||
res.setHeader('Content-Type', 'text/javascript');
|
res.setHeader('Content-Type', 'text/javascript');
|
||||||
res.send('define(' + JSON.stringify({
|
res.send('define(' + JSON.stringify({
|
||||||
|
websocketPath: config.websocketPath,
|
||||||
websocketURL:'ws' + ((httpsOpts) ? 's' : '') + '://' + host + ':' +
|
websocketURL:'ws' + ((httpsOpts) ? 's' : '') + '://' + host + ':' +
|
||||||
config.websocketPort + '/cryptpad_websocket',
|
config.websocketPort + '/cryptpad_websocket',
|
||||||
webrtcURL:'ws' + ((httpsOpts) ? 's' : '') + '://' + host + ':' +
|
|
||||||
config.websocketPort + '/cryptpad_webrtc',
|
|
||||||
}) + ');');
|
}) + ');');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
define([
|
define([
|
||||||
|
'/api/config?cb=' + Math.random().toString(16).slice(2),
|
||||||
'/customize/messages.js',
|
'/customize/messages.js',
|
||||||
'/customize/store.js',
|
'/customize/store.js',
|
||||||
'/bower_components/chainpad-crypto/crypto.js',
|
'/bower_components/chainpad-crypto/crypto.js',
|
||||||
@ -8,7 +9,7 @@ define([
|
|||||||
'/customize/user.js',
|
'/customize/user.js',
|
||||||
|
|
||||||
'/bower_components/jquery/dist/jquery.min.js',
|
'/bower_components/jquery/dist/jquery.min.js',
|
||||||
], function (Messages, Store, Crypto, Alertify, Spinner, User) {
|
], function (Config, Messages, Store, Crypto, Alertify, Spinner, User) {
|
||||||
/* This file exposes functionality which is specific to Cryptpad, but not to
|
/* This file exposes functionality which is specific to Cryptpad, but not to
|
||||||
any particular pad type. This includes functions for committing metadata
|
any particular pad type. This includes functions for committing metadata
|
||||||
about pads to your local storage for future use and improved usability.
|
about pads to your local storage for future use and improved usability.
|
||||||
@ -36,6 +37,20 @@ define([
|
|||||||
throw new Error("Store is not ready!");
|
throw new Error("Store is not ready!");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var getWebsocketURL = common.getWebsocketURL = function () {
|
||||||
|
if (!Config.websocketPath) { return Config.websocketURL; }
|
||||||
|
var path = Config.websocketPath;
|
||||||
|
if (/^ws{1,2}:\/\//.test(path)) { return path; }
|
||||||
|
|
||||||
|
var protocol = window.location.protocol.replace(/http/, 'ws');
|
||||||
|
var host = window.location.host;
|
||||||
|
var url = protocol + '//' + host + path;
|
||||||
|
|
||||||
|
console.log(url);
|
||||||
|
|
||||||
|
return url;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* cb(err, proxy);
|
* cb(err, proxy);
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify' } });
|
require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify' } });
|
||||||
define([
|
define([
|
||||||
'/api/config?cb=' + Math.random().toString(16).substring(2),
|
|
||||||
'/customize/messages.js?app=pad',
|
'/customize/messages.js?app=pad',
|
||||||
'/bower_components/chainpad-crypto/crypto.js',
|
'/bower_components/chainpad-crypto/crypto.js',
|
||||||
'/bower_components/chainpad-netflux/chainpad-netflux.js',
|
'/bower_components/chainpad-netflux/chainpad-netflux.js',
|
||||||
@ -18,7 +17,7 @@ define([
|
|||||||
'/bower_components/diff-dom/diffDOM.js',
|
'/bower_components/diff-dom/diffDOM.js',
|
||||||
'/bower_components/jquery/dist/jquery.min.js',
|
'/bower_components/jquery/dist/jquery.min.js',
|
||||||
'/customize/pad.js'
|
'/customize/pad.js'
|
||||||
], function (Config, Messages, Crypto, realtimeInput, Hyperjson,
|
], function (Messages, Crypto, realtimeInput, Hyperjson,
|
||||||
Toolbar, Cursor, JsonOT, TypingTest, JSONSortify, TextPatcher, Cryptpad,
|
Toolbar, Cursor, JsonOT, TypingTest, JSONSortify, TextPatcher, Cryptpad,
|
||||||
Visible, Notify) {
|
Visible, Notify) {
|
||||||
var $ = window.jQuery;
|
var $ = window.jQuery;
|
||||||
@ -340,7 +339,7 @@ define([
|
|||||||
initialState: stringifyDOM(inner) || '{}',
|
initialState: stringifyDOM(inner) || '{}',
|
||||||
|
|
||||||
// the websocket URL
|
// the websocket URL
|
||||||
websocketURL: Config.websocketURL,
|
websocketURL: Cryptpad.getWebsocketURL(),
|
||||||
|
|
||||||
// the channel we will communicate over
|
// the channel we will communicate over
|
||||||
channel: secret.channel,
|
channel: secret.channel,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user