mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-09 19:50:30 +08:00
增加防盗链功能
This commit is contained in:
@@ -457,6 +457,16 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
||||
config.UAM = uamConfig
|
||||
}
|
||||
|
||||
// Referers
|
||||
if IsNotNull(web.Referers) {
|
||||
var referersConfig = &serverconfigs.ReferersConfig{}
|
||||
err = json.Unmarshal(web.Referers, referersConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
config.Referers = referersConfig
|
||||
}
|
||||
|
||||
if cacheMap != nil {
|
||||
cacheMap.Put(cacheKey, config)
|
||||
}
|
||||
@@ -1212,6 +1222,35 @@ func (this *HTTPWebDAO) FindWebUAM(tx *dbs.Tx, webId int64) ([]byte, error) {
|
||||
FindJSONCol()
|
||||
}
|
||||
|
||||
// UpdateWebReferers 修改防盗链设置
|
||||
func (this *HTTPWebDAO) UpdateWebReferers(tx *dbs.Tx, webId int64, referersConfig *serverconfigs.ReferersConfig) error {
|
||||
if referersConfig == nil {
|
||||
return nil
|
||||
}
|
||||
configJSON, err := json.Marshal(referersConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = this.Query(tx).
|
||||
Pk(webId).
|
||||
Set("referers", configJSON).
|
||||
UpdateQuickly()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return this.NotifyUpdate(tx, webId)
|
||||
}
|
||||
|
||||
// FindWebReferers 查找服务的防盗链配置
|
||||
func (this *HTTPWebDAO) FindWebReferers(tx *dbs.Tx, webId int64) ([]byte, error) {
|
||||
return this.Query(tx).
|
||||
Pk(webId).
|
||||
Result("referers").
|
||||
FindJSONCol()
|
||||
}
|
||||
|
||||
// NotifyUpdate 通知更新
|
||||
func (this *HTTPWebDAO) NotifyUpdate(tx *dbs.Tx, webId int64) error {
|
||||
// server
|
||||
|
||||
Reference in New Issue
Block a user