it is not removing the damn rule, added logging rq
This commit is contained in:
@@ -12,7 +12,9 @@ router.post('/', (req, res) => {
|
|||||||
const body = req.body || {};
|
const body = req.body || {};
|
||||||
const event = body.event || '';
|
const event = body.event || '';
|
||||||
const data = body || {};
|
const data = body || {};
|
||||||
info(`Webhook: ${event}\n${JSON.stringify(body)}`);
|
info(`Webhook: ${event}\nbody: ${JSON.stringify(body)}`);
|
||||||
|
info('headers: ' + JSON.stringify(req.headers))
|
||||||
|
return;
|
||||||
try {
|
try {
|
||||||
if (event === 'created: Allocation') {
|
if (event === 'created: Allocation') {
|
||||||
enqueueNatAdd(data.ip, data.port);
|
enqueueNatAdd(data.ip, data.port);
|
||||||
|
|||||||
@@ -72,17 +72,20 @@ export function enqueueNatRemove(ip, port, proto = 'tcp/udp') {
|
|||||||
current: 1,
|
current: 1,
|
||||||
rowCount: 1000,
|
rowCount: 1000,
|
||||||
searchPhrase: `pelican-${ip}-${port}`,
|
searchPhrase: `pelican-${ip}-${port}`,
|
||||||
})
|
});
|
||||||
|
|
||||||
const rows = result?.rows || [];
|
const rows = result?.rows || [];
|
||||||
|
|
||||||
for (const rule of rows) {
|
for (const rule of rows) {
|
||||||
|
info(rule.descr);
|
||||||
if (rule.descr === `pelican-${ip}-${port}`) {
|
if (rule.descr === `pelican-${ip}-${port}`) {
|
||||||
|
info(JSON.stringify(rule));
|
||||||
await opnsenseRequest('POST', `/api/firewall/d_nat/delRule/${rule.uuid}`);
|
await opnsenseRequest('POST', `/api/firewall/d_nat/delRule/${rule.uuid}`);
|
||||||
|
success(`deleted rule udp+tcp at ${ip}:${port}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await applyRules();
|
await applyRules();
|
||||||
success(`deleted rule udp+tcp at ${ip}:${port}`);
|
success('Successfully applied rules');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user