集群可以设置WebP策略

This commit is contained in:
刘祥超
2022-04-01 16:20:36 +08:00
parent 6c1514cad7
commit d86f2bc1a4
5 changed files with 702 additions and 296 deletions

View File

@@ -68,6 +68,9 @@ type NodeConfig struct {
// 脚本
CommonScripts []*serverconfigs.CommonScript `yaml:"commonScripts" json:"commonScripts"`
// WebP
WebPImagePolicies map[int64]*WebPImagePolicy `yaml:"webpImagePolicies" json:"webpImagePolicies"`
paddedId string
// firewall
@@ -284,6 +287,16 @@ func (this *NodeConfig) Init() (err error, serverErrors []*ServerError) {
this.allowedIPMap[allowIP] = true
}
// webp image policy
if this.WebPImagePolicies != nil {
for _, policy := range this.WebPImagePolicies {
err = policy.Init()
if err != nil {
return
}
}
}
return
}
@@ -452,3 +465,11 @@ func (this *NodeConfig) UpdateCertOCSP(certId int64, ocsp []byte, expiresAt int6
}
}
}
// FindWebPImagePolicyWithClusterId 使用集群ID查找WebP策略
func (this *NodeConfig) FindWebPImagePolicyWithClusterId(clusterId int64) *WebPImagePolicy {
if this.WebPImagePolicies == nil {
return nil
}
return this.WebPImagePolicies[clusterId]
}