mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-06-06 23:57:21 +02:00
Bug fix
+ Added potential fix for #67 + Update version number + Changed default static web port to 5487 so it is even more unlikely to be used +
This commit is contained in:
parent
50f222cced
commit
156fa5dace
@ -47,9 +47,9 @@ var allowWebFileManager = flag.Bool("webfm", true, "Enable web file manager for
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
name = "Zoraxy"
|
name = "Zoraxy"
|
||||||
version = "2.6.7"
|
version = "2.6.8"
|
||||||
nodeUUID = "generic"
|
nodeUUID = "generic"
|
||||||
development = false //Set this to false to use embedded web fs
|
development = true //Set this to false to use embedded web fs
|
||||||
bootTime = time.Now().Unix()
|
bootTime = time.Now().Unix()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -220,7 +220,7 @@ func startupSequence() {
|
|||||||
|
|
||||||
staticWebServer = webserv.NewWebServer(&webserv.WebServerOptions{
|
staticWebServer = webserv.NewWebServer(&webserv.WebServerOptions{
|
||||||
Sysdb: sysdb,
|
Sysdb: sysdb,
|
||||||
Port: "8081", //Default Port
|
Port: "5487", //Default Port
|
||||||
WebRoot: *staticWebServerRoot,
|
WebRoot: *staticWebServerRoot,
|
||||||
EnableDirectoryListing: true,
|
EnableDirectoryListing: true,
|
||||||
EnableWebDirManager: *allowWebFileManager,
|
EnableWebDirManager: *allowWebFileManager,
|
||||||
|
@ -75,13 +75,13 @@
|
|||||||
$("#rootReqTLS").parent().addClass("disabled");
|
$("#rootReqTLS").parent().addClass("disabled");
|
||||||
|
|
||||||
//Check if web server is enabled. If not, ask if the user want to enable it
|
//Check if web server is enabled. If not, ask if the user want to enable it
|
||||||
if (!$("#webserv_enable").parent().checkbox("is checked")){
|
/*if (!$("#webserv_enable").parent().checkbox("is checked")){
|
||||||
confirmBox("Enable static web server now?", function(choice){
|
confirmBox("Enable static web server now?", function(choice){
|
||||||
if (choice == true){
|
if (choice == true){
|
||||||
$("#webserv_enable").parent().checkbox("set checked");
|
$("#webserv_enable").parent().checkbox("set checked");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}*/
|
||||||
}else{
|
}else{
|
||||||
$("#rootReqTLS").parent().removeClass("disabled");
|
$("#rootReqTLS").parent().removeClass("disabled");
|
||||||
$("#proxyRoot").parent().removeClass("disabled");
|
$("#proxyRoot").parent().removeClass("disabled");
|
||||||
@ -89,7 +89,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function initRootInfo(){
|
function initRootInfo(callback=undefined){
|
||||||
$.get("/api/proxy/list?type=root", function(data){
|
$.get("/api/proxy/list?type=root", function(data){
|
||||||
if (data == null){
|
if (data == null){
|
||||||
|
|
||||||
@ -97,10 +97,37 @@
|
|||||||
$("#proxyRoot").val(data.Domain);
|
$("#proxyRoot").val(data.Domain);
|
||||||
checkRootRequireTLS(data.Domain);
|
checkRootRequireTLS(data.Domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (callback != undefined){
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
initRootInfo(function(){
|
||||||
|
updateWebServerLinkSettings();
|
||||||
|
});
|
||||||
|
|
||||||
|
//Update the current web server port settings
|
||||||
|
function updateWebServerLinkSettings(){
|
||||||
|
isUsingStaticWebServerAsRoot(function(isUsingWebServ){
|
||||||
|
if (isUsingWebServ){
|
||||||
|
$(".webservRootDisabled").addClass("disabled");
|
||||||
|
}else{
|
||||||
|
$(".webservRootDisabled").removeClass("disabled");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function isUsingStaticWebServerAsRoot(callback){
|
||||||
|
let currentProxyRoot = $("#proxyRoot").val().trim();
|
||||||
|
$.get("/api/webserv/status", function(webservStatus){
|
||||||
|
if (currentProxyRoot == "127.0.0.1:" + webservStatus.ListeningPort || currentProxyRoot == "localhost:" + webservStatus.ListeningPort){
|
||||||
|
return callback(true);
|
||||||
|
}
|
||||||
|
return callback(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
initRootInfo();
|
|
||||||
|
|
||||||
function updateRootSettingStates(){
|
function updateRootSettingStates(){
|
||||||
$.get("/api/cert/tls", function(data){
|
$.get("/api/cert/tls", function(data){
|
||||||
@ -111,6 +138,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//Bind event to tab switch
|
//Bind event to tab switch
|
||||||
tabSwitchEventBind["setroot"] = function(){
|
tabSwitchEventBind["setroot"] = function(){
|
||||||
//On switch over to this page, update root info
|
//On switch over to this page, update root info
|
||||||
@ -137,11 +165,12 @@
|
|||||||
let useRedirect = $("#unsetRedirect")[0].checked;
|
let useRedirect = $("#unsetRedirect")[0].checked;
|
||||||
updateRedirectionDomainSettingInputBox(useRedirect);
|
updateRedirectionDomainSettingInputBox(useRedirect);
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
checkCustomRedirectForUnsetSubd();
|
checkCustomRedirectForUnsetSubd();
|
||||||
|
|
||||||
|
//Check if the given domain will redirect to https
|
||||||
function checkRootRequireTLS(targetDomain){
|
function checkRootRequireTLS(targetDomain){
|
||||||
//Trim off the http or https from the origin
|
//Trim off the http or https from the origin
|
||||||
if (targetDomain.startsWith("http://")){
|
if (targetDomain.startsWith("http://")){
|
||||||
@ -168,7 +197,7 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Set the new proxy root option
|
||||||
function setProxyRoot(){
|
function setProxyRoot(){
|
||||||
var newpr = $("#proxyRoot").val();
|
var newpr = $("#proxyRoot").val();
|
||||||
if (newpr.trim() == ""){
|
if (newpr.trim() == ""){
|
||||||
@ -189,8 +218,24 @@
|
|||||||
msgbox(data.error, false, 5000);
|
msgbox(data.error, false, 5000);
|
||||||
}else{
|
}else{
|
||||||
//OK
|
//OK
|
||||||
initRootInfo();
|
initRootInfo(function(){
|
||||||
msgbox("Proxy Root Updated")
|
//Check if WebServ is enabled
|
||||||
|
isUsingStaticWebServerAsRoot(function(isUsingWebServ){
|
||||||
|
if (isUsingWebServ){
|
||||||
|
//Force enable static web server
|
||||||
|
//See webserv.html for details
|
||||||
|
setWebServerRunningState(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(function(){
|
||||||
|
//Update the checkbox
|
||||||
|
updateWebServerLinkSettings();
|
||||||
|
msgbox("Proxy Root Updated");
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<h3>Web Server Settings</h3>
|
<h3>Web Server Settings</h3>
|
||||||
<div class="ui form">
|
<div class="ui form">
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
<div class="ui toggle checkbox">
|
<div class="ui toggle checkbox webservRootDisabled">
|
||||||
<input id="webserv_enable" type="checkbox" class="hidden">
|
<input id="webserv_enable" type="checkbox" class="hidden">
|
||||||
<label>Enable Static Web Server</label>
|
<label>Enable Static Web Server</label>
|
||||||
</div>
|
</div>
|
||||||
@ -37,7 +37,7 @@
|
|||||||
See the -webserv flag for more details.
|
See the -webserv flag for more details.
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field webservRootDisabled">
|
||||||
<label>Port Number</label>
|
<label>Port Number</label>
|
||||||
<input id="webserv_listenPort" type="number" step="1" min="0" max="65535" value="8081" onchange="updateWebServLinkExample(this.value);">
|
<input id="webserv_listenPort" type="number" step="1" min="0" max="65535" value="8081" onchange="updateWebServLinkExample(this.value);">
|
||||||
<small>Use <code>http://127.0.0.1:<span class="webserv_port">8081</span></code> in proxy rules to access the web server</small>
|
<small>Use <code>http://127.0.0.1:<span class="webserv_port">8081</span></code> in proxy rules to access the web server</small>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user