zoraxy-waf/web/app.js
cclohmar 16761613bb fix: redirect preservation, health check, Content-Length, UI simplification
- health.go: treat any HTTP response as reachable (only connection errors fail)
- main.go: CheckRedirect in handleReturn to preserve 302 + Set-Cookie
- middleware.go: Content-Length for POST/PUT/PATCH bodies, CheckRedirect
  in forwardToWAF and forwardToReturn
- web/: replace stats panel with 3-state WAF indicator (DISABLED/ENABLED/FAILED)
- README: update defaults, architecture, health check docs
- .agents.md: update verified status for Wallarm integration
2026-08-08 14:53:12 +00:00

65 lines
1.9 KiB
JavaScript

// Firewall — config panel
function loadConfig() {
$.get('./api/config', function (data) {
$('#fw-enabled').prop('checked', data.enabled);
$('#enabled-label').text(data.enabled ? 'Firewall Enabled' : 'Firewall Disabled');
$('#waf-url').val(data.waf_url);
$('#return-port').val(data.return_port);
$('#health-interval').val(data.health_interval);
$('#timeout-ms').val(data.timeout_ms);
});
}
function loadStatus() {
$.get('./api/stats', function (data) {
var state, text, cls;
if (!data.enabled) {
state = 'DISABLED'; text = 'Disabled'; cls = 'off';
} else if (data.circuit === 'open') {
state = 'FAILED'; text = 'Failed — WAF unreachable'; cls = 'warn';
} else {
state = 'ENABLED'; text = 'Enabled — WAF protecting'; cls = 'ok';
}
$('#waf-indicator')
.attr('data-state', state)
.find('.status-text').text(text).end()
.find('.status-dot').attr('class', 'status-dot ' + cls);
});
}
function saveConfig() {
$('#save-status').text('Saving...');
$.cjax({
url: './api/config/save',
type: 'POST',
data: {
enabled: $('#fw-enabled').is(':checked'),
waf_url: $('#waf-url').val().trim(),
return_port: $('#return-port').val(),
health_interval: $('#health-interval').val(),
timeout_ms: $('#timeout-ms').val()
},
success: function () {
$('#save-status').text('Saved ✓');
loadConfig();
loadStatus();
setTimeout(function () { $('#save-status').text(''); }, 2000);
},
error: function () {
$('#save-status').css('color', '#d63031').text('Save failed');
}
});
}
$('#fw-enabled').on('change', function () {
$('#enabled-label').text(this.checked ? 'Firewall Enabled' : 'Firewall Disabled');
});
$('#save-btn').on('click', saveConfig);
$(document).ready(function () {
loadConfig();
loadStatus();
setInterval(loadStatus, 10000);
});