2021-08-08 15:47:48 +08:00
|
|
|
package models
|
2022-08-22 15:11:22 +08:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
2024-07-27 14:15:25 +08:00
|
|
|
|
2022-09-10 16:13:21 +08:00
|
|
|
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
|
2022-08-22 15:11:22 +08:00
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ddosconfigs"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// DecodeDDoSProtection 解析DDOS Protection设置
|
|
|
|
|
func (this *NSCluster) DecodeDDoSProtection() *ddosconfigs.ProtectionConfig {
|
|
|
|
|
if IsNull(this.DdosProtection) {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var result = &ddosconfigs.ProtectionConfig{}
|
|
|
|
|
err := json.Unmarshal(this.DdosProtection, &result)
|
|
|
|
|
if err != nil {
|
2022-09-10 16:13:21 +08:00
|
|
|
remotelogs.Error("NSCluster.DecodeDDoSProtection", "decode failed: "+err.Error())
|
2022-08-22 15:11:22 +08:00
|
|
|
}
|
|
|
|
|
return result
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// HasDDoSProtection 检查是否有DDOS设置
|
|
|
|
|
func (this *NSCluster) HasDDoSProtection() bool {
|
|
|
|
|
var config = this.DecodeDDoSProtection()
|
|
|
|
|
if config != nil {
|
|
|
|
|
return config.IsOn()
|
|
|
|
|
}
|
|
|
|
|
return false
|
2022-09-10 16:13:21 +08:00
|
|
|
}
|