feat(nft): add source IP filtering for DNAT rules and expose table existence checks

This commit is contained in:
2026-03-30 14:19:44 +00:00
parent e4bb314b5f
commit 46a492443e
5 changed files with 28 additions and 2 deletions

View File

@@ -133,6 +133,22 @@ export class SmartNftables {
this.hasFilterChains = false;
}
/**
* Check if the managed nftables table exists in the kernel.
* Returns false if not root, not initialized, or the table was removed externally.
*/
public async tableExists(): Promise<boolean> {
if (!this.executor.isRoot() || !this.initialized) {
return false;
}
try {
await this.executor.exec(`nft list table ${this.family} ${this.tableName}`);
return true;
} catch {
return false;
}
}
/**
* Get status report of the managed nftables state.
*/