国家、省份数据不再每个小时更新一次;WAF增加国家/地区、省份、城市、ISP等参数

This commit is contained in:
刘祥超
2022-01-06 16:27:39 +08:00
parent be7267211b
commit ac4e240912
16 changed files with 583 additions and 20 deletions

View File

@@ -1,6 +1,6 @@
package checkpoints
// check point definition
// CheckpointDefinition check point definition
type CheckpointDefinition struct {
Name string
Description string

View File

@@ -0,0 +1,25 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package checkpoints
import (
"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
"github.com/iwind/TeaGo/maps"
)
type RequestGeoCityNameCheckpoint struct {
Checkpoint
}
func (this *RequestGeoCityNameCheckpoint) IsComposed() bool {
return false
}
func (this *RequestGeoCityNameCheckpoint) RequestValue(req requests.Request, param string, options maps.Map) (value interface{}, sysErr error, userErr error) {
value = req.Format("${geo.city.name}")
return
}
func (this *RequestGeoCityNameCheckpoint) ResponseValue(req requests.Request, resp *requests.Response, param string, options maps.Map) (value interface{}, sysErr error, userErr error) {
return this.RequestValue(req, param, options)
}

View File

@@ -0,0 +1,25 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package checkpoints
import (
"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
"github.com/iwind/TeaGo/maps"
)
type RequestGeoCountryNameCheckpoint struct {
Checkpoint
}
func (this *RequestGeoCountryNameCheckpoint) IsComposed() bool {
return false
}
func (this *RequestGeoCountryNameCheckpoint) RequestValue(req requests.Request, param string, options maps.Map) (value interface{}, sysErr error, userErr error) {
value = req.Format("${geo.country.name}")
return
}
func (this *RequestGeoCountryNameCheckpoint) ResponseValue(req requests.Request, resp *requests.Response, param string, options maps.Map) (value interface{}, sysErr error, userErr error) {
return this.RequestValue(req, param, options)
}

View File

@@ -0,0 +1,25 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package checkpoints
import (
"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
"github.com/iwind/TeaGo/maps"
)
type RequestGeoProvinceNameCheckpoint struct {
Checkpoint
}
func (this *RequestGeoProvinceNameCheckpoint) IsComposed() bool {
return false
}
func (this *RequestGeoProvinceNameCheckpoint) RequestValue(req requests.Request, param string, options maps.Map) (value interface{}, sysErr error, userErr error) {
value = req.Format("${geo.province.name}")
return
}
func (this *RequestGeoProvinceNameCheckpoint) ResponseValue(req requests.Request, resp *requests.Response, param string, options maps.Map) (value interface{}, sysErr error, userErr error) {
return this.RequestValue(req, param, options)
}

View File

@@ -0,0 +1,25 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package checkpoints
import (
"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
"github.com/iwind/TeaGo/maps"
)
type RequestISPNameCheckpoint struct {
Checkpoint
}
func (this *RequestISPNameCheckpoint) IsComposed() bool {
return false
}
func (this *RequestISPNameCheckpoint) RequestValue(req requests.Request, param string, options maps.Map) (value interface{}, sysErr error, userErr error) {
value = req.Format("${isp.name}")
return
}
func (this *RequestISPNameCheckpoint) ResponseValue(req requests.Request, resp *requests.Response, param string, options maps.Map) (value interface{}, sysErr error, userErr error) {
return this.RequestValue(req, param, options)
}

View File

@@ -173,7 +173,7 @@ var AllCheckpoints = []*CheckpointDefinition{
{
Name: "所有Header信息",
Prefix: "headers",
Description: "使用\n隔开的Header信息字符串",
Description: "使用\\n隔开的Header信息字符串",
HasParams: false,
Instance: new(RequestHeadersCheckpoint),
},
@@ -184,6 +184,34 @@ var AllCheckpoints = []*CheckpointDefinition{
HasParams: true,
Instance: new(RequestHeaderCheckpoint),
},
{
Name: "国家/地区名称",
Prefix: "geoCountryName",
Description: "国家/地区名称",
HasParams: false,
Instance: new(RequestGeoCountryNameCheckpoint),
},
{
Name: "省份名称",
Prefix: "geoProvinceName",
Description: "中国省份名称",
HasParams: false,
Instance: new(RequestGeoProvinceNameCheckpoint),
},
{
Name: "城市名称",
Prefix: "geoCityName",
Description: "中国城市名称",
HasParams: false,
Instance: new(RequestGeoCityNameCheckpoint),
},
{
Name: "ISP名称",
Prefix: "ispName",
Description: "ISP名称",
HasParams: false,
Instance: new(RequestISPNameCheckpoint),
},
{
Name: "CC统计",
Prefix: "cc",
@@ -242,7 +270,7 @@ var AllCheckpoints = []*CheckpointDefinition{
},
}
// find a check point
// FindCheckpoint find a check point
func FindCheckpoint(prefix string) CheckpointInterface {
for _, def := range AllCheckpoints {
if def.Prefix == prefix {
@@ -252,7 +280,7 @@ func FindCheckpoint(prefix string) CheckpointInterface {
return nil
}
// find a check point definition
// FindCheckpointDefinition find a check point definition
func FindCheckpointDefinition(prefix string) *CheckpointDefinition {
for _, def := range AllCheckpoints {
if def.Prefix == prefix {