|
@@ -4938,6 +4938,13 @@ function toggleNATActionFields() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function handleNATActionChange() {
|
|
|
|
|
+ const action = document.getElementById('nat-modal-action')?.value;
|
|
|
|
|
+ const chain = document.getElementById('nat-modal-chain');
|
|
|
|
|
+ if (action === 'dst-nat' && chain) chain.value = 'dstnat';
|
|
|
|
|
+ toggleNATActionFields();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function toggleNATLogPrefix() {
|
|
function toggleNATLogPrefix() {
|
|
|
const isLog = document.getElementById('nat-modal-log')?.checked;
|
|
const isLog = document.getElementById('nat-modal-log')?.checked;
|
|
|
toggleNATField('logprefix', !!isLog);
|
|
toggleNATField('logprefix', !!isLog);
|
|
@@ -5166,6 +5173,7 @@ async function applyNATRule(closeAfter = false) {
|
|
|
const usesAddr = ['src-nat', 'dst-nat', 'netmap'].includes(action);
|
|
const usesAddr = ['src-nat', 'dst-nat', 'netmap'].includes(action);
|
|
|
const usesPort = ['src-nat', 'dst-nat', 'redirect', 'masquerade'].includes(action);
|
|
const usesPort = ['src-nat', 'dst-nat', 'redirect', 'masquerade'].includes(action);
|
|
|
if (!chain.trim()) { switchNATRuleTab('general'); showToast('NAT rule', 'Enter a chain.', 'error'); document.getElementById('nat-modal-chain').focus(); return; }
|
|
if (!chain.trim()) { switchNATRuleTab('general'); showToast('NAT rule', 'Enter a chain.', 'error'); document.getElementById('nat-modal-chain').focus(); return; }
|
|
|
|
|
+ if (action === 'dst-nat' && chain.trim().toLowerCase() !== 'dstnat') { switchNATRuleTab('general'); showToast('NAT rule', 'The dst-nat action requires the dstnat chain.', 'error'); document.getElementById('nat-modal-chain').focus(); return; }
|
|
|
if (usesAddr && !document.getElementById('nat-modal-toaddr').value.trim()) { switchNATRuleTab('general'); showToast('NAT rule', 'Enter the destination IP / address for this action.', 'error'); document.getElementById('nat-modal-toaddr').focus(); return; }
|
|
if (usesAddr && !document.getElementById('nat-modal-toaddr').value.trim()) { switchNATRuleTab('general'); showToast('NAT rule', 'Enter the destination IP / address for this action.', 'error'); document.getElementById('nat-modal-toaddr').focus(); return; }
|
|
|
if ((sport || dport || anyport || (usesPort && document.getElementById('nat-modal-toport').value.trim())) && !['tcp', 'udp'].includes(proto)) {
|
|
if ((sport || dport || anyport || (usesPort && document.getElementById('nat-modal-toport').value.trim())) && !['tcp', 'udp'].includes(proto)) {
|
|
|
switchNATRuleTab('general'); toggleNATField('proto', true); document.getElementById('nat-val-proto').value = proto || 'all';
|
|
switchNATRuleTab('general'); toggleNATField('proto', true); document.getElementById('nat-val-proto').value = proto || 'all';
|