mirror of https://github.com/calzoneman/sync.git
Add /sioconfig.json
This commit is contained in:
parent
7875dbdf4a
commit
27b501e655
|
@ -317,10 +317,17 @@ function preprocessConfig(cfg) {
|
|||
cfg.io["ipv6-default"] = cfg.io["ipv6-ssl"] || cfg.io["ipv6-nossl"];
|
||||
|
||||
// sioconfig
|
||||
var sioconfig = "var IO_URLS={'ipv4-nossl':'" + cfg.io["ipv4-nossl"] + "'," +
|
||||
"'ipv4-ssl':'" + cfg.io["ipv4-ssl"] + "'," +
|
||||
"'ipv6-nossl':'" + cfg.io["ipv6-nossl"] + "'," +
|
||||
"'ipv6-ssl':'" + cfg.io["ipv6-ssl"] + "'};";
|
||||
// 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
|
||||
|
|
|
@ -120,6 +120,11 @@ function handleIndex(req, res) {
|
|||
* Handles a request for the socket.io information
|
||||
*/
|
||||
function handleSocketConfig(req, res) {
|
||||
if (/\.json$/.test(req.path)) {
|
||||
res.json(Config.get("sioconfigjson"));
|
||||
return;
|
||||
}
|
||||
|
||||
res.type("application/javascript");
|
||||
|
||||
var sioconfig = Config.get("sioconfig");
|
||||
|
@ -237,7 +242,7 @@ module.exports = {
|
|||
|
||||
app.get("/r/:channel", handleChannel);
|
||||
app.get("/", handleIndex);
|
||||
app.get("/sioconfig", handleSocketConfig);
|
||||
app.get("/sioconfig(.json)?", handleSocketConfig);
|
||||
app.get("/useragreement", handleUserAgreement);
|
||||
app.get("/contact", handleContactPage);
|
||||
require("./auth").init(app);
|
||||
|
|
Loading…
Reference in New Issue