mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-01 01:10:25 +08:00
IPBox把IP加入黑名单可以选择过期时间/可以从已经添加的名单中删除/已经添加的名单中显示过期时间
This commit is contained in:
@@ -14,19 +14,30 @@ type AddIPAction struct {
|
||||
}
|
||||
|
||||
func (this *AddIPAction) RunPost(params struct {
|
||||
ListId int64
|
||||
Ip string
|
||||
ListId int64
|
||||
Ip string
|
||||
ExpiredAt int64
|
||||
}) {
|
||||
var itemId int64 = 0
|
||||
|
||||
defer func() {
|
||||
this.CreateLogInfo("在名单 %d 中创建IP %d", params.ListId, itemId)
|
||||
}()
|
||||
|
||||
var ipType = "ipv4"
|
||||
if strings.Contains(params.Ip, ":") {
|
||||
ipType = "ipv6"
|
||||
}
|
||||
|
||||
_, err := this.RPC().IPItemRPC().CreateIPItem(this.AdminContext(), &pb.CreateIPItemRequest{
|
||||
if params.ExpiredAt <= 0 {
|
||||
params.ExpiredAt = time.Now().Unix() + 86400
|
||||
}
|
||||
|
||||
createResp, err := this.RPC().IPItemRPC().CreateIPItem(this.AdminContext(), &pb.CreateIPItemRequest{
|
||||
IpListId: params.ListId,
|
||||
IpFrom: params.Ip,
|
||||
IpTo: "",
|
||||
ExpiredAt: time.Now().Unix() + 86400, // TODO 可以自定义时间
|
||||
ExpiredAt: params.ExpiredAt,
|
||||
Reason: "从IPBox中加入名单",
|
||||
Type: ipType,
|
||||
EventLevel: "critical",
|
||||
@@ -36,5 +47,7 @@ func (this *AddIPAction) RunPost(params struct {
|
||||
return
|
||||
}
|
||||
|
||||
itemId = createResp.IpItemId
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user