Remnawave_migrate/util/username_sanitizer.go
Sergey Kutovoy faf2786d01
Refactor: Implement universal panel migration architecture
- Created modular source panel interface for extensibility
- Renamed arguments from marzban-* to panel-*
- Added panel-type argument with support for "marzban" and "marzneshin"
- Implemented Marzneshin panel support with unique proxy extraction logic
- Restructured models to support different panel types
- Updated README with new options and instructions
- Renamed app to "remnawave-migrate" to reflect universal nature

This refactoring makes the migration tool more flexible and
allows easier addition of new panel types in the future.

Co-authored-by: Yury Kastov <kastov@gog.sh>
2025-03-17 00:48:02 +05:00

28 lines
468 B
Go

package util
import (
"regexp"
"strings"
)
func SanitizeUsername(username string) string {
validPattern := regexp.MustCompile(`^[a-zA-Z0-9_-]+$`)
var sanitized strings.Builder
for _, char := range username {
if validPattern.MatchString(string(char)) {
sanitized.WriteRune(char)
} else {
sanitized.WriteRune('_')
}
}
result := sanitized.String()
if len(result) < 6 {
result = result + strings.Repeat("_", 6-len(result))
}
return result
}