github.com/yaling888/clash@v1.53.0/dns/policy.go (about) 1 package dns 2 3 import "reflect" 4 5 type Policy struct { 6 data []dnsClient 7 } 8 9 func (p *Policy) GetData() []dnsClient { 10 return p.data 11 } 12 13 func (p *Policy) Compare(p2 *Policy) int { 14 if p == nil && p2 == nil { 15 return 0 16 } 17 if p == nil || p2 == nil { 18 return 1 19 } 20 if reflect.DeepEqual(p.data, p2.data) { 21 return 0 22 } 23 if len(p.data) > len(p2.data) { 24 return 1 25 } 26 return -1 27 } 28 29 func NewPolicy(data []dnsClient) *Policy { 30 return &Policy{ 31 data: data, 32 } 33 }