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
34 lines
709 B
Go
34 lines
709 B
Go
package policy
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type Service struct {
|
|
repo Repository
|
|
}
|
|
|
|
func NewService(repo Repository) *Service {
|
|
return &Service{repo: repo}
|
|
}
|
|
|
|
func (s *Service) List(ctx context.Context) ([]Policy, error) {
|
|
return s.repo.List(ctx)
|
|
}
|
|
|
|
func (s *Service) Create(ctx context.Context, actorID uuid.UUID, input CreateRequest) (Policy, error) {
|
|
if input.Priority == 0 {
|
|
input.Priority = 100
|
|
}
|
|
if input.Effect == "" {
|
|
input.Effect = "allow"
|
|
}
|
|
return s.repo.Create(ctx, input, actorID)
|
|
}
|
|
|
|
func (s *Service) ResolveDestinations(ctx context.Context, userID uuid.UUID, deviceID *uuid.UUID) ([]string, error) {
|
|
return s.repo.ResolveDestinations(ctx, userID, deviceID)
|
|
}
|