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

Function NewIPList

internal/waf/ip_list.go:70–85  ·  view source on GitHub ↗

NewIPList 获取新对象

(listType IPListType)

Source from the content-addressed store, hash-verified

68
69// NewIPList 获取新对象
70func NewIPList(listType IPListType) *IPList {
71 var list = &IPList{
72 ipMap: map[string]uint64{},
73 idMap: map[uint64]string{},
74 listType: listType,
75 }
76
77 var e = expires.NewList()
78 list.expireList = e
79
80 e.OnGC(func(itemId uint64) {
81 list.remove(itemId) // TODO 使用异步,防止阻塞GC
82 })
83
84 return list
85}
86
87// Add 添加IP
88func (this *IPList) Add(ipType string, scope firewallconfigs.FirewallScope, serverId int64, ip string, expiresAt int64) {

Callers 8

TestNewIPListFunction · 0.92
TestIPList_ExpireFunction · 0.92
TestIPList_ContainsFunction · 0.92
TestIPList_SaveFunction · 0.92
BenchmarkIPList_AddFunction · 0.92
BenchmarkIPList_HasFunction · 0.92
ip_list.goFile · 0.70

Calls 3

NewListFunction · 0.92
OnGCMethod · 0.80
removeMethod · 0.45

Tested by 7

TestNewIPListFunction · 0.74
TestIPList_ExpireFunction · 0.74
TestIPList_ContainsFunction · 0.74
TestIPList_SaveFunction · 0.74
BenchmarkIPList_AddFunction · 0.74
BenchmarkIPList_HasFunction · 0.74