mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-09-19 20:15:59 +08:00
fix: system://
should ignore dns server setting by tun listener
This commit is contained in:
39
component/resolver/system.go
Normal file
39
component/resolver/system.go
Normal file
@ -0,0 +1,39 @@
|
||||
package resolver
|
||||
|
||||
import "sync"
|
||||
|
||||
var blacklist struct {
|
||||
Map map[string]struct{}
|
||||
Mutex sync.Mutex
|
||||
}
|
||||
|
||||
func init() {
|
||||
blacklist.Map = make(map[string]struct{})
|
||||
}
|
||||
|
||||
func AddSystemDnsBlacklist(names ...string) {
|
||||
blacklist.Mutex.Lock()
|
||||
defer blacklist.Mutex.Unlock()
|
||||
for _, name := range names {
|
||||
blacklist.Map[name] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
func RemoveSystemDnsBlacklist(names ...string) {
|
||||
blacklist.Mutex.Lock()
|
||||
defer blacklist.Mutex.Unlock()
|
||||
for _, name := range names {
|
||||
delete(blacklist.Map, name)
|
||||
}
|
||||
}
|
||||
|
||||
func IsSystemDnsBlacklisted(names ...string) bool {
|
||||
blacklist.Mutex.Lock()
|
||||
defer blacklist.Mutex.Unlock()
|
||||
for _, name := range names {
|
||||
if _, ok := blacklist.Map[name]; ok {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
Reference in New Issue
Block a user