|
@@ -12,7 +12,7 @@
|
|
|
<p>Attach Virtual Directory routing rule to root proxy router</p>
|
|
|
<div class="ui checkbox">
|
|
|
<input type="checkbox" id="useRootProxyRouterForVdir" onchange="handleVdirAttachTargetChange(this);">
|
|
|
- <label>Use Root Proxy Router<br>
|
|
|
+ <label>Root Proxy Router<br>
|
|
|
<small>Only applicable when Default Site is set to "Reverse Proxy" mode</small></label>
|
|
|
</div>
|
|
|
<div class="ui horizontal divider">OR</div>
|
|
@@ -45,7 +45,7 @@
|
|
|
</tbody>
|
|
|
</table>
|
|
|
</div>
|
|
|
- <button class="ui icon right floated basic button" onclick="listVdirs();"><i class="green refresh icon"></i> Refresh</button>
|
|
|
+ <button class="ui icon right floated basic button" onclick="reloadVdirList();"><i class="green refresh icon"></i> Refresh</button>
|
|
|
<br><br>
|
|
|
<div class="ui divider"></div>
|
|
|
<div id="newVDSection" class="disabled section">
|
|
@@ -119,6 +119,7 @@
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+
|
|
|
function handleVdirAttachTargetChange(targetCheckbox=undefined){
|
|
|
if (targetCheckbox != undefined && targetCheckbox.checked){
|
|
|
$("#vdirBaseRoutingRule").parent().addClass("disabled");
|
|
@@ -138,6 +139,7 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //List the Vdir of the given endpoint, use "root" for root router
|
|
|
function loadVdirList(endpoint){
|
|
|
$("#currentVirtualDirectoryAttachingHost").html(`Editing Host: ${endpoint}`);
|
|
|
let reqURL = "/api/proxy/vdir/list?type=host&ep=" + endpoint;
|
|
@@ -166,13 +168,15 @@
|
|
|
tlsIcon = `<i class="yellow lock icon" title="TLS/SSL mode without verification"></i>`
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- $("#vdirList").append(`<tr>
|
|
|
- <td data-label="" editable="false">${vdir.MatchingPath}</td>
|
|
|
+
|
|
|
+ let payload = JSON.stringify(vdir).hexEncode();
|
|
|
+
|
|
|
+ $("#vdirList").append(`<tr vdirid="${vdir.MatchingPath.hexEncode()}" class="vdirEntry" payload="${payload}">
|
|
|
+ <td data-label="" editable="false" >${vdir.MatchingPath}</td>
|
|
|
<td data-label="" editable="true" datatype="domain">${vdir.Domain} ${tlsIcon}</td>
|
|
|
<td class="center aligned" editable="true" datatype="action" data-label="">
|
|
|
- <button class="ui circular mini basic icon button editBtn" onclick='editEndpoint("vdir","${vdir.RootOrMatchingDomain}")'><i class="edit icon"></i></button>
|
|
|
- <button class="ui circular mini red basic icon button" onclick='deleteEndpoint("vdir","${vdir.RootOrMatchingDomain}")'><i class="trash icon"></i></button>
|
|
|
+ <button class="ui circular mini basic icon button editBtn" onclick='editVdir("${vdir.MatchingPath}", "${endpoint}")'><i class="edit icon"></i></button>
|
|
|
+ <button class="ui circular mini red basic icon button" onclick='deleteVdir("${vdir.MatchingPath}", "${endpoint}")'><i class="trash icon"></i></button>
|
|
|
</td>
|
|
|
</tr>`);
|
|
|
})
|
|
@@ -181,6 +185,7 @@
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ //Check if the entered domain require TLS
|
|
|
function updateVDTargetTLSState(){
|
|
|
var targetDomain = $("#virtualDirectoryDomain").val().trim();
|
|
|
if (targetDomain != ""){
|
|
@@ -280,50 +285,100 @@
|
|
|
$("#vdSkipTLSValidation").parent().checkbox("set unchecked");
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- function listVdirs(){
|
|
|
- $.get("/api/proxy/list?type=vdir", function(data){
|
|
|
- $("#vdirList").html(``);
|
|
|
- if (data.error !== undefined){
|
|
|
- $("#vdirList").append(`<tr>
|
|
|
- <td data-label="" colspan="3"><i class="remove icon"></i> ${data.error}</td>
|
|
|
- </tr>`);
|
|
|
- }else if (data.length == 0){
|
|
|
- $("#vdirList").append(`<tr>
|
|
|
- <td data-label="" colspan="3"><i class="checkmark icon"></i> No Virtual Directory Record</td>
|
|
|
- </tr>`);
|
|
|
- }else{
|
|
|
- data.forEach(vdir => {
|
|
|
- let tlsIcon = "";
|
|
|
- let vdirData = encodeURIComponent(JSON.stringify(vdir));
|
|
|
- if (vdir.RequireTLS){
|
|
|
- tlsIcon = `<i class="green lock icon" title="TLS Mode"></i>`;
|
|
|
- if (vdir.SkipCertValidations){
|
|
|
- tlsIcon = `<i class="yellow lock icon" title="TLS/SSL mode without verification"></i>`
|
|
|
- }
|
|
|
- }
|
|
|
+ //Remove Vdir
|
|
|
+ function deleteVdir(matchingPath, endpoint){
|
|
|
+ var epType = "host";
|
|
|
+ var path = $("#vdirBaseRoutingRule").val().trim();
|
|
|
+ if (endpoint == "root"){
|
|
|
+ eptype = "root";
|
|
|
+ path = "";
|
|
|
+ }
|
|
|
|
|
|
- let tlsVerificationField = "";
|
|
|
- if (vdir.RequireTLS){
|
|
|
- tlsVerificationField = !vdir.SkipCertValidations?`<i class="ui green check icon"></i>`:`<i class="ui yellow exclamation circle icon" title="TLS/SSL Verification will be skipped on this host"></i>`
|
|
|
- }else{
|
|
|
- tlsVerificationField = "N/A"
|
|
|
- }
|
|
|
+ $.ajax({
|
|
|
+ url: "/api/proxy/vdir/del",
|
|
|
+ method: "POST",
|
|
|
+ data: {
|
|
|
+ "type":epType,
|
|
|
+ "vdir": matchingPath,
|
|
|
+ "path": path
|
|
|
+ },
|
|
|
+ success: function(data){
|
|
|
+ if (data.error != undefined){
|
|
|
+ msgbox(data.error, false);
|
|
|
+ }else{
|
|
|
+ msgbox("Virtual Directory rule removed", true);
|
|
|
+ reloadVdirList();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
- $("#vdirList").append(`<tr eptuuid="${vdir.RootOrMatchingDomain}" payload="${vdirData}" class="vdirEntry">
|
|
|
- <td data-label="" editable="false">${vdir.RootOrMatchingDomain}</td>
|
|
|
- <td data-label="" editable="true" datatype="domain">${vdir.Domain} ${tlsIcon}</td>
|
|
|
- <td data-label="" editable="true" datatype="basicauth">${vdir.RequireBasicAuth?`<i class="ui green check icon"></i>`:`<i class="ui grey remove icon"></i>`}</td>
|
|
|
- <td class="center aligned" editable="true" datatype="action" data-label="">
|
|
|
- <button class="ui circular mini basic icon button editBtn" onclick='editEndpoint("vdir","${vdir.RootOrMatchingDomain}")'><i class="edit icon"></i></button>
|
|
|
- <button class="ui circular mini red basic icon button" onclick='deleteEndpoint("vdir","${vdir.RootOrMatchingDomain}")'><i class="trash icon"></i></button>
|
|
|
- </td>
|
|
|
- </tr>`);
|
|
|
- });
|
|
|
+ function editVdir(matchingPath, ept){
|
|
|
+ let targetDOM = $(".vdirEntry[vdirid='" + matchingPath.hexEncode() + "']")
|
|
|
+ let payload = $(targetDOM).attr("payload").hexDecode();
|
|
|
+ payload = JSON.parse(payload);
|
|
|
+ console.log(payload);
|
|
|
+ $(targetDOM).find("td[editable='true']").each(function(){
|
|
|
+ let datatype = $(this).attr("datatype");
|
|
|
+ let column = $(this);
|
|
|
+
|
|
|
+ if (datatype == "domain"){
|
|
|
+ let domain = payload.Domain;
|
|
|
+ //Target require TLS for proxying
|
|
|
+ let tls = payload.RequireTLS;
|
|
|
+ if (tls){
|
|
|
+ tls = "checked";
|
|
|
+ }else{
|
|
|
+ tls = "";
|
|
|
+ }
|
|
|
+
|
|
|
+ //Require TLS validation
|
|
|
+ let skipTLSValidation = payload.SkipCertValidations;
|
|
|
+ let checkstate = "";
|
|
|
+ if (skipTLSValidation){
|
|
|
+ checkstate = "checked";
|
|
|
+ }
|
|
|
+
|
|
|
+ input = `
|
|
|
+ <div class="ui mini fluid input">
|
|
|
+ <input type="text" class="Domain" value="${domain}">
|
|
|
+ </div>
|
|
|
+ <div class="ui checkbox" style="margin-top: 0.4em;">
|
|
|
+ <input type="checkbox" class="RequireTLS" ${tls}>
|
|
|
+ <label>Require TLS<br>
|
|
|
+ <small>Proxy target require HTTPS connection</small></label>
|
|
|
+ </div><br>
|
|
|
+ <div class="ui checkbox" style="margin-top: 0.4em;">
|
|
|
+ <input type="checkbox" class="SkipCertValidations" ${checkstate}>
|
|
|
+ <label>Skip Verification<br>
|
|
|
+ <small>Check this if proxy target is using self signed certificates</small></label>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+ column.empty().append(input);
|
|
|
+ }else if (datatype == 'action'){
|
|
|
+ column.empty().append(`
|
|
|
+ <button title="Save" onclick="saveVdirInlineEdit('${payload.MatchingPath.hexEncode()}');" class="ui basic small icon circular button inlineEditActionBtn"><i class="ui green save icon"></i></button>
|
|
|
+ <button title="Cancel" onclick="exitVdirInlineEdit();" class="ui basic small icon circular button inlineEditActionBtn"><i class="ui remove icon"></i></button>
|
|
|
+ `);
|
|
|
}
|
|
|
- });
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ function saveVdirInlineEdit(mathingPath){
|
|
|
+ mathingPath = mathingPath.hexDecode();
|
|
|
+
|
|
|
+ //Load new setting from inline editor
|
|
|
+ let newDomain = $("#vdirList").find(".Domain").val();
|
|
|
+ let requireTLS = $("#vdirList").find(".RequireTLS")[0].checked;
|
|
|
+ let skipValidation = $("#vdirList").find(".SkipCertValidations")[0].checked;
|
|
|
+
|
|
|
+ console.log(mathingPath, newDomain, requireTLS, skipValidation)
|
|
|
+ }
|
|
|
+
|
|
|
+ function exitVdirInlineEdit(){
|
|
|
+ reloadVdirList();
|
|
|
}
|
|
|
- */
|
|
|
|
|
|
//Bind on tab switch events
|
|
|
tabSwitchEventBind["vdir"] = function(){
|