NewIPList 获取新对象
(listType IPListType)
| 68 | |
| 69 | // NewIPList 获取新对象 |
| 70 | func 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 |
| 88 | func (this *IPList) Add(ipType string, scope firewallconfigs.FirewallScope, serverId int64, ip string, expiresAt int64) { |