Added new UI feature

- Added toggle for uptime monitor
- Added toggle for enable custom header passthrough to websocket
This commit is contained in:
Toby Chui
2024-12-30 21:41:15 +08:00
parent 0b1768ab5b
commit 30dfb9cb65
5 changed files with 106 additions and 2 deletions

View File

@@ -258,6 +258,13 @@
if (payload.UseStickySession){
useStickySessionChecked = "checked";
}
let enableUptimeMonitor = "";
//Note the config file store the uptime monitor as disable, so we need to reverse the logic
if (!payload.DisableUptimeMonitor){
enableUptimeMonitor = "checked";
}
input = `<button class="ui basic compact tiny button" style="margin-left: 0.4em; margin-top: 1em;" onclick="editUpstreams('${uuid}');"><i class="grey server icon"></i> Edit Upstreams</button>
<div class="ui divider"></div>
<div class="ui checkbox" style="margin-top: 0.4em;">
@@ -265,7 +272,11 @@
<label>Use Sticky Session<br>
<small>Enable stick session on load balancing</small></label>
</div>
<div class="ui checkbox" style="margin-top: 0.4em;">
<input type="checkbox" class="EnableUptimeMonitor" ${enableUptimeMonitor}>
<label>Monitor Uptime<br>
<small>Enable active uptime monitor</small></label>
</div>
`;
column.append(input);
$(column).find(".upstreamList").addClass("editing");
@@ -441,6 +452,7 @@
var epttype = "host";
let useStickySession = $(row).find(".UseStickySession")[0].checked;
let DisableUptimeMonitor = !$(row).find(".EnableUptimeMonitor")[0].checked;
let authProviderType = $(row).find(".authProviderPicker input[type='radio']:checked").val();
let requireRateLimit = $(row).find(".RequireRateLimit")[0].checked;
let rateLimit = $(row).find(".RateLimit").val();
@@ -453,6 +465,7 @@
"type": epttype,
"rootname": uuid,
"ss":useStickySession,
"dutm": DisableUptimeMonitor,
"bpgtls": bypassGlobalTLS,
"authprovider" :authProviderType,
"rate" :requireRateLimit,

View File

@@ -117,6 +117,16 @@
<label>Remove Hop-by-hop Header<br>
<small>This should be ON by default</small></label>
</div>
<div class="ui divider"></div>
<h4> WebSocket Custom Headers</h4>
<p>Copy custom headers from HTTP requests to WebSocket connections.
Might be required by some projects like MeshCentral.</p>
<div class="ui toggle checkbox">
<input type="checkbox" id="copyCustomHeadersWS" name="">
<label>Enable WebSocket Custom Header<br>
<small>This should be OFF by default</small></label>
</div>
<div class="ui yellow message">
<p><i class="exclamation triangle icon"></i>Settings in this section are for advanced users. Invalid settings might cause werid, unexpected behavior.</p>
</div>
@@ -597,6 +607,7 @@
})
}
/* Manual Hostname overwrite */
function initManualHostOverwriteValue(){
$.get("/api/proxy/header/handleHostOverwrite?domain=" + editingEndpoint.ep, function(data){
if (data.error != undefined){
@@ -643,6 +654,42 @@
})
}
initHopByHopRemoverState();
/* WebSocket Custom Headers */
function initWebSocketCustomHeaderState(){
$.get("/api/proxy/header/handleWsHeaderBehavior?domain=" + editingEndpoint.ep, function(data){
if (data.error != undefined){
parent.msgbox(data.error);
}else{
if (data == true){
$("#copyCustomHeadersWS").parent().checkbox("set checked");
}else{
$("#copyCustomHeadersWS").parent().checkbox("set unchecked");
}
//Bind event to the checkbox
$("#copyCustomHeadersWS").on("change", function(evt){
let isChecked = $(this)[0].checked;
$.cjax({
url: "/api/proxy/header/handleWsHeaderBehavior",
method: "POST",
data: {
"domain": editingEndpoint.ep,
"enable": isChecked,
},
success: function(data){
if (data.error != undefined){
parent.msgbox(data.error, false);
}else{
parent.msgbox("WebSocket Custom Header rule updated");
}
}
})
})
}
})
}
initWebSocketCustomHeaderState();
</script>
</body>
</html>