iwasnot
This commit is contained in:
@@ -22,10 +22,12 @@ async function opnsenseRequest(method, path, body = null) {
|
|||||||
method,
|
method,
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Basic ${auth}`,
|
'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 res = await fetch(`${process.env.OPNSENSE_HOST}${path}`, opts);
|
||||||
const text = await res.text();
|
const text = await res.text();
|
||||||
try {
|
try {
|
||||||
@@ -80,9 +82,7 @@ export function enqueueNatRemove(ip, port, proto = 'tcp/udp') {
|
|||||||
info(rule.descr);
|
info(rule.descr);
|
||||||
if (rule.descr === `pelican-${ip}-${port}`) {
|
if (rule.descr === `pelican-${ip}-${port}`) {
|
||||||
info(JSON.stringify(rule));
|
info(JSON.stringify(rule));
|
||||||
let res = await opnsenseRequest('POST', `/api/firewall/d_nat/delRule`, {
|
let res = await opnsenseRequest('POST', `/api/firewall/d_nat/delRule/${rule.uuid}`);
|
||||||
uuid: rule.uuid,
|
|
||||||
});
|
|
||||||
info(JSON.stringify(res));
|
info(JSON.stringify(res));
|
||||||
success(`deleted rule udp+tcp at ${ip}:${port}`);
|
success(`deleted rule udp+tcp at ${ip}:${port}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user