mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-14 05:11:17 +08:00
40 lines
724 B
Go
40 lines
724 B
Go
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
|
|
}
|