Skip to content

Commit

Permalink
fix: v2ray dns usage
Browse files Browse the repository at this point in the history
  • Loading branch information
arm64v8a committed Jan 13, 2023
1 parent 41096c2 commit 876c626
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions db/ConfigBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ namespace NekoRay {
}
dnsServers += QJsonObject{
{"address", directDnsAddress},
{"fallbackStrategy", "disabled"},
{"domains", QList2QJsonArray<QString>(status->domainListDNSDirect)},
};

Expand Down
11 changes: 10 additions & 1 deletion go/cmd/nekoray_core/core_ray.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (
"net/http"
"time"

"github.com/sirupsen/logrus"
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"
)

Expand All @@ -25,7 +27,14 @@ func setupCore() {
// localdns setup
resolver_def := &net.Resolver{PreferGo: false}
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)
if getNekorayTunIndex() == 0 {
return resolver_def.LookupIP(context.Background(), network, host)
Expand Down

0 comments on commit 876c626

Please sign in to comment.