ContainsIPStrings 是否包含一组IP中的任意一个,并返回匹配的第一个Item
(ipStrings []string)
| 120 | |
| 121 | // ContainsIPStrings 是否包含一组IP中的任意一个,并返回匹配的第一个Item |
| 122 | func (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 | |
| 158 | func (this *IPList) SetDeleted() { |
| 159 | this.isDeleted = true |