实现IP名单管理

This commit is contained in:
刘祥超
2020-11-07 19:40:32 +08:00
parent 8d074f09a8
commit 80562162d8
12 changed files with 2397 additions and 0 deletions

View File

@@ -1,5 +1,7 @@
package firewallconfigs
import "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ipconfigs"
type HTTPFirewallInboundConfig struct {
IsOn bool `yaml:"isOn" json:"isOn"`
GroupRefs []*HTTPFirewallRuleGroupRef `yaml:"groupRefs" json:"groupRefs"`
@@ -7,6 +9,11 @@ type HTTPFirewallInboundConfig struct {
// 地区相关
Region *HTTPFirewallRegionConfig `yaml:"region" json:"region"`
// IP名单
WhiteListRef *ipconfigs.IPListRef `yaml:"whiteListRef" json:"whiteListRef"`
BlackListRef *ipconfigs.IPListRef `yaml:"blackListRef" json:"blackListRef"`
GreyListRef *ipconfigs.IPListRef `yaml:"greyListRef" json:"greyListRef"`
}
// 初始化

View File

@@ -0,0 +1,13 @@
package ipconfigs
import "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
// IP名单配置
type IPListConfig struct {
Id int64 `yaml:"id" json:"id"` // ID
IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用
Version int64 `yaml:"version" json:"version"` // 版本号
Timeout *shared.TimeDuration `yaml:"timeout" json:"timeout"` // 默认超时时间
Code string `yaml:"code" json:"code"` // 代号
Type string `yaml:"type" json:"type"` // 类型
}

View File

@@ -0,0 +1,7 @@
package ipconfigs
// IP名单引用
type IPListRef struct {
IsOn bool `yaml:"isOn" json:"isOn"`
ListId int64 `yaml:"listId" json:"listId"`
}

View File

@@ -0,0 +1,26 @@
package ipconfigs
import "github.com/iwind/TeaGo/maps"
type IPListType = string
const (
IPListTypeWhite IPListType = "white"
IPListTypeBlack IPListType = "black"
IPListTypeGrey IPListType = "grey"
)
var IPListTypes = []maps.Map{
{
"name": "白名单",
"code": IPListTypeWhite,
},
{
"name": "黑名单",
"code": IPListTypeBlack,
},
{
"name": "灰名单",
"code": IPListTypeGrey,
},
}