Files
WarpBox/lib/server/ids.go
Daniel Legt cf90e08f98 refactor: extract models/routes and env-based server config
- Move API request/response structs into new lib/models package
- Centralize Gin route registration in lib/routing to simplify wiring
- Add lib/server config helper to allow WARPBOX_BOX_POLL_INTERVAL_MS override
- Improves modularity and makes polling behavior configurable per environmentrefactor: extract models/routes and env-based server config

- Move API request/response structs into new lib/models package
- Centralize Gin route registration in lib/routing to simplify wiring
- Add lib/server config helper to allow WARPBOX_BOX_POLL_INTERVAL_MS override
- Improves modularity and makes polling behavior configurable per environment
2026-04-27 17:49:19 +03:00

40 lines
621 B
Go

package server
import (
"crypto/rand"
"encoding/hex"
"strings"
)
func newBoxID() (string, error) {
bytes := make([]byte, 16)
if _, err := rand.Read(bytes); err != nil {
return "", err
}
return hex.EncodeToString(bytes), nil
}
func newFileID() (string, error) {
bytes := make([]byte, 8)
if _, err := rand.Read(bytes); err != nil {
return "", err
}
return hex.EncodeToString(bytes), nil
}
func validBoxID(boxID string) bool {
if len(boxID) != 32 {
return false
}
for _, character := range boxID {
if !strings.ContainsRune("0123456789abcdef", character) {
return false
}
}
return true
}