mirror of
https://github.com/SagerNet/sing-box.git
synced 2026-05-13 13:57:05 +00:00
dns: Add preferred_by rule item
This commit is contained in:
parent
e171852b19
commit
fdec2fe051
12 changed files with 208 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue