Expand README with desktop platform requirements (Windows x86, macOS ARM), helper build commands, gateway utility scripts, and updated local test flow. Add realistic MVP usage section clarifying current platform build status, gateway configuration needs, and admin debug profile behavior with client private key handling.
42 lines
890 B
Go
42 lines
890 B
Go
package gateway
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
"nexavpn/backend/internal/wireguard"
|
|
)
|
|
|
|
type Service struct {
|
|
repo Repository
|
|
}
|
|
|
|
func NewService(repo Repository) *Service {
|
|
return &Service{repo: repo}
|
|
}
|
|
|
|
func (s *Service) List(ctx context.Context) ([]Gateway, error) {
|
|
return s.repo.List(ctx)
|
|
}
|
|
|
|
func (s *Service) SelectActive(ctx context.Context) (Gateway, error) {
|
|
return s.repo.FirstActive(ctx)
|
|
}
|
|
|
|
func (s *Service) BuildSyncBundle(ctx context.Context, gatewayID string) (wireguard.GatewayBundle, error) {
|
|
id, err := uuid.Parse(gatewayID)
|
|
if err != nil {
|
|
return wireguard.GatewayBundle{}, err
|
|
}
|
|
return s.repo.BuildSyncBundle(ctx, id)
|
|
}
|
|
|
|
func (s *Service) Update(ctx context.Context, gatewayID string, input UpdateRequest) (Gateway, error) {
|
|
id, err := uuid.Parse(gatewayID)
|
|
if err != nil {
|
|
return Gateway{}, err
|
|
}
|
|
return s.repo.Update(ctx, id, input)
|
|
}
|