mirror of
https://github.com/v2rayA/v2rayA.git
synced 2026-11-20 23:02:25 +03:00
fix: duplicated dns-in problem and more accurate ipv6 support detecting
This commit is contained in:
1 parent
72b0baf963
commit
6a4391f266
2 files changed
+11
-6
No files matched your search
@@ -4,10 +4,9 @@ import (
|
||||
"github.com/v2rayA/v2rayA/common"
|
||||
"github.com/v2rayA/v2rayA/common/cmds"
|
||||
"github.com/v2rayA/v2rayA/global"
|
||||
"golang.org/x/net/nettest"
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func IPNet2CIDR(ipnet *net.IPNet) string {
|
||||
@@ -36,10 +35,7 @@ func IsIPv6Supported() bool {
|
||||
if common.IsInDocker() {
|
||||
return false
|
||||
}
|
||||
if b, err := os.ReadFile("/proc/sys/net/ipv6/conf/default/disable_ipv6"); err != nil || strings.TrimSpace(string(b)) == "1" {
|
||||
return false
|
||||
}
|
||||
if b, err := os.ReadFile("/proc/sys/net/ipv6/conf/all/disable_ipv6"); err != nil || strings.TrimSpace(string(b)) == "1" {
|
||||
if !nettest.SupportsIPv6() {
|
||||
return false
|
||||
}
|
||||
return cmds.IsCommandValid("ip6tables")
|
||||
|
||||
@@ -1300,6 +1300,7 @@ func (t *Template) SetDualStack(setting *configure.Setting) {
|
||||
for i := range t.Inbounds {
|
||||
if t.Inbounds[i].Tag == "dns-in" {
|
||||
t.Inbounds[i].Listen = "127.2.0.17"
|
||||
inbounds6[i].Tag = "THIS_IS_A_DROPPED_TAG"
|
||||
continue
|
||||
} else {
|
||||
t.Inbounds[i].Listen = "127.0.0.1"
|
||||
@@ -1311,6 +1312,14 @@ func (t *Template) SetDualStack(setting *configure.Setting) {
|
||||
inbounds6[i].Tag += tag6Suffix
|
||||
}
|
||||
}
|
||||
if !iptables.IsIPv6Supported() {
|
||||
return
|
||||
}
|
||||
for i := len(inbounds6) - 1; i >= 0; i-- {
|
||||
if inbounds6[i].Tag == "THIS_IS_A_DROPPED_TAG" {
|
||||
inbounds6 = append(inbounds6[:i], inbounds6[i+1:]...)
|
||||
}
|
||||
}
|
||||
t.Inbounds = append(t.Inbounds, inbounds6...)
|
||||
|
||||
// set routing
|
||||
|
||||
Reference in new issue
Block a user