TUN inbound's autoSystemWfpBlockLeak: Add "allexceptlan"

"allexceptlan" is "all" but for the local network: traffic to and from
private (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, fc00::/7), link-local
(169.254.0.0/16, fe80::/10), multicast (224.0.0.0/4, ff00::/8) and broadcast
(255.255.255.255) addresses stays allowed, so that printers, the router's
settings page, or casting to a TV keep working while nothing else leaves
outside the TUN.

It includes "dns": a resolver on the local network, like the router's,
would forward the queries outside the TUN, so DNS stays blocked there. The
LAN permit sits below the other values, like the permit through the TUN, so
they still apply on the local network, e.g. "tcp/445" blocks Windows file
sharing with it. The DNS Client service keeps mDNS and LLMNR, to the local
network's addresses only. "all" overrides it.

The addresses are matched with FWP_V4_ADDR_MASK and FWP_V6_ADDR_MASK
conditions on the remote address, which match when any of them does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
patterniha
2026-11-02 11:50:18 +03:30
co-authored by Claude Opus 5.5
parent 468f745fc2
commit bb4cd4b6d3
8 changed files with 150 additions and 20 deletions
+9 -1
View File
@@ -72,7 +72,8 @@ func parseLeakTraffic(value string) (leakTraffic, bool) {
// ExpandWfpBlockLeak checks the values of autoSystemWfpBlockLeak and returns
// them in lower case, in order and without duplicates, with "dns" replaced by
// what it stands for, and ports written the same way, "tcp/0" as "tcp" say.
// what it stands for, "allexceptlan" followed by that, and ports written the
// same way, "tcp/0" as "tcp" say.
func ExpandWfpBlockLeak(values []string) ([]string, error) {
var leaks []string
add := func(leak string) {
@@ -88,6 +89,13 @@ func ExpandWfpBlockLeak(values []string) ([]string, error) {
}
case "windnsclient", "misconfigtun", "all":
add(value)
case "allexceptlan":
// The local network is no way out for DNS, which a resolver
// there, like the router, would forward outside the TUN.
add(value)
for _, leak := range dnsLeaks {
add(leak)
}
default:
traffic, ok := parseLeakTraffic(value)
if !ok {