LSP: fix for HTTP(S).pubaddr detection

This commit is contained in:
Cat 2020-09-21 21:42:52 +02:00 committed by Thulinma
parent fcc61a4b21
commit 7cb3068b96
2 changed files with 9 additions and 9 deletions

View file

@ -137,7 +137,7 @@ switch(b.name){case "Buffer":case "Buffer.exe":d.push({label:"RTMP full url",typ
d.push({label:"RTSP",type:"span",clipboard:true,readonly:true,classes:["RTSP"]});break;case "TS":case "TS.exe":a.charAt(0)=="/"?d=[]:d.push({label:"TS",type:"span",clipboard:true,readonly:true,classes:["TS"]})}M.html(UI.buildUI(d));ma()}}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",LTSonly:!0,pointer:{main:o,index:"stop_sessions"}},M,$("<br>"),{type:"custom",custom:ca},Ka,$("<br>"),$("<h3>").text("Encryption"),{type:"help", d.push({label:"RTSP",type:"span",clipboard:true,readonly:true,classes:["RTSP"]});break;case "TS":case "TS.exe":a.charAt(0)=="/"?d=[]:d.push({label:"TS",type:"span",clipboard:true,readonly:true,classes:["TS"]})}M.html(UI.buildUI(d));ma()}}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",LTSonly:!0,pointer:{main:o,index:"stop_sessions"}},M,$("<br>"),{type:"custom",custom:ca},Ka,$("<br>"),$("<h3>").text("Encryption"),{type:"help",
help:"To enable encryption, the licence acquisition url must be entered, as well as either the content key or the key ID and seed.<br>Unsure how you should fill in your encryption or missing your preferred encryption? Please contact us."},{label:"License acquisition url",type:"str",LTSonly:!0,pointer:{main:o,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:o,index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:o, help:"To enable encryption, the licence acquisition url must be entered, as well as either the content key or the key ID and seed.<br>Unsure how you should fill in your encryption or missing your preferred encryption? Please contact us."},{label:"License acquisition url",type:"str",LTSonly:!0,pointer:{main:o,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:o,index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:o,
index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:o,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){Ia("Streams")}},{type:"save",label:"Save and Preview","function":function(){Ia("Preview")},classes:["saveandpreview"]}]}]));c.find("[name=name]").keyup(function(){ma()});ma();break;case "Preview":""==b&&UI.navto("Streams");var N=parseURL(mist.user.host),U=N.protocol, index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:o,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){Ia("Streams")}},{type:"save",label:"Save and Preview","function":function(){Ia("Preview")},classes:["saveandpreview"]}]}]));c.find("[name=name]").keyup(function(){ma()});ma();break;case "Preview":""==b&&UI.navto("Streams");var N=parseURL(mist.user.host),U=N.protocol,
R=N.host,G=":8080",u=U+R+G+"/";for(r in mist.data.config.protocols)if(s=mist.data.config.protocols[r],"HTTP"==s.connector||"HTTP.exe"==s.connector){s.pubaddr&&s.pubaddr.length?u="string"==typeof s.pubaddr?s.pubaddr.replace(/\/$/,"")+"/":s.pubaddr[0].replace(/\/$/,"")+"/":(G=s.port?":"+s.port:":8080",u=U+R+G+"/");break}var Q=$("<div>").css({display:"flex","flex-flow":"row wrap","flex-shrink":1,"min-width":"auto"}),V="";-1==b.indexOf("+")&&(V=$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit", R=N.host,G=":8080",u=U+R+G+"/";for(r in mist.data.config.protocols)if(s=mist.data.config.protocols[r],"HTTP"==s.connector||"HTTP.exe"==s.connector){s.pubaddr&&s.pubaddr.length?"string"==typeof s.pubaddr?u=s.pubaddr.replace(/\/$/,"")+"/":s.pubaddr.length&&(u=s.pubaddr[0].replace(/\/$/,"")+"/"):(G=s.port?":"+s.port:":8080",u=U+R+G+"/");break}var Q=$("<div>").css({display:"flex","flex-flow":"row wrap","flex-shrink":1,"min-width":"auto"}),V="";-1==b.indexOf("+")&&(V=$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",
b)}));c.html($("<div>").addClass("bigbuttons").append(V).append($("<button>").text("Embed").addClass("embed").click(function(){UI.navto("Embed",b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Preview of "'+b+'"')).append(Q);var H=encodeURIComponent(b),Ma=$("<div>").css("flex-shrink","1").css("min-width","auto").css("max-width","100%");Q.append(Ma);var Na=$("<div>"),W=$("<div>").text("Loading player..").css("max-width", b)}));c.html($("<div>").addClass("bigbuttons").append(V).append($("<button>").text("Embed").addClass("embed").click(function(){UI.navto("Embed",b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Preview of "'+b+'"')).append(Q);var H=encodeURIComponent(b),Ma=$("<div>").css("flex-shrink","1").css("min-width","auto").css("max-width","100%");Q.append(Ma);var Na=$("<div>"),W=$("<div>").text("Loading player..").css("max-width",
"100%").css("flex-shrink","1").css("min-width","auto"),oa=$("<div>").addClass("controls");Ma.append(W).append(Na).append(oa);$("link#devcss").length||c.append($("<link>").attr("rel","stylesheet").attr("type","text/css").attr("href",u+"skins/dev.css").attr("id","devcss"));var Oa=function(){Na.text("");var d=document.createElement("script");c.append(d);d.src=u+"player.js";d.onerror=function(){W.html($("<p>").append('Failed to load <a href="'+u+'player.js">'+u+"player.js</a>.")).append($("<p>").append("Please check if you've activated the HTTP protocol, if your http port is blocked, or if you're trying to load HTTPS on an HTTP page.")).append($("<button>").text("Reload").css("display", "100%").css("flex-shrink","1").css("min-width","auto"),oa=$("<div>").addClass("controls");Ma.append(W).append(Na).append(oa);$("link#devcss").length||c.append($("<link>").attr("rel","stylesheet").attr("type","text/css").attr("href",u+"skins/dev.css").attr("id","devcss"));var Oa=function(){Na.text("");var d=document.createElement("script");c.append(d);d.src=u+"player.js";d.onerror=function(){W.html($("<p>").append('Failed to load <a href="'+u+'player.js">'+u+"player.js</a>.")).append($("<p>").append("Please check if you've activated the HTTP protocol, if your http port is blocked, or if you're trying to load HTTPS on an HTTP page.")).append($("<button>").text("Reload").css("display",
"block").click(function(){Oa()}))};d.onload=function(){var g=b,f=function(){var a=MistVideoObject.reference;oa.html("");oa.append(a.UI.buildStructure({type:"container",classes:["mistvideo-column"],style:{flexShrink:1},children:[{"if":function(){return this.playerName&&this.source},then:{type:"container",classes:["mistvideo-description"],style:{display:"block"},children:[{type:"playername",style:{display:"inline"}},{type:"text",text:"is playing",style:{margin:"0 0.2em"}},{type:"mimetype"}]}},{type:"decodingIssues", "block").click(function(){Oa()}))};d.onload=function(){var g=b,f=function(){var a=MistVideoObject.reference;oa.html("");oa.append(a.UI.buildStructure({type:"container",classes:["mistvideo-column"],style:{flexShrink:1},children:[{"if":function(){return this.playerName&&this.source},then:{type:"container",classes:["mistvideo-description"],style:{display:"block"},children:[{type:"playername",style:{display:"inline"}},{type:"text",text:"is playing",style:{margin:"0 0.2em"}},{type:"mimetype"}]}},{type:"decodingIssues",
@ -150,10 +150,10 @@ MistVideoObject.reference={unload:function(){d.onload=function(){this.parentElem
"px"),UI.format.addUnit(UI.format.number(i.fpks/1E3),"fps"),"language"in i?i.language:"unknown",e,"bframes"in i?"yes":"no"]});e++;break;case "meta":case "subtitle":if(i.codec=="subtitle"||i.type=="subtitle"){d.subtitle.content.push({header:"Track "+k.split("_").pop(),body:[i.codec,UI.format.duration((i.lastms-i.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(i.firstms/1E3)+" to "+UI.format.duration(i.lastms/1E3)+"</span>",b(i,"bps"),b(i,"maxbps"),"language"in i?i.language:"unknown", "px"),UI.format.addUnit(UI.format.number(i.fpks/1E3),"fps"),"language"in i?i.language:"unknown",e,"bframes"in i?"yes":"no"]});e++;break;case "meta":case "subtitle":if(i.codec=="subtitle"||i.type=="subtitle"){d.subtitle.content.push({header:"Track "+k.split("_").pop(),body:[i.codec,UI.format.duration((i.lastms-i.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(i.firstms/1E3)+" to "+UI.format.duration(i.lastms/1E3)+"</span>",b(i,"bps"),b(i,"maxbps"),"language"in i?i.language:"unknown",
h]});h++}}}b=["audio","video","subtitle"];j=$("<div>").css({display:"flex","flex-flow":"row wrap","font-size":"0.9em"});for(k in b)d[b[k]].content.length&&j.append(UI.buildVheaderTable(d[b[k]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(j);da.html(UI.buildUI(a))}},error:function(){da.html("Error while retrieving stream info.")}});break;case "Embed":""==b&&UI.navTo("Streams");V="";-1==b.indexOf("+")&&(V=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit", h]});h++}}}b=["audio","video","subtitle"];j=$("<div>").css({display:"flex","flex-flow":"row wrap","font-size":"0.9em"});for(k in b)d[b[k]].content.length&&j.append(UI.buildVheaderTable(d[b[k]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(j);da.html(UI.buildUI(a))}},error:function(){da.html("Error while retrieving stream info.")}});break;case "Embed":""==b&&UI.navTo("Streams");V="";-1==b.indexOf("+")&&(V=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",
b)}));c.html($("<div>").addClass("bigbuttons").append(V).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+b+'"'));var X=$("<span>");c.append(X);var H=encodeURIComponent(b),N=parseURL(mist.user.host),U=N.protocol,R=N.host,G=":8080",Y,ea={},u={http:U+R+G+"/"};for(r in mist.data.config.protocols)if(s=mist.data.config.protocols[r], b)}));c.html($("<div>").addClass("bigbuttons").append(V).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+b+'"'));var X=$("<span>");c.append(X);var H=encodeURIComponent(b),N=parseURL(mist.user.host),U=N.protocol,R=N.host,G=":8080",Y,ea={},u={http:U+R+G+"/"};for(r in mist.data.config.protocols)if(s=mist.data.config.protocols[r],
"HTTP"==s.connector||"HTTP.exe"==s.connector)s.pubaddr&&s.pubaddr.length?(u.http="string"==typeof s.pubaddr?s.pubaddr.replace(/\/$/,"")+"/":s.pubaddr[0].replace(/\/$/,"")+"/",ea.http=s.pubaddr):(G=s.port?":"+s.port:":8080",u.http=U+R+G+"/");else if("HTTPS"==s.connector||"HTTPS.exe"==s.connector)s.pubaddr&&s.pubaddr.length?(u.https="string"==typeof s.pubaddr?s.pubaddr.replace(/\/$/,"")+"/":s.pubaddr[0].replace(/\/$/,"")+"/",ea.https=s.pubaddr):(Y=s.port?":"+s.port:":4433",u.https="https://"+R+Y+"/"); "HTTP"==s.connector||"HTTP.exe"==s.connector)s.pubaddr?("string"==typeof s.pubaddr?u.http=s.pubaddr.replace(/\/$/,"")+"/":s.pubaddr.length&&(u.http=s.pubaddr[0].replace(/\/$/,"")+"/"),ea.http=s.pubaddr):(G=s.port?":"+s.port:":8080",u.http=U+R+G+"/");else if("HTTPS"==s.connector||"HTTPS.exe"==s.connector)s.pubaddr&&s.pubaddr.length?("string"==typeof s.pubaddr?u.https=s.pubaddr.replace(/\/$/,"")+"/":s.pubaddr.length&&(u.https=s.pubaddr[0].replace(/\/$/,"")+"/"),ea.https=s.pubaddr):(Y=s.port?":"+s.port:
var O=u.http,A={http:u.http};"https"in u&&(A.https=u.https);if(otherhost.host||otherhost.https){O=(otherhost.https&&Y?"https://":"http://")+(otherhost.host?otherhost.host:N.host)+(otherhost.https&&Y?Y:G)+"/";if(otherhost.host&&("http"in ea||(A.http=parseURL(A.http,{hostname:otherhost.host}).full),"https"in A&&!("https"in ea)))A.https=parseURL(A.https,{hostname:otherhost.host}).full;O=otherhost.https?A.https:A.http}var Z=!1,pa={forcePlayer:"",forceType:"",controls:!0,autoplay:!0,loop:!1,muted:!1,fillSpace:!1, ":4433",u.https="https://"+R+Y+"/");var O=u.http,A={http:u.http};"https"in u&&(A.https=u.https);if(otherhost.host||otherhost.https){O=(otherhost.https&&Y?"https://":"http://")+(otherhost.host?otherhost.host:N.host)+(otherhost.https&&Y?Y:G)+"/";if(otherhost.host&&("http"in ea||(A.http=parseURL(A.http,{hostname:otherhost.host}).full),"https"in A&&!("https"in ea)))A.https=parseURL(A.https,{hostname:otherhost.host}).full;O=otherhost.https?A.https:A.http}var Z=!1,pa={forcePlayer:"",forceType:"",controls:!0,
poster:"",urlappend:"",setTracks:{}},p=$.extend({},pa),Qa=UI.stored.getOpts();"embedoptions"in Qa&&(p=$.extend(p,Qa.embedoptions,!0),"object"!=typeof p.setTracks&&(p.setTracks={}));var fa={};switch(p.controls){case "stock":fa.controls="stock";break;case !0:fa.controls=1;break;case !1:fa.controls=0}var x=function(){function a(b){switch(typeof b){case "string":return $.isNumeric(b)?b:'"'+b+'"';case "object":return JSON.stringify(b);default:return b}}Z&&UI.stored.saveOpt("embedoptions",p);for(var c= autoplay:!0,loop:!1,muted:!1,fillSpace:!1,poster:"",urlappend:"",setTracks:{}},p=$.extend({},pa),Qa=UI.stored.getOpts();"embedoptions"in Qa&&(p=$.extend(p,Qa.embedoptions,!0),"object"!=typeof p.setTracks&&(p.setTracks={}));var fa={};switch(p.controls){case "stock":fa.controls="stock";break;case !0:fa.controls=1;break;case !1:fa.controls=0}var x=function(){function a(b){switch(typeof b){case "string":return $.isNumeric(b)?b:'"'+b+'"';case "object":return JSON.stringify(b);default:return b}}Z&&UI.stored.saveOpt("embedoptions",
b+"_",d=12,g="";d--;){var f;f=Math.floor(Math.random()*62);f=f<10?f:f<36?String.fromCharCode(f+55):String.fromCharCode(f+61);g=g+f}var c=c+g,d=['target: document.getElementById("'+c+'")'],e;for(e in p)e=="prioritize_type"?p[e]&&p[e]!=""&&d.push("forcePriority: "+JSON.stringify({source:[["type",[p[e]]]]})):e=="monitor_action"?p[e]&&p[e]!=""&&p[e]=="nextCombo"&&d.push('monitor: {\n action: function(){\n this.MistVideo.log("Switching to nextCombo because of poor playback in "+this.MistVideo.source.type+" ("+Math.round(this.vars.score*1000)/10+"%)");\n this.MistVideo.nextCombo();\n }\n }'): p);for(var c=b+"_",d=12,g="";d--;){var f;f=Math.floor(Math.random()*62);f=f<10?f:f<36?String.fromCharCode(f+55):String.fromCharCode(f+61);g=g+f}var c=c+g,d=['target: document.getElementById("'+c+'")'],e;for(e in p)e=="prioritize_type"?p[e]&&p[e]!=""&&d.push("forcePriority: "+JSON.stringify({source:[["type",[p[e]]]]})):e=="monitor_action"?p[e]&&p[e]!=""&&p[e]=="nextCombo"&&d.push('monitor: {\n action: function(){\n this.MistVideo.log("Switching to nextCombo because of poor playback in "+this.MistVideo.source.type+" ("+Math.round(this.vars.score*1000)/10+"%)");\n this.MistVideo.nextCombo();\n }\n }'):
p[e]!=pa[e]&&(p[e]!=null&&(typeof p[e]!="object"||JSON.stringify(p[e])!=JSON.stringify(pa[e])))&&d.push(e+": "+a(p[e]));e=[];e.push('<div class="mistvideo" id="'+c+'">');e.push(" <noscript>");e.push(' <a href="'+(otherhost.https?A.https:A.http)+H+'.html" target="_blank">');e.push(" Click here to play this video");e.push(" </a>");e.push(" </noscript>");e.push(" <script>");e.push(" var a = function(){");e.push(' mistPlay("'+b+'",{');e.push(" "+d.join(",\n "));e.push(" });"); p[e]!=pa[e]&&(p[e]!=null&&(typeof p[e]!="object"||JSON.stringify(p[e])!=JSON.stringify(pa[e])))&&d.push(e+": "+a(p[e]));e=[];e.push('<div class="mistvideo" id="'+c+'">');e.push(" <noscript>");e.push(' <a href="'+(otherhost.https?A.https:A.http)+H+'.html" target="_blank">');e.push(" Click here to play this video");e.push(" </a>");e.push(" </noscript>");e.push(" <script>");e.push(" var a = function(){");e.push(' mistPlay("'+b+'",{');e.push(" "+d.join(",\n "));e.push(" });");
e.push(" };");e.push(" if (!window.mistplayers) {");e.push(' var p = document.createElement("script");');if("https"in u&&parseURL(u.http).protocol!="https://"){e.push(' if (location.protocol == "https:") { p.src = "'+A.https+'player.js" } ');e.push(' else { p.src = "'+A.http+'player.js" } ')}else e.push(' p.src = "'+O+'player.js"');e.push(" document.head.appendChild(p);");e.push(" p.onload = a;");e.push(" }");e.push(" else { a(); }");e.push(" <\/script>"); e.push(" };");e.push(" if (!window.mistplayers) {");e.push(' var p = document.createElement("script");');if("https"in u&&parseURL(u.http).protocol!="https://"){e.push(' if (location.protocol == "https:") { p.src = "'+A.https+'player.js" } ');e.push(' else { p.src = "'+A.http+'player.js" } ')}else e.push(' p.src = "'+O+'player.js"');e.push(" document.head.appendChild(p);");e.push(" p.onload = a;");e.push(" }");e.push(" else { a(); }");e.push(" <\/script>");
e.push("</div>");return e.join("\n")},qa=$("<span>").text("Loading.."),Ra=x(p),S=$("<div>").text("Loading..").css("display","flex").css("flex-flow","column nowrap"),Sa="";"https"in u&&(Sa=UI.buildUI([{label:"Use HTTPS",type:"checkbox","function":function(){if($(this).getval()!=otherhost.https){otherhost.https=$(this).getval();UI.navto("Embed",b)}},value:otherhost.https}]).find("label"));X.append($("<span>").addClass("input_container").append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Use a different host:")).append($("<span>").addClass("field_container").append($("<input>").attr("type", e.push("</div>");return e.join("\n")},qa=$("<span>").text("Loading.."),Ra=x(p),S=$("<div>").text("Loading..").css("display","flex").css("flex-flow","column nowrap"),Sa="";"https"in u&&(Sa=UI.buildUI([{label:"Use HTTPS",type:"checkbox","function":function(){if($(this).getval()!=otherhost.https){otherhost.https=$(this).getval();UI.navto("Embed",b)}},value:otherhost.https}]).find("label"));X.append($("<span>").addClass("input_container").append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Use a different host:")).append($("<span>").addClass("field_container").append($("<input>").attr("type",

View file

@ -4028,7 +4028,7 @@ var UI = {
if (typeof protocol.pubaddr == "string") { if (typeof protocol.pubaddr == "string") {
embedbase = protocol.pubaddr.replace(/\/$/,'')+"/"; embedbase = protocol.pubaddr.replace(/\/$/,'')+"/";
} }
else { else if (protocol.pubaddr.length) {
embedbase = protocol.pubaddr[0].replace(/\/$/,'')+"/"; embedbase = protocol.pubaddr[0].replace(/\/$/,'')+"/";
} }
} }
@ -4403,11 +4403,11 @@ var UI = {
for (var i in mist.data.config.protocols) { for (var i in mist.data.config.protocols) {
var protocol = mist.data.config.protocols[i]; var protocol = mist.data.config.protocols[i];
if ((protocol.connector == 'HTTP') || (protocol.connector == 'HTTP.exe')) { if ((protocol.connector == 'HTTP') || (protocol.connector == 'HTTP.exe')) {
if (protocol.pubaddr && protocol.pubaddr.length) { if (protocol.pubaddr) {
if (typeof protocol.pubaddr == "string") { if (typeof protocol.pubaddr == "string") {
embedbase.http = protocol.pubaddr.replace(/\/$/,'')+"/"; embedbase.http = protocol.pubaddr.replace(/\/$/,'')+"/";
} }
else { else if (protocol.pubaddr.length) {
embedbase.http = protocol.pubaddr[0].replace(/\/$/,'')+"/"; embedbase.http = protocol.pubaddr[0].replace(/\/$/,'')+"/";
} }
puburls.http = protocol.pubaddr; puburls.http = protocol.pubaddr;
@ -4422,7 +4422,7 @@ var UI = {
if (typeof protocol.pubaddr == "string") { if (typeof protocol.pubaddr == "string") {
embedbase.https = protocol.pubaddr.replace(/\/$/,'')+"/"; embedbase.https = protocol.pubaddr.replace(/\/$/,'')+"/";
} }
else { else if (protocol.pubaddr.length) {
embedbase.https = protocol.pubaddr[0].replace(/\/$/,'')+"/"; embedbase.https = protocol.pubaddr[0].replace(/\/$/,'')+"/";
} }
puburls.https = protocol.pubaddr; puburls.https = protocol.pubaddr;