diff --git a/internal/service/auto_config.go b/internal/service/auto_config.go index 548f437..ca40b8e 100644 --- a/internal/service/auto_config.go +++ b/internal/service/auto_config.go @@ -606,24 +606,14 @@ func cleanSourceNames(names []string) []string { // deriveSafeInstanceName converts a user-facing video source name into a valid // recognition unit instance name ([A-Za-z0-9_.-]+). If the source name is already -// valid, it's used as-is. Otherwise, a sanitised version is generated. +// valid, it's used as-is. Otherwise, a unique hash-based name is generated. func deriveSafeInstanceName(srcName string) string { // If already valid per validateConfigName rules, use as-is. if safeConfigName.MatchString(srcName) { return srcName } - // Build a safe name from the source: keep only ASCII letters, digits, underscores. - var b strings.Builder - for _, r := range srcName { - if (r >= 'a' && r <= 'z') || (r >= 'A' && r <= 'Z') || (r >= '0' && r <= '9') || r == '_' || r == '-' || r == '.' { - b.WriteRune(r) - } - } - derived := strings.Trim(b.String(), "-_.") - if derived != "" && safeConfigName.MatchString(derived) { - return derived - } - // Fallback: use a short hash suffix to guarantee uniqueness. + // For non-ASCII names, use a hash prefix to guarantee uniqueness + // (extracting digits/ASCII from Chinese names causes collisions e.g. "5跨主通道" and "5跨焙烧区" both → "5"). sum := sha256.Sum256([]byte(srcName)) return "src_" + strings.ToLower(hex.EncodeToString(sum[:4])) } diff --git a/safesightd-linux-arm64 b/safesightd-linux-arm64 index 0eb0212..b4fee56 100644 Binary files a/safesightd-linux-arm64 and b/safesightd-linux-arm64 differ