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

Method RemoveIP

internal/waf/ip_list.go:203–234  ·  view source on GitHub ↗

RemoveIP 删除IP

(ip string, serverId int64, shouldExecute bool)

Source from the content-addressed store, hash-verified

201
202// RemoveIP 删除IP
203func (this *IPList) RemoveIP(ip string, serverId int64, shouldExecute bool) {
204 this.locker.Lock()
205
206 {
207 var key = "*@" + ip + "@" + IPTypeAll
208 id, ok := this.ipMap[key]
209 if ok {
210 delete(this.ipMap, key)
211 delete(this.idMap, id)
212
213 this.expireList.Remove(id)
214 }
215 }
216
217 if serverId > 0 {
218 var key = types.String(serverId) + "@" + ip + "@" + IPTypeAll
219 id, ok := this.ipMap[key]
220 if ok {
221 delete(this.ipMap, key)
222 delete(this.idMap, id)
223
224 this.expireList.Remove(id)
225 }
226 }
227
228 this.locker.Unlock()
229
230 // 从本地防火墙中删除
231 if shouldExecute {
232 _ = firewalls.Firewall().RemoveSourceIP(ip)
233 }
234}
235
236// Save to local file
237func (this *IPList) Save(path string) error {

Callers 2

processItemsMethod · 0.80
TestNewIPListFunction · 0.80

Calls 6

FirewallFunction · 0.92
RemoveMethod · 0.65
RemoveSourceIPMethod · 0.65
LockMethod · 0.45
StringMethod · 0.45
UnlockMethod · 0.45

Tested by 1

TestNewIPListFunction · 0.64