github.com/metacubex/mihomo@v1.18.5/component/resolver/system.go (about)

     1  package resolver
     2  
     3  import "sync"
     4  
     5  var blacklist struct {
     6  	Map   map[string]struct{}
     7  	Mutex sync.Mutex
     8  }
     9  
    10  func init() {
    11  	blacklist.Map = make(map[string]struct{})
    12  }
    13  
    14  func AddSystemDnsBlacklist(names ...string) {
    15  	blacklist.Mutex.Lock()
    16  	defer blacklist.Mutex.Unlock()
    17  	for _, name := range names {
    18  		blacklist.Map[name] = struct{}{}
    19  	}
    20  }
    21  
    22  func RemoveSystemDnsBlacklist(names ...string) {
    23  	blacklist.Mutex.Lock()
    24  	defer blacklist.Mutex.Unlock()
    25  	for _, name := range names {
    26  		delete(blacklist.Map, name)
    27  	}
    28  }
    29  
    30  func IsSystemDnsBlacklisted(names ...string) bool {
    31  	blacklist.Mutex.Lock()
    32  	defer blacklist.Mutex.Unlock()
    33  	for _, name := range names {
    34  		if _, ok := blacklist.Map[name]; ok {
    35  			return true
    36  		}
    37  	}
    38  	return false
    39  }