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

Method Contains

internal/waf/ip_list.go:166–180  ·  view source on GitHub ↗

Contains 判断是否有某个IP

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

Source from the content-addressed store, hash-verified

164
165// Contains 判断是否有某个IP
166func (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,并返回过期时间
183func (this *IPList) ContainsExpires(ipType string, scope firewallconfigs.FirewallScope, serverId int64, ip string) (expiresAt int64, ok bool) {

Callers 15

ErrorFunction · 0.45
ErrorServerFunction · 0.45
listenUDPMethod · 0.45
doRootMethod · 0.45
findIndexFileMethod · 0.45
handleConnMethod · 0.45
FormatMethod · 0.45
fixRequestHeaderMethod · 0.45
canIgnoreMethod · 0.45
updateDiskMethod · 0.45
doMismatchMethod · 0.45
AcceptMethod · 0.45

Calls 3

RLockMethod · 0.80
RUnlockMethod · 0.80
StringMethod · 0.45

Tested by 4

testUnescapeFunction · 0.36
TestIPList_ContainsFunction · 0.36
TestIPList_SaveFunction · 0.36
BenchmarkIPList_HasFunction · 0.36