Documentation
¶
Index ¶
- Constants
- func GetTunnelName() string
- func RunTunnelService(configJSON string) error
- func SetInstallTunnelCallback(fn func(string) error)
- func SetState(state State)
- func SetStateChangeCallback(cb func(State))
- func SetUninstallTunnelCallback(fn func(string) error)
- func StartTunnel(config Config) error
- func StopTunnel() error
- type Config
- type ConnectionError
- type IPCClient
- type Manager
- func (tm *Manager) Close()
- func (tm *Manager) Connect() error
- func (tm *Manager) Disconnect() error
- func (tm *Manager) GetOLMStatus() (*OLMStatusResponse, error)
- func (tm *Manager) IsConnected() bool
- func (tm *Manager) RegisterErrorCallback(cb func(*OLMStatusError))
- func (tm *Manager) RegisterStateChangeCallback(cb func(State))
- func (tm *Manager) StartStatusPolling()
- func (tm *Manager) State() State
- func (tm *Manager) StopStatusPolling()
- func (tm *Manager) SwitchOLMOrg(orgID string) error
- type OLMPeerStatus
- type OLMStatusError
- type OLMStatusResponse
- type State
- type SwitchOrgRequest
Constants ¶
const OLMNamedPipePath = `\\.\pipe\pangolin-olm`
OLMNamedPipePath is the Windows named pipe path for OLM API communication
Variables ¶
This section is empty.
Functions ¶
func GetTunnelName ¶
func GetTunnelName() string
GetTunnelName returns the name of the currently active tunnel
func RunTunnelService ¶
RunTunnelService runs the tunnel as a Windows service Tunnels are always started via the UI and run as Windows services
func SetStateChangeCallback ¶
func SetStateChangeCallback(cb func(State))
SetStateChangeCallback sets a callback that will be called when tunnel state changes
func StartTunnel ¶
func StopTunnel ¶
func StopTunnel() error
Types ¶
type Config ¶
type Config struct {
Name string `json:"name"` // for Windows service name
Endpoint string `json:"endpoint"`
ID string `json:"id"`
Secret string `json:"secret"`
MTU int `json:"mtu"`
DNS string `json:"dns"`
Holepunch bool `json:"holepunch"`
PingIntervalSeconds int `json:"pingIntervalSeconds"`
PingTimeoutSeconds int `json:"pingTimeoutSeconds"`
UserToken string `json:"userToken"`
OrgID string `json:"orgId"`
InterfaceName string `json:"interfaceName"`
UpstreamDNS []string `json:"upstreamDns"`
OverrideDNS bool `json:"overrideDns"`
TunnelDNS bool `json:"tunnelDns"`
}
Config represents the tunnel configuration
func ConfigFromJSON ¶
ConfigFromJSON parses a JSON string into a Config struct
type ConnectionError ¶
ConnectionError represents a connection error with a user-friendly message
func (*ConnectionError) Error ¶
func (e *ConnectionError) Error() string
type IPCClient ¶
type IPCClient interface {
StartTunnel(config Config) error
StopTunnel() error
RegisterStateChangeCallback(cb func(State)) func() // Returns unregister function
}
IPCClient provides an interface for IPC operations needed by the tunnel manager This avoids circular dependencies between tunnel and managers packages
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages tunnel connection state and operations It provides a simplified API for the UI layer, abstracting away IPC details
func NewManager ¶
func NewManager( authManager *auth.AuthManager, configManager *config.ConfigManager, accountManager *config.AccountManager, secretManager *secrets.SecretManager, ipcClient IPCClient, ) *Manager
NewManager creates a new Manager instance
func (*Manager) GetOLMStatus ¶
func (tm *Manager) GetOLMStatus() (*OLMStatusResponse, error)
GetOLMStatus retrieves the status from OLM via the named pipe API
func (*Manager) IsConnected ¶
IsConnected returns whether the tunnel is currently connected
func (*Manager) RegisterErrorCallback ¶
func (tm *Manager) RegisterErrorCallback(cb func(*OLMStatusError))
RegisterErrorCallback registers a callback that will be called when an error is detected in OLM status
func (*Manager) RegisterStateChangeCallback ¶
RegisterStateChangeCallback registers a callback that will be called when tunnel state changes
func (*Manager) StartStatusPolling ¶
func (tm *Manager) StartStatusPolling()
StartStatusPolling starts polling the OLM status endpoint every 1 second
func (*Manager) StopStatusPolling ¶
func (tm *Manager) StopStatusPolling()
StopStatusPolling stops the status polling
func (*Manager) SwitchOLMOrg ¶
SwitchOLMOrg switches the organization in OLM via the named pipe API
type OLMPeerStatus ¶
type OLMPeerStatus struct {
SiteID int `json:"siteId"`
SiteName string `json:"name"`
Connected bool `json:"connected"`
RTT time.Duration `json:"rtt"`
LastSeen time.Time `json:"lastSeen"`
Endpoint string `json:"endpoint,omitempty"`
IsRelay bool `json:"isRelay"`
PeerIP string `json:"peerAddress,omitempty"`
}
OLMPeerStatus represents the status of a peer connection
type OLMStatusError ¶
OLMStatusError represents an error in the OLM status response
type OLMStatusResponse ¶
type OLMStatusResponse struct {
Connected bool `json:"connected"`
Registered bool `json:"registered"`
Terminated bool `json:"terminated"`
Version string `json:"version,omitempty"`
Agent string `json:"agent,omitempty"`
OrgID string `json:"orgId,omitempty"`
PeerStatuses map[int]*OLMPeerStatus `json:"peers,omitempty"`
NetworkSettings map[string]interface{} `json:"networkSettings,omitempty"`
Error *OLMStatusError `json:"error,omitempty"`
}
OLMStatusResponse represents the status response from OLM API
type State ¶
type State int
State represents the state of a tunnel
func (State) DisplayText ¶
DisplayText returns a human-readable display text for the tunnel state
type SwitchOrgRequest ¶
type SwitchOrgRequest struct {
OrgID string `json:"org_id"`
}
SwitchOrgRequest represents the request body for switching organizations