Fix DNS route suffix matching

This commit is contained in:
世界
2026-07-19 17:09:35 +08:00
parent 3d2461f3ba
commit 77d9c07d2f
2 changed files with 4 additions and 5 deletions
+2 -2
View File
@@ -267,7 +267,7 @@ func (t *DNSTransport) PreferredDomain(domain string) bool {
return true
}
for suffix := range routes {
if strings.HasSuffix(domain, suffix) {
if mDNS.IsSubDomain(suffix, domain) {
return true
}
}
@@ -377,7 +377,7 @@ func (t *DNSTransport) exchangeOnce(ctx context.Context, message *mDNS.Msg, allo
}
}
for domainSuffix, transports := range routes {
if strings.HasSuffix(question.Name, domainSuffix) {
if mDNS.IsSubDomain(domainSuffix, question.Name) {
if len(transports) == 0 {
callback(&mDNS.Msg{
MsgHdr: mDNS.MsgHdr{
+2 -3
View File
@@ -6,7 +6,6 @@ import (
"context"
"net/netip"
"os"
"strings"
"sync"
"sync/atomic"
"time"
@@ -202,7 +201,7 @@ func (t *Transport) PreferredDomain(domain string) bool {
if linkDomain.Domain == "." {
continue
}
if strings.HasSuffix(domain, linkDomain.Domain) {
if mDNS.IsSubDomain(linkDomain.Domain, domain) {
return true
}
}
@@ -234,7 +233,7 @@ func (t *Transport) ExchangeAsync(ctx context.Context, message *mDNS.Msg, callba
if domain.Domain == "." && domain.RoutingOnly && !t.acceptDefaultResolvers {
continue
}
if strings.HasSuffix(question.Name, domain.Domain) {
if mDNS.IsSubDomain(domain.Domain, question.Name) {
selectedLink = link
}
}