Fix firewall rule issues, enhance security, and improve proxy handling#1897
Merged
Conversation
- Fix RemoveIPWhitelist table target from mangle to nat in redirect.go - Fix IsEnabledTproxyWhiteIpGroups() logical operator from && to || in utils.go - Add whitelist group support for Redirect mode in redirect.go - Fix data race in LocalIPWatcher by adding sync.Mutex in watcher.go - Clean up conntrack entries with mark 0x40 on TPROXY teardown in tproxy.go - Preserve and restore original system proxy state on all platforms (macOS, Windows, Linux) - Uncomment FakeDNS bypass rules (198.18.0.0/15, fc00::/7) in redirect.go - Add startup cleanup for residual iptables/nftables rules in transparent.go
…esolution core: fix geosite.dat parsing in DNS resolver - Replace broken GeoSiteList unmarshal with correct varint-length-delimited stream parser matching xray-core's format - Add result caching to avoid re-reading the file per tag expansion service: persist kernel exit status for proper state restoration - Add LastKernelExitStatus (running/stopped/crashed) to DB - Set 'running' on graceful shutdown while kernel is active so it is automatically restored on next startup - Set 'stopped' when user explicitly stops the kernel via API - Set 'crashed' when the kernel exits unexpectedly - Check saved status at startup and log appropriate messages - Expose lastKernelExit field via GET /api/version for the frontend
…ables sets
Two fixes for the redirect/tproxy interface exclusion feature:
1. Add missing -o/oifname rules for the OUTPUT path
- The TP_RULE chain is jumped from both PREROUTING (tp_pre) and
OUTPUT (tp_out). The existing -i/iifname rules only match the
PREROUTING path correctly (packets arriving on a given interface).
- For the OUTPUT path (locally-originated traffic), the input
interface is always 'lo', so -i never matches the excluded
interface. Add corresponding -o/oifname rules so that locally-
originated traffic going out through an excluded interface is
also bypassed (RETURN before the final REDIRECT/TPROXY action).
- Applies to both redirect and tproxy modes, legacy iptables and
nftables implementations, for both IPv4 and IPv6.
2. Rename nftables set 'interface'/'interface6' to 'local_ips'/'local_ips6'
- These sets store IPv4/IPv6 addresses of local interfaces,
dynamically maintained by the LocalIPWatcher to prevent proxy
loops (traffic destined to local IPs returns early).
- The old name 'interface' was misleading: it suggested it stores
interface names, but the type is ipv4_addr/ipv6_addr.
- The rename affects nftRedirect and nftTproxy, including the
set definitions, chain references (ip daddr @local_ips), and
AddIPWhitelist/RemoveIPWhitelist nft command strings.
k.GetIntegerValue() returns uint64 on Windows, but proxyEnable was
declared as uint32. Add explicit uint32() conversion to fix the
cross-compilation error:
cannot use k.GetIntegerValue("ProxyEnable") (value of type uint64)
as uint32 value in assignment
syscall.SetsockoptInt takes int (Linux) vs syscall.Handle (Windows) as its first argument. The existing code used int(fd) which fails on Windows where fd is uintptr and syscall.Handle = uintptr. Fix: extract a platform-specific setSocketMark(fd uintptr) helper: - socket_unix.go (!windows) : calls SetsockoptInt(int(fd), ...) - socket_windows.go (windows): no-op (SO_MARK is Linux-only)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.