mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-25 00:10:26 +08:00
增加CC防护相关API
This commit is contained in:
@@ -458,6 +458,16 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
||||
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
|
||||
if IsNotNull(web.Referers) {
|
||||
var referersConfig = &serverconfigs.ReferersConfig{}
|
||||
@@ -1233,6 +1243,35 @@ func (this *HTTPWebDAO) FindWebUAM(tx *dbs.Tx, webId int64) ([]byte, error) {
|
||||
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 修改防盗链设置
|
||||
func (this *HTTPWebDAO) UpdateWebReferers(tx *dbs.Tx, webId int64, referersConfig *serverconfigs.ReferersConfig) error {
|
||||
if referersConfig == nil {
|
||||
|
||||
Reference in New Issue
Block a user