Fix nftables parser to use input_wan chain
All checks were successful
Build and Release / build-and-release (push) Successful in 1m27s
All checks were successful
Build and Release / build-and-release (push) Successful in 1m27s
Change nftables port parser to specifically look for 'chain input_wan' instead of any chain with 'input' in the name. This ensures we only collect WAN/external ports, not LAN or other internal chains. - Look for 'chain input_wan' specifically - Remove internal network filters (no longer needed) - Update version to v0.1.249
This commit is contained in:
@@ -933,26 +933,26 @@ impl SystemdCollector {
|
||||
|
||||
// Parse nftables output for WAN incoming accept rules with dport
|
||||
// Looking for patterns like: tcp dport 22 accept or tcp dport { 22, 80, 443 } accept
|
||||
// Only include rules in input chain without private network source restrictions
|
||||
let mut in_input_chain = false;
|
||||
// Only include rules in input_wan chain
|
||||
let mut in_wan_chain = false;
|
||||
|
||||
for line in output_str.lines() {
|
||||
let line = line.trim();
|
||||
|
||||
// Track if we're in the input chain
|
||||
if line.contains("chain input") || line.contains("chain INPUT") {
|
||||
in_input_chain = true;
|
||||
// Track if we're in the input_wan chain
|
||||
if line.contains("chain input_wan") {
|
||||
in_wan_chain = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Reset when entering other chains
|
||||
if line.starts_with("chain ") && !line.contains("input") && !line.contains("INPUT") {
|
||||
in_input_chain = false;
|
||||
if line.starts_with("chain ") && !line.contains("input_wan") {
|
||||
in_wan_chain = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Only process rules in input chain
|
||||
if !in_input_chain {
|
||||
// Only process rules in input_wan chain
|
||||
if !in_wan_chain {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -961,14 +961,6 @@ impl SystemdCollector {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip internal network traffic (LAN/private networks)
|
||||
if line.contains("ip saddr 192.168.") ||
|
||||
line.contains("ip saddr 10.") ||
|
||||
line.contains("ip saddr 172.16.") ||
|
||||
line.contains("iifname \"lo\"") {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Parse TCP ports
|
||||
if line.contains("tcp dport") {
|
||||
for port in self.extract_ports_from_nft_rule(line) {
|
||||
|
||||
Reference in New Issue
Block a user