From ee71b5d76982387afbc2b1b243cebd5487797eea Mon Sep 17 00:00:00 2001 From: mzz2017 Date: Tue, 14 Sep 2021 23:07:46 +0800 Subject: [PATCH] fix: skip xdriod interfaces --- service/core/iptables/redirect.go | 4 +++- service/core/iptables/tproxy.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/service/core/iptables/redirect.go b/service/core/iptables/redirect.go index d2d15385..2e84f692 100644 --- a/service/core/iptables/redirect.go +++ b/service/core/iptables/redirect.go @@ -14,7 +14,7 @@ func (r *redirect) AddIPWhitelist(cidr string) { // avoid duplication r.RemoveIPWhitelist(cidr) var commands string - commands = fmt.Sprintf(`iptables -w 2 -t nat -I V2RAY -d %s -j RETURN`, cidr) + commands = fmt.Sprintf(`iptables -w 2 -t nat -I V2RAY 2 -d %s -j RETURN`, cidr) if !strings.Contains(cidr, ".") { //ipv6 commands = strings.Replace(commands, "iptables", "ip6tables", 1) @@ -31,6 +31,7 @@ func (r *redirect) RemoveIPWhitelist(cidr string) { func (r *redirect) GetSetupCommands() SetupCommands { commands := ` iptables -w 2 -t nat -N V2RAY +iptables -w 2 -t nat -A V2RAY -i xdroid+ -j RETURN iptables -w 2 -t nat -A V2RAY -d 0.0.0.0/32 -j RETURN iptables -w 2 -t nat -A V2RAY -d 10.0.0.0/8 -j RETURN iptables -w 2 -t nat -A V2RAY -d 100.64.0.0/10 -j RETURN @@ -55,6 +56,7 @@ iptables -w 2 -t nat -I OUTPUT -p tcp -j V2RAY if IsIPv6Supported() { commands += ` ip6tables -t nat -N V2RAY +ip6tables -w 2 -t nat -A V2RAY -i xdroid+ -j RETURN ip6tables -w 2 -t nat -A V2RAY -d ::/128 -j RETURN ip6tables -w 2 -t nat -A V2RAY -d ::1/128 -j RETURN ip6tables -w 2 -t nat -A V2RAY -d 64:ff9b::/96 -j RETURN diff --git a/service/core/iptables/tproxy.go b/service/core/iptables/tproxy.go index f995967b..c4cf8952 100644 --- a/service/core/iptables/tproxy.go +++ b/service/core/iptables/tproxy.go @@ -16,7 +16,7 @@ var Tproxy tproxy func (t *tproxy) AddIPWhitelist(cidr string) { // avoid duplication t.RemoveIPWhitelist(cidr) - pos := 5 + pos := 6 if configure.GetSettingNotNil().AntiPollution != configure.AntipollutionClosed { pos += 3 } @@ -66,6 +66,7 @@ iptables -w 2 -t mangle -A TP_PRE -p udp -m mark --mark 0x40/0xc0 -j TPROXY --on iptables -w 2 -t mangle -A TP_RULE -j CONNMARK --restore-mark iptables -w 2 -t mangle -A TP_RULE -m mark --mark 0x40/0xc0 -j RETURN iptables -w 2 -t mangle -A TP_RULE -i docker+ -j RETURN +iptables -w 2 -t mangle -A TP_RULE -i xdroid+ -j RETURN iptables -w 2 -t mangle -A TP_RULE -i veth+ -j RETURN ` if configure.GetSettingNotNil().AntiPollution != configure.AntipollutionClosed { @@ -123,6 +124,7 @@ ip6tables -w 2 -t mangle -A TP_PRE -p udp -m mark --mark 0x40/0xc0 -j TPROXY --o ip6tables -w 2 -t mangle -A TP_RULE -j CONNMARK --restore-mark ip6tables -w 2 -t mangle -A TP_RULE -m mark --mark 0x40/0xc0 -j RETURN ip6tables -w 2 -t mangle -A TP_RULE -i docker+ -j RETURN +ip6tables -w 2 -t mangle -A TP_RULE -i xdroid+ -j RETURN ip6tables -w 2 -t mangle -A TP_RULE -i veth+ -j RETURN ` if configure.GetSettingNotNil().AntiPollution != configure.AntipollutionClosed {