fix: v2ray dns usage

This commit is contained in:
arm64v8a
2023-01-13 16:53:48 +09:00
parent 41096c25a7
commit 876c626a70
2 changed files with 11 additions and 1 deletions

View File

@@ -275,6 +275,7 @@ namespace NekoRay {
} }
dnsServers += QJsonObject{ dnsServers += QJsonObject{
{"address", directDnsAddress}, {"address", directDnsAddress},
{"fallbackStrategy", "disabled"},
{"domains", QList2QJsonArray<QString>(status->domainListDNSDirect)}, {"domains", QList2QJsonArray<QString>(status->domainListDNSDirect)},
}; };

View File

@@ -10,7 +10,9 @@ import (
"net/http" "net/http"
"time" "time"
"github.com/sirupsen/logrus"
v2rayNet "github.com/v2fly/v2ray-core/v5/common/net" v2rayNet "github.com/v2fly/v2ray-core/v5/common/net"
"github.com/v2fly/v2ray-core/v5/features/dns"
"github.com/v2fly/v2ray-core/v5/features/dns/localdns" "github.com/v2fly/v2ray-core/v5/features/dns/localdns"
) )
@@ -25,7 +27,14 @@ func setupCore() {
// localdns setup // localdns setup
resolver_def := &net.Resolver{PreferGo: false} resolver_def := &net.Resolver{PreferGo: false}
resolver_go := &net.Resolver{PreferGo: true} resolver_go := &net.Resolver{PreferGo: true}
localdns.SetLookupFunc(func(network string, host string) ([]net.IP, error) { localdns.SetLookupFunc(func(network string, host string) (ips []net.IP, err error) {
// fix old sekai
defer func() {
if len(ips) == 0 {
logrus.Println("LookupIP error:", err)
err = dns.ErrEmptyResponse
}
}()
// Normal mode use system resolver (go bug) // Normal mode use system resolver (go bug)
if getNekorayTunIndex() == 0 { if getNekorayTunIndex() == 0 {
return resolver_def.LookupIP(context.Background(), network, host) return resolver_def.LookupIP(context.Background(), network, host)