Merge pull request #55 from samwafgo/fix_54

fix:cc modify not affect
This commit is contained in:
samwafgo
2024-11-12 09:08:08 +08:00
committed by GitHub
2 changed files with 12 additions and 4 deletions
+9 -1
View File
@@ -415,8 +415,16 @@ func (m *wafSystenService) run() {
globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.HostTarget[globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.HostCode[msg.HostCode]].Mux.Unlock()
break
case enums.ChanTypeAnticc:
antiCC := msg.Content.(model.AntiCC)
globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.HostTarget[globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.HostCode[msg.HostCode]].Mux.Lock()
globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.HostTarget[globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.HostCode[msg.HostCode]].PluginIpRateLimiter = webplugin.NewIPRateLimiter(rate.Limit(msg.Content.(model.AntiCC).Rate), msg.Content.(model.AntiCC).Limit)
if antiCC.Id == "" {
globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.HostTarget[globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.HostCode[msg.HostCode]].PluginIpRateLimiter = nil
globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.HostTarget[globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.HostCode[msg.HostCode]].AntiCCBean = antiCC
} else {
globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.HostTarget[globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.HostCode[msg.HostCode]].PluginIpRateLimiter = webplugin.NewIPRateLimiter(rate.Limit(msg.Content.(model.AntiCC).Rate), msg.Content.(model.AntiCC).Limit)
globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.HostTarget[globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.HostCode[msg.HostCode]].AntiCCBean = antiCC
}
zlog.Debug("远程配置", zap.Any("Anticc", msg.Content.(model.AntiCC)))
globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.HostTarget[globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.HostCode[msg.HostCode]].Mux.Unlock()
break
+3 -3
View File
@@ -36,15 +36,15 @@ func (receiver *WafAntiCCService) AddApi(req request.WafAntiCCAddReq) error {
}
func (receiver *WafAntiCCService) CheckIsExistApi(req request.WafAntiCCAddReq) error {
return global.GWAF_LOCAL_DB.First(&model.AntiCC{}, "host_code = ? and url= ?", req.HostCode,
return global.GWAF_LOCAL_DB.First(&model.AntiCC{}, "host_code = ?", req.HostCode,
req.Url).Error
}
func (receiver *WafAntiCCService) ModifyApi(req request.WafAntiCCEditReq) error {
var ipWhite model.AntiCC
global.GWAF_LOCAL_DB.Where("host_code = ? and url= ?", req.HostCode,
global.GWAF_LOCAL_DB.Where("host_code = ? ", req.HostCode,
req.Url).Find(&ipWhite)
if ipWhite.Id != "" && ipWhite.Url != req.Url {
return errors.New("当前网站和url已经存在")
return errors.New("当前网站已经存在")
}
ipWhiteMap := map[string]interface{}{
"Host_Code": req.HostCode,