ContainsExpires 判断是否有某个IP,并返回过期时间
(ipType string, scope firewallconfigs.FirewallScope, serverId int64, ip string)
| 181 | |
| 182 | // ContainsExpires 判断是否有某个IP,并返回过期时间 |
| 183 | func (this *IPList) ContainsExpires(ipType string, scope firewallconfigs.FirewallScope, serverId int64, ip string) (expiresAt int64, ok bool) { |
| 184 | switch scope { |
| 185 | case firewallconfigs.FirewallScopeGlobal: |
| 186 | ip = "*@" + ip + "@" + ipType |
| 187 | case firewallconfigs.FirewallScopeServer: |
| 188 | ip = types.String(serverId) + "@" + ip + "@" + ipType |
| 189 | default: |
| 190 | ip = "*@" + ip + "@" + ipType |
| 191 | } |
| 192 | |
| 193 | this.locker.RLock() |
| 194 | id, ok := this.ipMap[ip] |
| 195 | if ok { |
| 196 | expiresAt = this.expireList.ExpiresAt(id) |
| 197 | } |
| 198 | this.locker.RUnlock() |
| 199 | return expiresAt, ok |
| 200 | } |
| 201 | |
| 202 | // RemoveIP 删除IP |
| 203 | func (this *IPList) RemoveIP(ip string, serverId int64, shouldExecute bool) { |