Documentation
¶
Index ¶
- func GenerateKeyPair() (privateKey, publicKey string, err error)
- func GeneratePassword(length int) (string, error)
- type CalendarClient
- type CalendarConfig
- type CalendarService
- type ESXiConfig
- type EmailAttachment
- type EmailSender
- type EmailService
- type FeatureConfig
- type OPNsenseAPI
- type OPNsenseClient
- type PeerRow
- type UserVMPair
- type VMwareClient
- type VMwareService
- func (s *VMwareService) Close(ctx context.Context) error
- func (s *VMwareService) GetClient() *govmomi.Client
- func (s *VMwareService) GetFinder() *find.Finder
- func (s *VMwareService) ListAllVMs(ctx context.Context) ([]*models.VM, error)
- func (s *VMwareService) ListVMSnapshots(ctx context.Context) (*models.VMListResponse, error)
- func (s *VMwareService) RestoreVMsWithPasswordRotation(ctx context.Context, vmNames []string, userNames []string, snapshotName string) ([]string, map[string]string)
- func (s *VMwareService) RotateESXiUserPassword(ctx context.Context, host *object.HostSystem, username string) (string, error)
- type WireGuardConfig
- type WireGuardManager
- type WireGuardService
- func (w *WireGuardService) GenerateClientConfig(username string, userIndex int) (string, error)
- func (w *WireGuardService) RegisterPeerWithOPNsense(username string, publicKey string, userIndex int) error
- func (w *WireGuardService) RotateUserKey(username string) (privateKey, publicKey string, err error)
- func (w *WireGuardService) ValidateConfig() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateKeyPair ¶
GenerateKeyPair generates a new WireGuard private/public key pair
func GeneratePassword ¶
GeneratePassword generates a random password of specified length
Types ¶
type CalendarClient ¶
CalendarClient abstracts Google Calendar operations for testability.
type CalendarConfig ¶
type CalendarConfig struct {
CalendarID string `toml:"calendar_id"`
ServiceAccountPath string `toml:"service_account_path"`
}
func (*CalendarConfig) LoadServiceAccountToken ¶
func (c *CalendarConfig) LoadServiceAccountToken() ([]byte, error)
type CalendarService ¶
type CalendarService struct {
// contains filtered or unexported fields
}
func NewCalendarService ¶
func NewCalendarService(ctx context.Context, config CalendarConfig) (*CalendarService, error)
func (*CalendarService) ListEvents ¶
func (s *CalendarService) ListEvents(timeMin, timeMax string) ([]*calendar.Event, error)
type ESXiConfig ¶
type ESXiConfig struct {
URL string `toml:"url"`
UserVMMappings map[string][]string `toml:"user_vm_mappings"`
SnapshotName *string `toml:"snapshot_name"`
}
func (*ESXiConfig) UserVMPairs ¶
func (c *ESXiConfig) UserVMPairs() []UserVMPair
UserVMPairs returns user-VM pairs sorted by username.
func (*ESXiConfig) Users ¶
func (c *ESXiConfig) Users() []string
Users returns sorted usernames from user-VM mappings.
func (*ESXiConfig) VMs ¶
func (c *ESXiConfig) VMs() []string
VMs returns all VM prefixes from user-VM mappings.
type EmailAttachment ¶
EmailAttachment represents a file attachment for an email
type EmailSender ¶
type EmailSender interface {
SendPasswordEmail(to, vmName, username, password string) error
SendPasswordEmailWithAttachment(to, vmName, username, password string, attachment *EmailAttachment) error
}
EmailSender abstracts email sending operations for testability.
type EmailService ¶
type EmailService struct {
// contains filtered or unexported fields
}
func NewEmailService ¶
func NewEmailService(smtpHost, smtpPort, username, password, fromEmail, testEmailOnly string) (*EmailService, error)
NewEmailService creates a new email service using SMTP
func (*EmailService) SendPasswordEmail ¶
func (s *EmailService) SendPasswordEmail(to, vmName, username, password string) error
SendPasswordEmail sends an email with the new password to the recipient
func (*EmailService) SendPasswordEmailWithAttachment ¶
func (s *EmailService) SendPasswordEmailWithAttachment(to, vmName, username, password string, attachment *EmailAttachment) error
SendPasswordEmailWithAttachment sends an email with the new password and optional attachment
type FeatureConfig ¶
type FeatureConfig struct {
Calendar CalendarConfig `toml:"calendar"`
ESXi ESXiConfig `toml:"esxi"`
WireGuard WireGuardConfig `toml:"wireguard"`
}
func LoadFeatureConfig ¶
func LoadFeatureConfig(path string) (*FeatureConfig, error)
type OPNsenseAPI ¶
type OPNsenseAPI interface {
SearchPeerByTunnelAddress(tunnelAddress string) (*PeerRow, error)
UpdatePeer(uuid, name, publicKey, tunnelAddress, servers string) error
CreatePeer(name, publicKey, tunnelAddress string, keepalive int) error
}
OPNsenseAPI abstracts OPNsense WireGuard API operations for testability.
type OPNsenseClient ¶
type OPNsenseClient struct {
// contains filtered or unexported fields
}
OPNsenseClient represents a client for OPNsense WireGuard API
func NewOPNsenseClient ¶
func NewOPNsenseClient(url, apiKey, apiSecret string, httpClient *http.Client, insecure bool) *OPNsenseClient
func (*OPNsenseClient) CreatePeer ¶
func (c *OPNsenseClient) CreatePeer(name, publicKey, tunnelAddress string, keepalive int) error
CreatePeer creates a new WireGuard peer in OPNsense
func (*OPNsenseClient) SearchPeerByTunnelAddress ¶
func (c *OPNsenseClient) SearchPeerByTunnelAddress(tunnelAddress string) (*PeerRow, error)
SearchPeerByTunnelAddress finds an existing peer by its tunnel address. The comparison ignores CIDR notation so "172.17.18.103/32" matches "172.17.18.103".
func (*OPNsenseClient) UpdatePeer ¶
func (c *OPNsenseClient) UpdatePeer(uuid, name, publicKey, tunnelAddress, servers string) error
UpdatePeer updates an existing WireGuard peer's public key.
type PeerRow ¶
type PeerRow struct {
UUID string `json:"uuid"`
Name string `json:"name"`
PubKey string `json:"pubkey"`
TunnelAddress string `json:"tunneladdress"`
Servers string `json:"servers"`
}
PeerRow represents a WireGuard peer from the OPNsense search response
type UserVMPair ¶
type VMwareClient ¶
type VMwareClient interface {
ListVMSnapshots(ctx context.Context) (*models.VMListResponse, error)
RestoreVMsWithPasswordRotation(ctx context.Context, vmNames []string, userNames []string, snapshotName string) ([]string, map[string]string)
Close(ctx context.Context) error
}
VMwareClient abstracts VMware operations for testability.
type VMwareService ¶
type VMwareService struct {
// contains filtered or unexported fields
}
func NewVMwareService ¶
func (*VMwareService) GetClient ¶
func (s *VMwareService) GetClient() *govmomi.Client
func (*VMwareService) GetFinder ¶
func (s *VMwareService) GetFinder() *find.Finder
func (*VMwareService) ListAllVMs ¶
func (*VMwareService) ListVMSnapshots ¶
func (s *VMwareService) ListVMSnapshots(ctx context.Context) (*models.VMListResponse, error)
func (*VMwareService) RestoreVMsWithPasswordRotation ¶
func (s *VMwareService) RestoreVMsWithPasswordRotation(ctx context.Context, vmNames []string, userNames []string, snapshotName string) ([]string, map[string]string)
RestoreVMsWithPasswordRotation restores VMs and rotates ESXi user passwords
func (*VMwareService) RotateESXiUserPassword ¶
func (s *VMwareService) RotateESXiUserPassword(ctx context.Context, host *object.HostSystem, username string) (string, error)
RotateESXiUserPassword rotates the password for an ESXi local user
type WireGuardConfig ¶
type WireGuardConfig struct {
Enabled bool `toml:"enabled"`
ServerPublicKey string `toml:"server_public_key"`
ServerEndpoint string `toml:"server_endpoint"`
ServerTunnelNetwork string `toml:"server_tunnel_network"`
AllowedIPs []string `toml:"allowed_ips"`
MTU int `toml:"mtu"`
ClientAddresses []string `toml:"client_addresses"`
Keepalive int `toml:"keepalive"`
OPNsenseURL string `toml:"opnsense_url"`
OPNsenseAPIKey string `toml:"-"`
OPNsenseAPISecret string `toml:"-"`
OPNsenseInsecure bool `toml:"opnsense_insecure"`
AutoRegisterPeers bool `toml:"auto_register_peers"`
}
WireGuardConfig holds tunnel settings from user_config.toml. OPNsense API credentials come from .env (OPNSENSE_API_KEY, OPNSENSE_API_SECRET).
type WireGuardManager ¶
type WireGuardManager interface {
RotateUserKey(username string) (privateKey, publicKey string, err error)
GenerateClientConfig(username string, userIndex int) (string, error)
ValidateConfig() error
RegisterPeerWithOPNsense(username, publicKey string, userIndex int) error
}
WireGuardManager abstracts WireGuard operations for testability.
type WireGuardService ¶
type WireGuardService struct {
// contains filtered or unexported fields
}
func NewWireGuardService ¶
func NewWireGuardService(config *WireGuardConfig, opnsense OPNsenseAPI) *WireGuardService
func (*WireGuardService) GenerateClientConfig ¶
func (w *WireGuardService) GenerateClientConfig(username string, userIndex int) (string, error)
GenerateClientConfig generates a WireGuard client configuration file content
func (*WireGuardService) RegisterPeerWithOPNsense ¶
func (w *WireGuardService) RegisterPeerWithOPNsense(username string, publicKey string, userIndex int) error
RegisterPeerWithOPNsense updates an existing peer's public key by tunnel address.
func (*WireGuardService) RotateUserKey ¶
func (w *WireGuardService) RotateUserKey(username string) (privateKey, publicKey string, err error)
RotateUserKey generates a new WireGuard key pair for a user
func (*WireGuardService) ValidateConfig ¶
func (w *WireGuardService) ValidateConfig() error
ValidateConfig validates the WireGuard configuration