mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2026-04-08 22:58:21 +08:00
国家、省份数据不再每个小时更新一次;WAF增加国家/地区、省份、城市、ISP等参数
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package checkpoints
|
||||
|
||||
// check point definition
|
||||
// CheckpointDefinition check point definition
|
||||
type CheckpointDefinition struct {
|
||||
Name string
|
||||
Description string
|
||||
|
||||
25
internal/waf/checkpoints/request_geo_city_name.go
Normal file
25
internal/waf/checkpoints/request_geo_city_name.go
Normal 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)
|
||||
}
|
||||
25
internal/waf/checkpoints/request_geo_country_name.go
Normal file
25
internal/waf/checkpoints/request_geo_country_name.go
Normal 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)
|
||||
}
|
||||
25
internal/waf/checkpoints/request_geo_province_name.go
Normal file
25
internal/waf/checkpoints/request_geo_province_name.go
Normal 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)
|
||||
}
|
||||
25
internal/waf/checkpoints/request_isp_name.go
Normal file
25
internal/waf/checkpoints/request_isp_name.go
Normal 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)
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user