LSP: added trusted proxy config option

This commit is contained in:
Cat 2020-02-19 12:30:19 +01:00 committed by Thulinma
parent a75ac5713c
commit b9eb03a599
2 changed files with 15 additions and 4 deletions

View file

@ -85,12 +85,13 @@ type:"str",validate:["required"],help:"Enter your desired username. In the futur
mist.user.password=MD5(mist.user.rawpassword);delete mist.user.rawpassword}}]}]));break;case "Account created":UI.elements.menu.addClass("hide");d.append($("<p>").text("Your account has been created succesfully.")).append(UI.buildUI([{type:"text",text:"Would you like to enable all (currently) available protocols with their default settings?"},{type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)d.append("Unable to enable all protocols as protocol settings already exist.<br>"); mist.user.password=MD5(mist.user.rawpassword);delete mist.user.rawpassword}}]}]));break;case "Account created":UI.elements.menu.addClass("hide");d.append($("<p>").text("Your account has been created succesfully.")).append(UI.buildUI([{type:"text",text:"Would you like to enable all (currently) available protocols with their default settings?"},{type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)d.append("Unable to enable all protocols as protocol settings already exist.<br>");
else{d.append("Retrieving available protocols..<br>");mist.send(function(a){var b=[],c;for(c in a.capabilities.connectors)if(a.capabilities.connectors[c].required)d.append('Could not enable protocol "'+c+'" because it has required settings.<br>');else{b.push({connector:c});d.append('Enabled protocol "'+c+'".<br>')}d.append("Saving protocol settings..<br>");mist.send(function(){d.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:b}})},{capabilities:true})}}}, else{d.append("Retrieving available protocols..<br>");mist.send(function(a){var b=[],c;for(c in a.capabilities.connectors)if(a.capabilities.connectors[c].required)d.append('Could not enable protocol "'+c+'" because it has required settings.<br>');else{b.push({connector:c});d.append('Enabled protocol "'+c+'".<br>')}d.append("Saving protocol settings..<br>");mist.send(function(){d.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:b}})},{capabilities:true})}}},
{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":if("undefined"==typeof mist.data.bandwidth){mist.send(function(){UI.navto(a)},{bandwidth:!0});d.append("Loading..");return}var f=$("<span>").text("Loading.."),n=$("<span>"),o=$("<span>").addClass("logs"),e=$("<span>"),r=$("<span>"),i=$("<span>").text("Unknown"),l=$("<span>"),u=$("<span>"),g={serverid:mist.data.config.serverid,debug:mist.data.config.debug,accesslog:mist.data.config.accesslog,prometheus:mist.data.config.prometheus, {label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":if("undefined"==typeof mist.data.bandwidth){mist.send(function(){UI.navto(a)},{bandwidth:!0});d.append("Loading..");return}var f=$("<span>").text("Loading.."),n=$("<span>"),o=$("<span>").addClass("logs"),e=$("<span>"),r=$("<span>"),i=$("<span>").text("Unknown"),l=$("<span>"),u=$("<span>"),g={serverid:mist.data.config.serverid,debug:mist.data.config.debug,accesslog:mist.data.config.accesslog,prometheus:mist.data.config.prometheus,
defaultStream:mist.data.config.defaultStream},h={};"bandwidth"in mist.data&&(h=mist.data.bandwidth,null==h&&(h={}),h.limit||(h.limit=""));var k=$("<select>").html($("<option>").val(1).text("bytes/s")).append($("<option>").val(1024).text("KiB/s")).append($("<option>").val(1048576).text("MiB/s")).append($("<option>").val(1073741824).text("GiB/s")),b=parseURL(mist.user.host),b=b.protocol+b.host+b.port;d.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "}, defaultStream:mist.data.config.defaultStream,trustedproxy:mist.data.config.trustedproxy},h={};"bandwidth"in mist.data&&(h=mist.data.bandwidth,null==h&&(h={}),h.limit||(h.limit=""));var k=$("<select>").html($("<option>").val(1).text("bytes/s")).append($("<option>").val(1024).text("KiB/s")).append($("<option>").val(1048576).text("MiB/s")).append($("<option>").val(1073741824).text("GiB/s")),b=parseURL(mist.user.host),b=b.protocol+b.host+b.port;d.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},
{type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:f,LTSonly:!0},{type:"span",label:"Server time",value:r},{type:"span",label:"Licensed to",value:"license"in mist.data.config?mist.data.config.license.user:"",LTSonly:!0},{type:"span",label:"Active licenses",value:i,LTSonly:!0},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:n},{type:"span", {type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:f,LTSonly:!0},{type:"span",label:"Server time",value:r},{type:"span",label:"Licensed to",value:"license"in mist.data.config?mist.data.config.license.user:"",LTSonly:!0},{type:"span",label:"Active licenses",value:i,LTSonly:!0},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:n},{type:"span",
label:"Current connections",value:e},{type:"span",label:"Enabled protocols",value:l},{type:"span",label:"Disabled protocols",value:u},{type:"span",label:"Recent problems",value:o},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:g,index:"serverid"},help:"You can name your MistServer here for personal use. You'll still need to set host name within your network yourself."},{type:"debug",label:"Debug level",pointer:{main:g,index:"debug"},help:"You can set the amount of debug information MistServer saves in the log. A full reboot of MistServer is required before some components of MistServer can post debug information."}, label:"Current connections",value:e},{type:"span",label:"Enabled protocols",value:l},{type:"span",label:"Disabled protocols",value:u},{type:"span",label:"Recent problems",value:o},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:g,index:"serverid"},help:"You can name your MistServer here for personal use. You'll still need to set host name within your network yourself."},{type:"debug",label:"Debug level",pointer:{main:g,index:"debug"},help:"You can set the amount of debug information MistServer saves in the log. A full reboot of MistServer is required before some components of MistServer can post debug information."},
{type:"selectinput",label:"Access log",selectinput:[["","Do not track"],["LOG","Log to MistServer log"],[{type:"str",label:"Path",LTSonly:!0},"Log to file"]],pointer:{main:g,index:"accesslog"},help:"Enable access logs.",LTSonly:!0},{type:"selectinput",label:"Prometheus stats output",selectinput:[["","Disabled"],[{type:"str",label:"Passphrase",LTSonly:!0},"Enabled"]],pointer:{main:g,index:"prometheus"},help:"Make stats available in Prometheus format. These can be accessed via "+b+"/PASSPHRASE or "+ {type:"selectinput",label:"Access log",selectinput:[["","Do not track"],["LOG","Log to MistServer log"],[{type:"str",label:"Path",LTSonly:!0},"Log to file"]],pointer:{main:g,index:"accesslog"},help:"Enable access logs.",LTSonly:!0},{type:"selectinput",label:"Prometheus stats output",selectinput:[["","Disabled"],[{type:"str",label:"Passphrase",LTSonly:!0},"Enabled"]],pointer:{main:g,index:"prometheus"},help:"Make stats available in Prometheus format. These can be accessed via "+b+"/PASSPHRASE or "+
b+"/PASSPHRASE.json.",LTSonly:!0},{type:"selectinput",label:"Load balancer bandwidth limit",selectinput:[["","Default (1 gbps)"],[{label:"Custom",type:"int",min:0,unit:k},"Custom"]],pointer:{main:h,index:"limit"},help:"This setting only applies when MistServer is combined with a load balancer. This is the amount of traffic this server is willing to handle.",LTSonly:!0},{type:"inputlist",label:"Load balancer bandwidth exceptions",pointer:{main:h,index:"exceptions"},help:"This setting only applies when MistServer is combined with a load balancer. Data sent to the hosts and subnets listed here will not count towards reported bandwidth usage.<br>Examples:<ul><li>192.168.0.0/16</li><li>localhost</li><li>10.0.0.0/8</li><li>fe80::/16</li></ul>", b+"/PASSPHRASE.json.",LTSonly:!0},{type:"inputlist",label:"Trusted proxies",help:"List of proxy server addresses that are allowed to override the viewer IP address to arbitrary values.<br>You may use a hostname or IP address.",LTSonly:!0,pointer:{main:g,index:"trustedproxy"}},{type:"selectinput",label:"Load balancer bandwidth limit",selectinput:[["","Default (1 gbps)"],[{label:"Custom",type:"int",min:0,unit:k},"Custom"]],pointer:{main:h,index:"limit"},help:"This setting only applies when MistServer is combined with a load balancer. This is the amount of traffic this server is willing to handle.",
LTSonly:!0},{type:"str",validate:["streamname_with_wildcard_and_variables"],label:"Fallback stream",pointer:{main:g,index:"defaultStream"},help:"When this is set, if someone attempts to view a stream that does not exist, or is offline, they will be redirected to this stream instead. $stream may be used to refer to the original stream name.",LTSonly:!0},{type:"checkbox",label:"Force configurations save",pointer:{main:g,index:"save"},help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don't forget to press save after ticking the box."}, LTSonly:!0},{type:"inputlist",label:"Load balancer bandwidth exceptions",pointer:{main:h,index:"exceptions"},help:"This setting only applies when MistServer is combined with a load balancer. Data sent to the hosts and subnets listed here will not count towards reported bandwidth usage.<br>Examples:<ul><li>192.168.0.0/16</li><li>localhost</li><li>10.0.0.0/8</li><li>fe80::/16</li></ul>",LTSonly:!0},{type:"str",validate:["streamname_with_wildcard_and_variables"],label:"Fallback stream",pointer:{main:g,
index:"defaultStream"},help:"When this is set, if someone attempts to view a stream that does not exist, or is offline, they will be redirected to this stream instead. $stream may be used to refer to the original stream name.",LTSonly:!0},{type:"checkbox",label:"Force configurations save",pointer:{main:g,index:"save"},help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don't forget to press save after ticking the box."},
{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={config:g},b={};b.limit=h.limit?k.val()*h.limit:0;b.exceptions=h.exceptions;if(b.exceptions===null)b.exceptions=[];a.bandwidth=b;if(g.save)a.save=g.save;delete g.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var j=function(a){function b(a){if(a.update){var d="";"progress"in a.update&&(d=" ("+a.update.progress+"%)");f.text("Updating.."+d);c(a.log);setTimeout(function(){mist.send(function(a){b(a)}, {type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={config:g},b={};b.limit=h.limit?k.val()*h.limit:0;b.exceptions=h.exceptions;if(b.exceptions===null)b.exceptions=[];a.bandwidth=b;if(g.save)a.save=g.save;delete g.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var j=function(a){function b(a){if(a.update){var d="";"progress"in a.update&&(d=" ("+a.update.progress+"%)");f.text("Updating.."+d);c(a.log);setTimeout(function(){mist.send(function(a){b(a)},
{update:true})},1E3)}else UI.showTab("Overview")}function c(a){a=a.filter(function(a){return a[1]=="UPDR"});if(a.length){var b=$("<div>");f.append(b);for(var d in a)b.append($("<div>").text(a[d][2]))}}if(!a.update||!("uptodate"in a.update)){f.text("Unknown, checking..");setTimeout(function(){mist.send(function(a){"update"in a&&j(a)},{checkupdate:true})},5E3)}else if(a.update.error)f.addClass("red").text(a.update.error);else if(a.update.uptodate)f.text("Your version is up to date.").addClass("green"); {update:true})},1E3)}else UI.showTab("Overview")}function c(a){a=a.filter(function(a){return a[1]=="UPDR"});if(a.length){var b=$("<div>");f.append(b);for(var d in a)b.append($("<div>").text(a[d][2]))}}if(!a.update||!("uptodate"in a.update)){f.text("Unknown, checking..");setTimeout(function(){mist.send(function(a){"update"in a&&j(a)},{checkupdate:true})},5E3)}else if(a.update.error)f.addClass("red").text(a.update.error);else if(a.update.uptodate)f.text("Your version is up to date.").addClass("green");
else{if(a.update.progress){f.addClass("orange").removeClass("red").text("Updating..");b(a)}else{f.text("");f.append($("<span>").addClass("red").text("On "+(new Date(a.update.date)).toLocaleDateString()+" version "+a.update.version+" became available."));(!a.update.url||a.update.url.slice(-4)!=".zip")&&f.append($("<button>").text("Rolling update").css({"font-size":"1em","margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){f.addClass("orange").removeClass("red").text("Rolling update command sent.."); else{if(a.update.progress){f.addClass("orange").removeClass("red").text("Updating..");b(a)}else{f.text("");f.append($("<span>").addClass("red").text("On "+(new Date(a.update.date)).toLocaleDateString()+" version "+a.update.version+" became available."));(!a.update.url||a.update.url.slice(-4)!=".zip")&&f.append($("<button>").text("Rolling update").css({"font-size":"1em","margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){f.addClass("orange").removeClass("red").text("Rolling update command sent..");

View file

@ -2367,7 +2367,8 @@ var UI = {
debug: mist.data.config.debug, debug: mist.data.config.debug,
accesslog: mist.data.config.accesslog, accesslog: mist.data.config.accesslog,
prometheus: mist.data.config.prometheus, prometheus: mist.data.config.prometheus,
defaultStream: mist.data.config.defaultStream defaultStream: mist.data.config.defaultStream,
trustedproxy: mist.data.config.trustedproxy
}; };
var b = {}; var b = {};
if ("bandwidth" in mist.data) { if ("bandwidth" in mist.data) {
@ -2494,6 +2495,15 @@ var UI = {
}, },
help: "Make stats available in Prometheus format. These can be accessed via "+host+"/PASSPHRASE or "+host+"/PASSPHRASE.json.", help: "Make stats available in Prometheus format. These can be accessed via "+host+"/PASSPHRASE or "+host+"/PASSPHRASE.json.",
LTSonly: true LTSonly: true
},{
type: "inputlist",
label: "Trusted proxies",
help: "List of proxy server addresses that are allowed to override the viewer IP address to arbitrary values.<br>You may use a hostname or IP address.",
LTSonly: true,
pointer: {
main: s,
index: "trustedproxy"
}
},{ },{
type: "selectinput", type: "selectinput",
label: "Load balancer bandwidth limit", label: "Load balancer bandwidth limit",