Skip to content

Commit 4fde60e

Browse files
committed
fix: fix the false positive result of firewall rule checking
1 parent d61c6bc commit 4fde60e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src-tauri/src/cmd/firewall.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ pub async fn check_firewall_rule(state: State<'_, AppState>) -> Result<bool, Str
9696
.port;
9797

9898
if let Some(out) = rule_stdout()? {
99-
Ok(out.contains(&port.to_string()))
99+
let rule_exists = out.contains(&format!("LocalPort: {port}"))
100+
&& out.contains("Action: Allow")
101+
&& out.contains("Protocol: TCP");
102+
Ok(rule_exists)
100103
} else {
101104
Ok(false)
102105
}

src/utils/formatters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const formatBytes = (bytes: number, decimals = 2): string => {
2-
if (bytes === 0) return '0 Bytes'
2+
if (bytes <= 0) return '0 Bytes'
33

44
const k = 1024
55
const dm = decimals < 0 ? 0 : decimals

0 commit comments

Comments
 (0)