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

Method ContainsIPStrings

internal/iplibrary/ip_list.go:122–156  ·  view source on GitHub ↗

ContainsIPStrings 是否包含一组IP中的任意一个,并返回匹配的第一个Item

(ipStrings []string)

Source from the content-addressed store, hash-verified

120
121// ContainsIPStrings 是否包含一组IP中的任意一个,并返回匹配的第一个Item
122func (this *IPList) ContainsIPStrings(ipStrings []string) (item *IPItem, found bool) {
123 if this.isDeleted {
124 return
125 }
126
127 if len(ipStrings) == 0 {
128 return
129 }
130
131 this.mu.RLock()
132 defer this.mu.RUnlock()
133
134 if len(this.allItemsMap) > 0 {
135 for _, allItem := range this.allItemsMap {
136 item = allItem
137 break
138 }
139
140 if item != nil {
141 found = true
142 return
143 }
144 }
145 for _, ipString := range ipStrings {
146 if len(ipString) == 0 {
147 continue
148 }
149 item = this.lookupIP(iputils.ToBytes(ipString))
150 if item != nil {
151 found = true
152 return
153 }
154 }
155 return
156}
157
158func (this *IPList) SetDeleted() {
159 this.isDeleted = true

Callers 2

checkWAFRemoteAddrMethod · 0.80

Calls 3

lookupIPMethod · 0.95
RLockMethod · 0.80
RUnlockMethod · 0.80

Tested by 1