From c19c6afc765bf9084607b5d660564080d6431174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 26 Feb 2025 07:13:18 +0800 Subject: [PATCH] Fix DNS fallback --- dns/transport/local/local.go | 3 +++ dns/transport/local/local_fallback.go | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dns/transport/local/local.go b/dns/transport/local/local.go index e4236275..4e05ff02 100644 --- a/dns/transport/local/local.go +++ b/dns/transport/local/local.go @@ -139,6 +139,9 @@ func (t *Transport) tryOneName(ctx context.Context, config *dnsConfig, fqdn stri } func (t *Transport) exchangeOne(ctx context.Context, server M.Socksaddr, question mDNS.Question, timeout time.Duration, useTCP, ad bool) (*mDNS.Msg, error) { + if server.Port == 0 { + server.Port = 53 + } var networks []string if useTCP { networks = []string{N.NetworkTCP} diff --git a/dns/transport/local/local_fallback.go b/dns/transport/local/local_fallback.go index 0a7cd9f0..cd2d198f 100644 --- a/dns/transport/local/local_fallback.go +++ b/dns/transport/local/local_fallback.go @@ -58,8 +58,12 @@ func (f *FallbackTransport) Start(stage adapter.StartStage) error { return nil } +func (f *FallbackTransport) Close() error { + return nil +} + func (f *FallbackTransport) Exchange(ctx context.Context, message *mDNS.Msg) (*mDNS.Msg, error) { - if f.fallback { + if !f.fallback { return f.DNSTransport.Exchange(ctx, message) } question := message.Question[0]