mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 20:44:38 +03:00
fix: v2ray dns usage
This commit is contained in:
@@ -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)},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user