fix: Redis集群查询+metrics修复 — 单节点连接替代ClusterClient

- crypto.go: decryptPassword 自动处理 enc: 前缀,避免调用方遗漏
- redis.go: getRedisClient 统一使用 redis.NewClient 单节点连接
  ClusterClient 拓扑发现(CLUSTER SLOTS)在Docker内网IP不可达时超时
  redisClientWrapper 全部方法改为使用 Client (不再走 ClusterClient)
  ScanAllKeys 简化为单节点 SCAN
- connection_tester.go: getRedisMetrics 统一单节点连接采集metrics
  删除 isCluster 分支的 ClusterClient 代码,避免5秒超时
This commit is contained in:
logan committed 2026-05-31 01:30:10 +08:00
1 parent e9a700b9d9
commit 9c5cb04cfa
3 files changed
+55 -173

No files matched your search

+6 -1
View File
@@ -6,6 +6,7 @@ import (
"crypto/rand"
"encoding/base64"
"os"
"strings"
)
// getSecretKey returns the AES key derived from SECRET_KEY env var.
@@ -26,8 +27,12 @@ func getSecretKey() []byte {
// decryptPassword decrypts a base64-encoded AES-256-GCM ciphertext.
// Mirrors Python's crypto.decrypt_password().
// If the value is not valid encrypted data (e.g., plaintext), returns it as-is.
// Handles "enc:" prefix automatically. If not valid encrypted data, returns as-is.
func decryptPassword(encrypted string) (string, error) {
// Strip "enc:" prefix if present
if strings.HasPrefix(encrypted, "enc:") {
encrypted = strings.TrimPrefix(encrypted, "enc:")
}
raw, err := base64.StdEncoding.DecodeString(encrypted)
if err != nil {
return encrypted, nil // not valid base64 — plaintext