This commit is contained in:
2026-03-23 17:46:12 +02:00
parent fd63d1e697
commit b309bd3649

View File

@@ -22,10 +22,12 @@ async function opnsenseRequest(method, path, body = null) {
method,
headers: {
'Authorization': `Basic ${auth}`,
'Content-Type': 'application/json',
},
};
if (body) opts.body = JSON.stringify(body);
if (body) {
opts.headers['Content-Type'] = 'application/json';
opts.body = JSON.stringify(body);
}
const res = await fetch(`${process.env.OPNSENSE_HOST}${path}`, opts);
const text = await res.text();
try {
@@ -80,9 +82,7 @@ export function enqueueNatRemove(ip, port, proto = 'tcp/udp') {
info(rule.descr);
if (rule.descr === `pelican-${ip}-${port}`) {
info(JSON.stringify(rule));
let res = await opnsenseRequest('POST', `/api/firewall/d_nat/delRule`, {
uuid: rule.uuid,
});
let res = await opnsenseRequest('POST', `/api/firewall/d_nat/delRule/${rule.uuid}`);
info(JSON.stringify(res));
success(`deleted rule udp+tcp at ${ip}:${port}`);
}