revert "skip xdroid" and refine "intranet sharing"

This commit is contained in:
mzz2017 committed 2021-09-16 15:39:29 +08:00
1 parent 01a535710e
commit ddbf487347
3 files changed
+9 -6

No files matched your search

+7
View File
@@ -5,12 +5,16 @@ package ipforward
import (
"fmt"
"github.com/v2rayA/v2rayA/db/configure"
"os/exec"
"strings"
"syscall"
)
func IsIpForwardOn() bool {
if setting := configure.GetSettingNotNil(); setting.Transparent == configure.TransparentClose {
return setting.IntranetSharing
}
out, err := syscall.Sysctl("net.inet.ip.forwarding")
return err == nil && strings.TrimSpace(out) == "1"
}
@@ -21,6 +25,9 @@ func WriteIpForward(on bool) (err error) {
err = fmt.Errorf("WriteIpForward: %w", err)
}
}()
if setting := configure.GetSettingNotNil(); setting.Transparent == configure.TransparentClose {
setting.IntranetSharing = on
}
val := "0"
if on {
val = "1"
+1 -3
View File
@@ -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 2 -d %s -j RETURN`, cidr)
commands = fmt.Sprintf(`iptables -w 2 -t nat -I V2RAY -d %s -j RETURN`, cidr)
if !strings.Contains(cidr, ".") {
//ipv6
commands = strings.Replace(commands, "iptables", "ip6tables", 1)
@@ -31,7 +31,6 @@ 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
@@ -56,7 +55,6 @@ 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
+1 -3
View File
@@ -16,7 +16,7 @@ var Tproxy tproxy
func (t *tproxy) AddIPWhitelist(cidr string) {
// avoid duplication
t.RemoveIPWhitelist(cidr)
pos := 6
pos := 5
if configure.GetSettingNotNil().AntiPollution != configure.AntipollutionClosed {
pos += 3
}
@@ -66,7 +66,6 @@ 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 {
@@ -124,7 +123,6 @@ 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 {