dns: Add preferred_by rule item

This commit is contained in:
世界
2026-04-29 22:48:02 +08:00
parent a81ca0f5c5
commit 7c722b3d50
12 changed files with 208 additions and 4 deletions
+16
View File
@@ -255,6 +255,22 @@ func (t *DNSTransport) Raw() bool {
return true
}
func (t *DNSTransport) PreferredDomain(domain string) bool {
t.access.RLock()
hosts := t.hosts
routes := t.routes
t.access.RUnlock()
if _, loaded := hosts[domain]; loaded {
return true
}
for suffix := range routes {
if strings.HasSuffix(domain, suffix) {
return true
}
}
return false
}
func (t *DNSTransport) Exchange(ctx context.Context, message *mDNS.Msg) (*mDNS.Msg, error) {
if len(message.Question) != 1 {
return nil, os.ErrInvalid