Revert "Remove legacy /sioconfig and user agreement link"
ACP has a dependency on `/sioconfig`. Reverting until that can be
fixed.
This reverts commit a48cab81b9.
This commit is contained in:
parent
cacde7f72d
commit
cc69b3c225
5 changed files with 148 additions and 1 deletions
|
|
@ -375,6 +375,20 @@ function preprocessConfig(cfg) {
|
|||
cfg.io["ipv4-default"] = cfg.io["ipv4-ssl"] || cfg.io["ipv4-nossl"];
|
||||
cfg.io["ipv6-default"] = cfg.io["ipv6-ssl"] || cfg.io["ipv6-nossl"];
|
||||
|
||||
// sioconfig
|
||||
// TODO this whole thing is messy, need to redo how the socket address is sent
|
||||
var sioconfigjson = {
|
||||
"ipv4-nossl": cfg.io["ipv4-nossl"],
|
||||
"ipv4-ssl": cfg.io["ipv4-ssl"],
|
||||
"ipv6-nossl": cfg.io["ipv6-nossl"],
|
||||
"ipv6-ssl": cfg.io["ipv6-ssl"]
|
||||
};
|
||||
|
||||
var sioconfig = JSON.stringify(sioconfigjson);
|
||||
sioconfig = "var IO_URLS=" + sioconfig + ";";
|
||||
cfg.sioconfigjson = sioconfigjson;
|
||||
cfg.sioconfig = sioconfig;
|
||||
|
||||
// Generate RegExps for reserved names
|
||||
var reserved = cfg["reserved-names"];
|
||||
for (var key in reserved) {
|
||||
|
|
|
|||
|
|
@ -76,6 +76,43 @@ function redirectHttps(req, res) {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy socket.io configuration endpoint. This is being migrated to
|
||||
* /socketconfig/<channel name>.json (see ./routes/socketconfig.js)
|
||||
*/
|
||||
function handleLegacySocketConfig(req, res) {
|
||||
if (/\.json$/.test(req.path)) {
|
||||
res.json(Config.get('sioconfigjson'));
|
||||
return;
|
||||
}
|
||||
|
||||
res.type('application/javascript');
|
||||
|
||||
var sioconfig = Config.get('sioconfig');
|
||||
var iourl;
|
||||
var ip = req.realIP;
|
||||
var ipv6 = false;
|
||||
|
||||
if (net.isIPv6(ip)) {
|
||||
iourl = Config.get('io.ipv6-default');
|
||||
ipv6 = true;
|
||||
}
|
||||
|
||||
if (!iourl) {
|
||||
iourl = Config.get('io.ipv4-default');
|
||||
}
|
||||
|
||||
sioconfig += 'var IO_URL=\'' + iourl + '\';';
|
||||
sioconfig += 'var IO_V6=' + ipv6 + ';';
|
||||
res.send(sioconfig);
|
||||
}
|
||||
|
||||
function handleUserAgreement(req, res) {
|
||||
sendPug(res, 'tos', {
|
||||
domain: Config.get('http.domain')
|
||||
});
|
||||
}
|
||||
|
||||
function initializeErrorHandlers(app) {
|
||||
app.use((req, res, next) => {
|
||||
return next(new HTTPError(`No route for ${req.path}`, {
|
||||
|
|
@ -206,7 +243,9 @@ module.exports = {
|
|||
|
||||
require('./routes/channel')(app, ioConfig, chanPath);
|
||||
require('./routes/index')(app, channelIndex, webConfig.getMaxIndexEntries());
|
||||
app.get('/sioconfig(.json)?', handleLegacySocketConfig);
|
||||
require('./routes/socketconfig')(app, clusterClient);
|
||||
app.get('/useragreement', handleUserAgreement);
|
||||
require('./routes/contact')(app, webConfig);
|
||||
require('./auth').init(app);
|
||||
require('./account').init(app, globalMessageBus);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue