MCPcopy
hub / github.com/shawn1m/overture / Contains

Method Contains

core/common/ipset.go:43–58  ·  view source on GitHub ↗
(ip net.IP, isLog bool, name string)

Source from the content-addressed store, hash-verified

41}
42
43func (ipSet *IPSet) Contains(ip net.IP, isLog bool, name string) bool {
44 result := false
45 if ipSet != nil {
46 if ipv4 := ip.To4(); ipv4 != nil {
47 result = ipSet.ipv4.contains(ipv4)
48 } else if ipv6 := ip.To16(); ipv6 != nil {
49 result = ipSet.ipv6.contains(ipv6)
50 }
51 if result && isLog {
52 log.Debugf("Matched: IP network %s %s", name, ip.String())
53 }
54 } else {
55 log.Debug("IP network list is nil, not checking")
56 }
57 return result
58}
59
60func toRange(ip net.IP, mask net.IPMask) *ipRange {
61 // assert len(ip) == len(mask)

Callers 9

TestIPSetFunction · 0.95
HasMethod · 0.80
parseLineMethod · 0.80
ServeDNSHttpMethod · 0.80
containsFunction · 0.80
selectByIPNetworkMethod · 0.80
getEDNSClientSubnetIPMethod · 0.80
extractUrlFunction · 0.80
isJustIPFunction · 0.80

Calls 1

containsMethod · 0.80

Tested by 2

TestIPSetFunction · 0.76
containsFunction · 0.64