MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / Contains

Method Contains

internal/waf/values/ip_range.go:26–43  ·  view source on GitHub ↗
(netIP net.IP)

Source from the content-addressed store, hash-verified

24}
25
26func (this *IPRange) Contains(netIP net.IP) bool {
27 if netIP == nil {
28 return false
29 }
30 switch this.Type {
31 case IPRangeTypeCIDR:
32 if this.CIDR != nil {
33 return this.CIDR.Contains(netIP)
34 }
35 case IPRangeTypeSingeIP:
36 if this.IPFrom != nil {
37 return this.IPFrom.Equal(netIP)
38 }
39 case IPRangeTypeRange:
40 return bytes.Compare(this.IPFrom, netIP) <= 0 && bytes.Compare(this.IPTo, netIP) >= 0
41 }
42 return false
43}
44
45type IPRangeList struct {
46 Ranges []*IPRange

Callers 5

TestIPRange_ContainsFunction · 0.45
ParseIPRangeListFunction · 0.45
ContainsMethod · 0.45
TestParseStringListFunction · 0.45
TestParseNumberListFunction · 0.45

Calls

no outgoing calls

Tested by 3

TestIPRange_ContainsFunction · 0.36
TestParseStringListFunction · 0.36
TestParseNumberListFunction · 0.36