83 lines
2.8 KiB
JavaScript
83 lines
2.8 KiB
JavaScript
(() => {
|
|
'use strict';
|
|
|
|
// ===== HELPER FUNCTIONS =====
|
|
const $ = (sel, root = document) => root.querySelector(sel);
|
|
const $$ = (sel, root = document) => Array.from(root.querySelectorAll(sel));
|
|
const toggle = (on, el) => el && el.classList.toggle('d-none', !on);
|
|
|
|
// ===== SSL FIELDS =====
|
|
const sslCheckbox = $('#ssl_checkbox');
|
|
const sslFields = $('#ssl_fields');
|
|
sslCheckbox?.addEventListener('change', () => toggle(sslCheckbox.checked, sslFields));
|
|
|
|
// ===== DOS PROTECTION =====
|
|
const dosCheckbox = $('#add_dos');
|
|
const dosFields = $('#dos_fields');
|
|
dosCheckbox?.addEventListener('change', () => toggle(dosCheckbox.checked, dosFields));
|
|
|
|
// ===== PROTOCOL CHANGE (HTTP/TCP) =====
|
|
const protocolSelect = $('#protocol');
|
|
const httpGroups = $$('.http-only, #forbidden_acl_container');
|
|
const httpToggles = [
|
|
$('#sql_injection_check'),
|
|
$('#xss_check'),
|
|
$('#remote_uploads_check'),
|
|
$('#webshells_check'),
|
|
$('#forward_for_check'),
|
|
$('#add_acl_path'),
|
|
$('#add_path_based'),
|
|
$('#add_custom_acl'),
|
|
];
|
|
|
|
const forbiddenFields = $('#forbidden_fields');
|
|
const pathFields = $('#base_redirect_fields');
|
|
|
|
const onProtocolChange = () => {
|
|
const isHttp = protocolSelect?.value === 'http';
|
|
httpGroups.forEach(el => toggle(isHttp, el));
|
|
|
|
if (!isHttp) {
|
|
[forbiddenFields, pathFields].forEach(el => toggle(false, el));
|
|
httpToggles.forEach(input => {
|
|
if (input) input.checked = false;
|
|
});
|
|
}
|
|
};
|
|
|
|
protocolSelect?.addEventListener('change', onProtocolChange);
|
|
onProtocolChange();
|
|
|
|
// ===== BACKEND SSL REDIRECT =====
|
|
const backendSslCheckbox = $('#backend_ssl_redirect');
|
|
const backendSslFields = $('#backend_ssl_fields');
|
|
|
|
backendSslCheckbox?.addEventListener('change', function() {
|
|
toggle(this.checked, backendSslFields);
|
|
});
|
|
|
|
// ===== CUSTOM ACL (Main Toggle) =====
|
|
const customAclCheckbox = $('#add_custom_acl');
|
|
const customAclFields = $('#custom_acl_fields');
|
|
|
|
customAclCheckbox?.addEventListener('change', function() {
|
|
toggle(this.checked, customAclFields);
|
|
});
|
|
|
|
// ===== CUSTOM ACL Action Type Toggle =====
|
|
const customAclAction = $('#custom_acl_action');
|
|
const aclBackendSelect = $('#acl_backend_select');
|
|
const aclRedirectSelect = $('#acl_redirect_select');
|
|
|
|
const onCustomAclActionChange = () => {
|
|
const action = customAclAction?.value;
|
|
toggle(action === 'route', aclBackendSelect);
|
|
toggle(action === 'redirect', aclRedirectSelect);
|
|
};
|
|
|
|
customAclAction?.addEventListener('change', onCustomAclActionChange);
|
|
// Initial state
|
|
onCustomAclActionChange();
|
|
|
|
})();
|