Remove /sioconfig for real
This commit is contained in:
parent
a2be65aead
commit
3cd8bfa8c7
6 changed files with 25 additions and 69 deletions
|
|
@ -6,6 +6,8 @@ var Logger = require("../logger");
|
|||
var db = require("../database");
|
||||
var Config = require("../config");
|
||||
|
||||
let ioConfig;
|
||||
|
||||
function checkAdmin(cb) {
|
||||
return async function (req, res) {
|
||||
const user = await webserver.authorize(req);
|
||||
|
|
@ -28,16 +30,17 @@ function checkAdmin(cb) {
|
|||
* Handles a request for the ACP
|
||||
*/
|
||||
function handleAcp(req, res, user) {
|
||||
var sio;
|
||||
if (req.secure || req.header("x-forwarded-proto") === "https") {
|
||||
sio = Config.get("https.domain") + ":" + Config.get("https.default-port");
|
||||
} else {
|
||||
sio = Config.get("io.domain") + ":" + Config.get("io.default-port");
|
||||
const ioServers = ioConfig.getSocketEndpoints();
|
||||
const chosenServer = ioServers[0];
|
||||
|
||||
if (!chosenServer) {
|
||||
res.status(500).text("No suitable socket.io address for ACP");
|
||||
return;
|
||||
}
|
||||
sio += "/socket.io/socket.io.js";
|
||||
|
||||
sendPug(res, "acp", {
|
||||
sioSource: sio
|
||||
ioServers: JSON.stringify(ioServers),
|
||||
sioSource: `${chosenServer.url}/socket.io/socket.io.js`
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +107,9 @@ function handleReadChanlog(req, res) {
|
|||
}
|
||||
|
||||
module.exports = {
|
||||
init: function (app) {
|
||||
init: function (app, _ioConfig) {
|
||||
ioConfig = _ioConfig;
|
||||
|
||||
app.get("/acp", checkAdmin(handleAcp));
|
||||
app.get("/acp/syslog", checkAdmin(handleReadSyslog));
|
||||
app.get("/acp/errlog", checkAdmin(handleReadErrlog));
|
||||
|
|
|
|||
|
|
@ -64,37 +64,6 @@ function initPrometheus(app) {
|
|||
}, 5 * 60 * 1000).unref();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 initializeErrorHandlers(app) {
|
||||
app.use((req, res, next) => {
|
||||
return next(new HTTPError(`No route for ${req.path}`, {
|
||||
|
|
@ -232,12 +201,11 @@ 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);
|
||||
require('./routes/contact')(app, webConfig);
|
||||
require('./auth').init(app);
|
||||
require('./account').init(app, globalMessageBus, emailConfig, emailController);
|
||||
require('./acp').init(app);
|
||||
require('./acp').init(app, ioConfig);
|
||||
require('../google2vtt').attach(app);
|
||||
require('./routes/google_drive_userscript')(app);
|
||||
require('./routes/ustream_bypass')(app);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue