Files
NexaVPN/backend/internal/profile/builder.go
nessi 830491cb0d chore: initial project scaffold with admin web, backend, desktop client, and deployment setup
Add monorepo structure for NexaVPN WireGuard control plane including:
- .gitignore for node_modules, build artifacts, and environment files
- README with project overview, monorepo layout, and quick start guide
- Admin web UI with React, Vite, TypeScript, and nginx reverse proxy
- API client with type definitions for users, devices, policies, gateways, and audit logs
- Admin pages for dashboard, users, devices, policies, g
2026-03-15 16:32:34 +01:00

34 lines
963 B
Go

package profile
import (
"fmt"
"strings"
)
type BuildInput struct {
PrivateKey string
Address string
DNSServers []string
ServerPublicKey string
ServerEndpoint string
AllowedIPs []string
PersistentKeepal int
}
func BuildWireGuardConfig(input BuildInput) string {
var b strings.Builder
b.WriteString("[Interface]\n")
b.WriteString(fmt.Sprintf("PrivateKey = %s\n", input.PrivateKey))
b.WriteString(fmt.Sprintf("Address = %s\n", input.Address))
if len(input.DNSServers) > 0 {
b.WriteString(fmt.Sprintf("DNS = %s\n", strings.Join(input.DNSServers, ", ")))
}
b.WriteString("\n[Peer]\n")
b.WriteString(fmt.Sprintf("PublicKey = %s\n", input.ServerPublicKey))
b.WriteString(fmt.Sprintf("Endpoint = %s\n", input.ServerEndpoint))
b.WriteString(fmt.Sprintf("AllowedIPs = %s\n", strings.Join(input.AllowedIPs, ", ")))
b.WriteString(fmt.Sprintf("PersistentKeepalive = %d\n", input.PersistentKeepal))
return b.String()
}