Files
navi/internal/remnawave/embedded.go
T
Navis 1144fab54d Release 4.0.0+1: rebrand Navis → EvilFox; centralized Remnawave auto-provisioning (panel credentials baked into binary); remove Remnawave API UI; Windows 4.0.0.1.
Keep dist/navis-release/ path and ship Navis.exe as a same-hash alias of EvilFox.exe so 3.x clients can still update from the Windows branch feed.
2026-08-01 20:06:25 +03:00

52 lines
1.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package remnawave
// Centralized (NordVPN-style) provisioning: the panel address and API token
// are baked into the binary at build time, so every user gets configs
// automatically and cannot change the panel.
//
// build.bat copies configs/remnawave-api.json into embeddedcfg/ before
// `go build`; the copy is gitignored so credentials never land in the repo.
// Without the embedded file the app falls back to the external
// configs/remnawave-api.json (developer mode).
import (
"crypto/rand"
"embed"
"encoding/hex"
"fmt"
"os"
"time"
)
//go:embed embeddedcfg
var embeddedCfgFS embed.FS
// EmbeddedAdminConfig returns the admin config baked into the binary,
// or nil when this build has no embedded credentials.
func EmbeddedAdminConfig() *AdminConfig {
data, err := embeddedCfgFS.ReadFile("embeddedcfg/remnawave-api.json")
if err != nil {
return nil
}
cfg, err := parseAdminConfig(data)
if err != nil {
return nil
}
return cfg
}
// GenerateUsername makes a unique panel username for silent auto-provisioning
// (users never type anything): "fox_" + 10 hex chars, e.g. fox_3fa9c02b71.
func GenerateUsername() string {
var b [5]byte
if _, err := rand.Read(b[:]); err != nil {
// Keep within Remnawave's 634 char username limit.
s := fmt.Sprintf("fox_%x%x", os.Getpid()&0xffff, time.Now().UnixNano()&0xffffffff)
if len(s) > 34 {
s = s[:34]
}
return s
}
return "fox_" + hex.EncodeToString(b[:])
}