dns: Add preferred_by rule item

This commit is contained in:
世界 2026-04-29 22:48:02 +08:00
parent e171852b19
commit fdec2fe051
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
12 changed files with 208 additions and 4 deletions

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