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

Method ContainsExpires

internal/waf/ip_list.go:183–200  ·  view source on GitHub ↗

ContainsExpires 判断是否有某个IP,并返回过期时间

(ipType string, scope firewallconfigs.FirewallScope, serverId int64, ip string)

Source from the content-addressed store, hash-verified

181
182// ContainsExpires 判断是否有某个IP,并返回过期时间
183func (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
203func (this *IPList) RemoveIP(ip string, serverId int64, shouldExecute bool) {

Callers 2

AcceptMethod · 0.45

Calls 4

RLockMethod · 0.80
RUnlockMethod · 0.80
ExpiresAtMethod · 0.65
StringMethod · 0.45

Tested by 1