mirror of
https://github.com/v2rayA/v2rayA.git
synced 2026-11-20 23:02:25 +03:00
fix(transparent): restore the redirect ingress wildcard, trim whitelist IPs, keep DNS readiness advisory
Three regressions from the previous transparent-proxy commit: - the redirect ingress rules lost the "*" to "+" translation, so an excluded interface pattern such as docker* stopped matching and Docker traffic was redirected; the egress rules and both tproxy directions still translated it; - the whitelist now parses its entries, and the GUI submits the textarea lines as typed, so a pasted CIDR with surrounding whitespace aborted the whole setup where the shell used to swallow it; - the DNS readiness probe resolves a name, so a dead or slow upstream failed it even with the listener up, and the core could no longer start at all. The probe is now advisory: it still waits when DNS is healthy, but a failure is logged instead of aborting the start.
This commit is contained in:
3 files changed
+14
-4
No files matched your search
@@ -85,7 +85,7 @@ iptables -w 2 -t nat -A DNS_REDIRECT -p tcp -j REDIRECT --to-port 52353
|
||||
iptables -w 2 -t nat -A DNS_REDIRECT -p udp -j REDIRECT --to-port 52353
|
||||
`
|
||||
for _, v := range excludedInterfaces {
|
||||
commands += fmt.Sprintf("iptables -w 2 -t nat -A TP_RULE -i %s -j RETURN\n", v)
|
||||
commands += fmt.Sprintf("iptables -w 2 -t nat -A TP_RULE -i %s -j RETURN\n", strings.ReplaceAll(v, "*", "+"))
|
||||
}
|
||||
// OUTPUT 路径使用 -o 匹配输出网卡(本地流量在 OUTPUT 链中 -i 始终为 lo)
|
||||
for _, v := range excludedInterfaces {
|
||||
@@ -135,7 +135,7 @@ ip6tables -w 2 -t nat -A TP_RULE -d ff00::/8 -j RETURN
|
||||
ip6tables -w 2 -t nat -A TP_RULE -m mark --mark 0x80/0x80 -j RETURN
|
||||
`
|
||||
for _, v := range excludedInterfaces {
|
||||
commands += fmt.Sprintf("ip6tables -w 2 -t nat -A TP_RULE -i %s -j RETURN\n", v)
|
||||
commands += fmt.Sprintf("ip6tables -w 2 -t nat -A TP_RULE -i %s -j RETURN\n", strings.ReplaceAll(v, "*", "+"))
|
||||
}
|
||||
// IPv6 OUTPUT 路径使用 -o 匹配输出网卡
|
||||
for _, v := range excludedInterfaces {
|
||||
|
||||
@@ -105,6 +105,12 @@ func GetWhiteListIPs() ([]string, []string, error) {
|
||||
ipv6List = append(ipv6List, ipv6s...)
|
||||
}
|
||||
for _, v := range dataModal.CustomIps {
|
||||
// The GUI submits the textarea lines as typed, so a pasted CIDR can
|
||||
// carry surrounding whitespace that net.ParseCIDR does not accept.
|
||||
v = strings.TrimSpace(v)
|
||||
if v == "" {
|
||||
continue
|
||||
}
|
||||
if net.ParseIP(v) == nil {
|
||||
if _, _, err := net.ParseCIDR(v); err != nil {
|
||||
return nil, nil, fmt.Errorf("invalid tproxy whitelist IP/CIDR %q", v)
|
||||
|
||||
@@ -155,9 +155,13 @@ func writeTransparentProxyRules(tmpl *Template) (err error) {
|
||||
dnsAddr = tmpl.Setting.DnsListenAddr
|
||||
}
|
||||
if err := waitForDnsPort(dnsAddr, 5*time.Second); err != nil {
|
||||
return fmt.Errorf("dns module not ready: %w", err)
|
||||
// The probe resolves a name, so a dead or slow upstream fails it
|
||||
// even though the listener is up. Waiting is worth it when DNS is
|
||||
// healthy, but it must not be the reason the core cannot start.
|
||||
log.Warn("DNS module did not answer on %s yet, applying transparent proxy rules anyway: %v", dnsAddr, err)
|
||||
} else {
|
||||
log.Trace("DNS module is ready on %s, setting up transparent proxy rules", dnsAddr)
|
||||
}
|
||||
log.Trace("DNS module is ready on %s, setting up transparent proxy rules", dnsAddr)
|
||||
}
|
||||
cleanupResidualTransparentProxyRules()
|
||||
setting := configure.GetSettingNotNil()
|
||||
|
||||
Reference in new issue
Block a user