IT HAS TCP/UDP OPTIONS
This commit is contained in:
@@ -40,36 +40,21 @@ async function applyRules() {
|
||||
await opnsenseRequest('POST', '/api/firewall/d_nat/apply');
|
||||
}
|
||||
|
||||
export function enqueueNatAdd(ip, port, proto = 'tcp') {
|
||||
export function enqueueNatAdd(ip, port, proto = 'tcp/udp') {
|
||||
enqueue(async () => {
|
||||
info(`adding rule udp+tcp at ${ip}:${port}`);
|
||||
|
||||
await opnsenseRequest('POST', '/api/firewall/d_nat/addRule', {
|
||||
rule: {
|
||||
interface: 'wan',
|
||||
protocol: 'tcp',
|
||||
protocol: 'tcp/udp',
|
||||
destination: {
|
||||
network: 'wanip',
|
||||
port: `${port}`,
|
||||
},
|
||||
target: ip,
|
||||
'local-port': `${port}`,
|
||||
descr: `pelican-${ip}-${port}-tcp`,
|
||||
disabled: '0',
|
||||
}
|
||||
});
|
||||
|
||||
await opnsenseRequest('POST', '/api/firewall/d_nat/addRule', {
|
||||
rule: {
|
||||
interface: 'wan',
|
||||
protocol: 'udp',
|
||||
destination: {
|
||||
network: 'wanip',
|
||||
port: `${port}`,
|
||||
},
|
||||
target: ip,
|
||||
'local-port': `${port}`,
|
||||
descr: `pelican-${ip}-${port}-udp`,
|
||||
descr: `pelican-${ip}-${port}`,
|
||||
disabled: '0',
|
||||
}
|
||||
});
|
||||
@@ -79,7 +64,7 @@ export function enqueueNatAdd(ip, port, proto = 'tcp') {
|
||||
});
|
||||
}
|
||||
|
||||
export function enqueueNatRemove(ip, port, proto = 'tcp') {
|
||||
export function enqueueNatRemove(ip, port, proto = 'tcp/udp') {
|
||||
enqueue(async () => {
|
||||
info(`deleting rule udp+tcp at ${ip}:${port}`);
|
||||
|
||||
@@ -92,10 +77,7 @@ export function enqueueNatRemove(ip, port, proto = 'tcp') {
|
||||
const rows = result?.rows || [];
|
||||
|
||||
for (const rule of rows) {
|
||||
if (
|
||||
rule.descr === `pelican-${ip}-${port}-udp` ||
|
||||
rule.descr === `pelican-${ip}-${port}-tcp`
|
||||
) {
|
||||
if (rule.descr === `pelican-${ip}-${port}`) {
|
||||
await opnsenseRequest('POST', `/api/firewall/d_nat/delRule/${rule.uuid}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user