mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-28 21:46:36 +08:00
IPBox增加地域、ISP、添加到黑名单等功能
This commit is contained in:
40
internal/web/actions/default/servers/ipbox/addIP.go
Normal file
40
internal/web/actions/default/servers/ipbox/addIP.go
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package ipbox
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type AddIPAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *AddIPAction) RunPost(params struct {
|
||||
ListId int64
|
||||
Ip string
|
||||
}) {
|
||||
var ipType = "ipv4"
|
||||
if strings.Contains(params.Ip, ":") {
|
||||
ipType = "ipv6"
|
||||
}
|
||||
|
||||
_, err := this.RPC().IPItemRPC().CreateIPItem(this.AdminContext(), &pb.CreateIPItemRequest{
|
||||
IpListId: params.ListId,
|
||||
IpFrom: params.Ip,
|
||||
IpTo: "",
|
||||
ExpiredAt: time.Now().Unix() + 86400, // TODO 可以自定义时间
|
||||
Reason: "从IPBox中加入名单",
|
||||
Type: ipType,
|
||||
EventLevel: "critical",
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
Reference in New Issue
Block a user