package state import ( "errors" "net" "os" "path/filepath" "regexp" "strconv" "ripple/config" ) var errInvalidAddress = errors.New("invalid address") var usernameRegex = regexp.MustCompile(`^[A-Za-z0-9_]{1,32}$`) func storagePath() (string, error) { homeDir, err := os.UserHomeDir() if err != nil { return "", err } return filepath.Join(homeDir, config.DataDir, config.StorageFile), nil } func validateAddress(addr string, port int) error { hostPort := net.JoinHostPort(addr, strconv.Itoa(port)) if _, err := net.ResolveUDPAddr("udp", hostPort); err != nil { return errInvalidAddress } return nil }