Contains 判断是否有某个IP
(ipType string, scope firewallconfigs.FirewallScope, serverId int64, ip string)
| 164 | |
| 165 | // Contains 判断是否有某个IP |
| 166 | func (this *IPList) Contains(ipType string, scope firewallconfigs.FirewallScope, serverId int64, ip string) bool { |
| 167 | switch scope { |
| 168 | case firewallconfigs.FirewallScopeGlobal: |
| 169 | ip = "*@" + ip + "@" + ipType |
| 170 | case firewallconfigs.FirewallScopeServer: |
| 171 | ip = types.String(serverId) + "@" + ip + "@" + ipType |
| 172 | default: |
| 173 | ip = "*@" + ip + "@" + ipType |
| 174 | } |
| 175 | |
| 176 | this.locker.RLock() |
| 177 | _, ok := this.ipMap[ip] |
| 178 | this.locker.RUnlock() |
| 179 | return ok |
| 180 | } |
| 181 | |
| 182 | // ContainsExpires 判断是否有某个IP,并返回过期时间 |
| 183 | func (this *IPList) ContainsExpires(ipType string, scope firewallconfigs.FirewallScope, serverId int64, ip string) (expiresAt int64, ok bool) { |