RemoveIP 删除IP
(ip string, serverId int64, shouldExecute bool)
| 201 | |
| 202 | // RemoveIP 删除IP |
| 203 | func (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 |
| 237 | func (this *IPList) Save(path string) error { |