You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
v2ray-core/app/dns/json/config.go

36 lines
658 B

9 years ago
package json
import (
"strings"
serialjson "github.com/v2ray/v2ray-core/common/serial/json"
)
type TagList map[string]bool
func NewTagList(tags []string) TagList {
list := TagList(make(map[string]bool))
for _, tag := range tags {
list[strings.TrimSpace(tag)] = true
}
return list
}
func (this *TagList) UnmarshalJSON(data []byte) error {
tags, err := serialjson.UnmarshalStringList(data)
if err != nil {
return err
}
*this = NewTagList(tags)
return nil
}
type CacheConfig struct {
TrustedTags TagList `json:"trustedTags"`
}
func (this *CacheConfig) IsTrustedSource(tag string) bool {
_, found := this.TrustedTags[tag]
return found
}