mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-07 02:20:24 +08:00
增加CC防护相关API
This commit is contained in:
@@ -21,5 +21,5 @@ const (
|
|||||||
NodeVersion = "0.6.4"
|
NodeVersion = "0.6.4"
|
||||||
|
|
||||||
// SQLVersion SQL版本号
|
// SQLVersion SQL版本号
|
||||||
SQLVersion = "10"
|
SQLVersion = "11"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -458,6 +458,16 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
config.UAM = uamConfig
|
config.UAM = uamConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CC
|
||||||
|
if teaconst.IsPlus && IsNotNull(web.Cc) {
|
||||||
|
var ccConfig = &serverconfigs.HTTPCCConfig{}
|
||||||
|
err = json.Unmarshal(web.Cc, ccConfig)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
config.CC = ccConfig
|
||||||
|
}
|
||||||
|
|
||||||
// Referers
|
// Referers
|
||||||
if IsNotNull(web.Referers) {
|
if IsNotNull(web.Referers) {
|
||||||
var referersConfig = &serverconfigs.ReferersConfig{}
|
var referersConfig = &serverconfigs.ReferersConfig{}
|
||||||
@@ -1233,6 +1243,35 @@ func (this *HTTPWebDAO) FindWebUAM(tx *dbs.Tx, webId int64) ([]byte, error) {
|
|||||||
FindJSONCol()
|
FindJSONCol()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateWebCC 开启CC
|
||||||
|
func (this *HTTPWebDAO) UpdateWebCC(tx *dbs.Tx, webId int64, ccConfig *serverconfigs.HTTPCCConfig) error {
|
||||||
|
if ccConfig == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
configJSON, err := json.Marshal(ccConfig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = this.Query(tx).
|
||||||
|
Pk(webId).
|
||||||
|
Set("cc", configJSON).
|
||||||
|
UpdateQuickly()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.NotifyUpdate(tx, webId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindWebCC 查找服务的CC配置
|
||||||
|
func (this *HTTPWebDAO) FindWebCC(tx *dbs.Tx, webId int64) ([]byte, error) {
|
||||||
|
return this.Query(tx).
|
||||||
|
Pk(webId).
|
||||||
|
Result("cc").
|
||||||
|
FindJSONCol()
|
||||||
|
}
|
||||||
|
|
||||||
// UpdateWebReferers 修改防盗链设置
|
// UpdateWebReferers 修改防盗链设置
|
||||||
func (this *HTTPWebDAO) UpdateWebReferers(tx *dbs.Tx, webId int64, referersConfig *serverconfigs.ReferersConfig) error {
|
func (this *HTTPWebDAO) UpdateWebReferers(tx *dbs.Tx, webId int64, referersConfig *serverconfigs.ReferersConfig) error {
|
||||||
if referersConfig == nil {
|
if referersConfig == nil {
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ type HTTPWeb struct {
|
|||||||
RequestLimit dbs.JSON `field:"requestLimit"` // 请求限制
|
RequestLimit dbs.JSON `field:"requestLimit"` // 请求限制
|
||||||
RequestScripts dbs.JSON `field:"requestScripts"` // 请求脚本
|
RequestScripts dbs.JSON `field:"requestScripts"` // 请求脚本
|
||||||
Uam dbs.JSON `field:"uam"` // UAM设置
|
Uam dbs.JSON `field:"uam"` // UAM设置
|
||||||
|
Cc dbs.JSON `field:"cc"` // CC设置
|
||||||
Referers dbs.JSON `field:"referers"` // 防盗链设置
|
Referers dbs.JSON `field:"referers"` // 防盗链设置
|
||||||
UserAgent dbs.JSON `field:"userAgent"` // UserAgent设置
|
UserAgent dbs.JSON `field:"userAgent"` // UserAgent设置
|
||||||
}
|
}
|
||||||
@@ -77,6 +78,7 @@ type HTTPWebOperator struct {
|
|||||||
RequestLimit any // 请求限制
|
RequestLimit any // 请求限制
|
||||||
RequestScripts any // 请求脚本
|
RequestScripts any // 请求脚本
|
||||||
Uam any // UAM设置
|
Uam any // UAM设置
|
||||||
|
Cc any // CC设置
|
||||||
Referers any // 防盗链设置
|
Referers any // 防盗链设置
|
||||||
UserAgent any // UserAgent设置
|
UserAgent any // UserAgent设置
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,3 +18,12 @@ func (this *HTTPWebService) UpdateHTTPWebUAM(ctx context.Context, req *pb.Update
|
|||||||
func (this *HTTPWebService) FindHTTPWebUAM(ctx context.Context, req *pb.FindHTTPWebUAMRequest) (*pb.FindHTTPWebUAMResponse, error) {
|
func (this *HTTPWebService) FindHTTPWebUAM(ctx context.Context, req *pb.FindHTTPWebUAMRequest) (*pb.FindHTTPWebUAMResponse, error) {
|
||||||
return &pb.FindHTTPWebUAMResponse{UamJSON: nil}, nil
|
return &pb.FindHTTPWebUAMResponse{UamJSON: nil}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *HTTPWebService) UpdateHTTPWebCC(ctx context.Context, req *pb.UpdateHTTPWebCCRequest) (*pb.RPCSuccess, error) {
|
||||||
|
return nil, this.NotImplementedYet()
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindHTTPWebCC 查找UAM设置
|
||||||
|
func (this *HTTPWebService) FindHTTPWebCC(ctx context.Context, req *pb.FindHTTPWebCCRequest) (*pb.FindHTTPWebCCResponse, error) {
|
||||||
|
return nil, this.NotImplementedYet()
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user