mirror of
https://github.com/remnawave/migrate.git
synced 2026-05-13 12:16:40 +00:00
- 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>
28 lines
468 B
Go
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
|
|
}
|