Fix DNS route suffix matching

This commit is contained in:
世界
2026-07-27 10:41:51 +08:00
parent 1f1d6d9a87
commit 513910462e
2 changed files with 2 additions and 3 deletions

View File

@@ -283,7 +283,7 @@ func (t *DNSTransport) Exchange(ctx context.Context, message *mDNS.Msg) (*mDNS.M
} }
} }
for domainSuffix, transports := range routes { for domainSuffix, transports := range routes {
if strings.HasSuffix(question.Name, domainSuffix) { if mDNS.IsSubDomain(domainSuffix, question.Name) {
if len(transports) == 0 { if len(transports) == 0 {
return &mDNS.Msg{ return &mDNS.Msg{
MsgHdr: mDNS.MsgHdr{ MsgHdr: mDNS.MsgHdr{

View File

@@ -6,7 +6,6 @@ import (
"context" "context"
"net/netip" "net/netip"
"os" "os"
"strings"
"sync" "sync"
"sync/atomic" "sync/atomic"
"time" "time"
@@ -200,7 +199,7 @@ func (t *Transport) Exchange(ctx context.Context, message *mDNS.Msg) (*mDNS.Msg,
if domain.Domain == "." && domain.RoutingOnly && !t.acceptDefaultResolvers { if domain.Domain == "." && domain.RoutingOnly && !t.acceptDefaultResolvers {
continue continue
} }
if strings.HasSuffix(question.Name, domain.Domain) { if mDNS.IsSubDomain(domain.Domain, question.Name) {
selectedLink = link selectedLink = link
} }
} }