mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-12 10:16:37 +08:00
fix: 修复 WAF 规则组保存/绑定网站时报 of_waf_rule_group_bindings_pkey 冲突
This commit is contained in:
@@ -308,7 +308,7 @@ func buildSnapshotWAFDocument(ctx context.Context, routes []*model.ProxyRoute) (
|
||||
RegionWhitelist: view.RegionWhitelist,
|
||||
RegionBlacklist: view.RegionBlacklist,
|
||||
PoWEnabled: view.PoWEnabled,
|
||||
PoWConfig: convertPoWConfig(view.PoWConfig),
|
||||
PoWConfig: convertPoWConfig(view.PoWEnabled, view.PoWConfig),
|
||||
})
|
||||
}
|
||||
ipGroups, err := buildSnapshotWAFIPGroups(ctx, ruleGroups)
|
||||
@@ -415,10 +415,14 @@ func decodeIPList(raw string) ([]string, error) {
|
||||
return items, nil
|
||||
}
|
||||
|
||||
func convertPoWConfig(config *waf.PoWConfig) *openrestyrender.PoWConfig {
|
||||
if config == nil {
|
||||
func convertPoWConfig(enabled bool, config *waf.PoWConfig) *openrestyrender.PoWConfig {
|
||||
if !enabled {
|
||||
return nil
|
||||
}
|
||||
if config == nil {
|
||||
defaultConfig := openrestyrender.DefaultPoWConfig()
|
||||
return &defaultConfig
|
||||
}
|
||||
return &openrestyrender.PoWConfig{
|
||||
Difficulty: config.Difficulty,
|
||||
Algorithm: config.Algorithm,
|
||||
|
||||
Reference in New Issue
Block a user