Browse Source

fix(aodun): 处理重复防御值的错误响应

- 在反序列化 JSON 响应后,检查 res.Msg 是否为 "当前ip已是此防御值"
- 如果是该错误消息,表示无需进一步操作,直接返回 nil
- 这样可以避免在 IP
fusu 1 week ago
parent
commit
538c129bf4
1 changed files with 3 additions and 0 deletions
  1. 3 0
      internal/service/aodun.go

+ 3 - 0
internal/service/aodun.go

@@ -407,6 +407,9 @@ func (s *aoDunService) SetDefense(ctx context.Context, req v1.SetDefense) error
 	if err := json.Unmarshal(resBody, &res); err != nil {
 	if err := json.Unmarshal(resBody, &res); err != nil {
 		return fmt.Errorf("反序列化响应 JSON 失败 (内容: %s): %w", string(resBody), err)
 		return fmt.Errorf("反序列化响应 JSON 失败 (内容: %s): %w", string(resBody), err)
 	}
 	}
+	if res.Msg == "当前ip已是此防御值" {
+		return nil
+	}
 	if res.Code != 200 {
 	if res.Code != 200 {
 		return fmt.Errorf("API 错误: code %d, msg '%s'", res.Code, res.Msg)
 		return fmt.Errorf("API 错误: code %d, msg '%s'", res.Code, res.Msg)
 	}
 	}