默认使用 passthrough resolver close #75
Co-authored-by: NewbieOrange <7200314+NewbieOrange@users.noreply.github.com>
This commit is contained in:
parent
404260187c
commit
765f7d9c34
@ -29,6 +29,7 @@ import (
|
|||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
"google.golang.org/grpc/credentials/insecure"
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
|
"google.golang.org/grpc/resolver"
|
||||||
|
|
||||||
"github.com/nezhahq/agent/model"
|
"github.com/nezhahq/agent/model"
|
||||||
fm "github.com/nezhahq/agent/pkg/fm"
|
fm "github.com/nezhahq/agent/pkg/fm"
|
||||||
@ -63,7 +64,7 @@ var (
|
|||||||
arch string
|
arch string
|
||||||
client pb.NezhaServiceClient
|
client pb.NezhaServiceClient
|
||||||
initialized bool
|
initialized bool
|
||||||
resolver = &net.Resolver{PreferGo: true}
|
dnsResolver = &net.Resolver{PreferGo: true}
|
||||||
)
|
)
|
||||||
|
|
||||||
var agentCmd = &cobra.Command{
|
var agentCmd = &cobra.Command{
|
||||||
@ -99,6 +100,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
resolver.SetDefaultScheme("passthrough")
|
||||||
net.DefaultResolver.PreferGo = true // 使用 Go 内置的 DNS 解析器解析域名
|
net.DefaultResolver.PreferGo = true // 使用 Go 内置的 DNS 解析器解析域名
|
||||||
net.DefaultResolver.Dial = func(ctx context.Context, network, address string) (net.Conn, error) {
|
net.DefaultResolver.Dial = func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||||
d := net.Dialer{
|
d := net.Dialer{
|
||||||
@ -862,7 +864,7 @@ func generateQueue(start int, size int) []int {
|
|||||||
|
|
||||||
func lookupIP(hostOrIp string) (string, error) {
|
func lookupIP(hostOrIp string) (string, error) {
|
||||||
if net.ParseIP(hostOrIp) == nil {
|
if net.ParseIP(hostOrIp) == nil {
|
||||||
ips, err := resolver.LookupIPAddr(context.Background(), hostOrIp)
|
ips, err := dnsResolver.LookupIPAddr(context.Background(), hostOrIp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user