tunnel

package
v0.0.0-...-1cf95b6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Rendered for windows/amd64

Index

Constants

View Source
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

func RunTunnelService(configJSON string) error

RunTunnelService runs the tunnel as a Windows service Tunnels are always started via the UI and run as Windows services

func SetInstallTunnelCallback

func SetInstallTunnelCallback(fn func(string) error)

func SetState

func SetState(state State)

func SetStateChangeCallback

func SetStateChangeCallback(cb func(State))

SetStateChangeCallback sets a callback that will be called when tunnel state changes

func SetUninstallTunnelCallback

func SetUninstallTunnelCallback(fn func(string) error)

func StartTunnel

func StartTunnel(config Config) error

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

func ConfigFromJSON(jsonStr string) (Config, error)

ConfigFromJSON parses a JSON string into a Config struct

func (Config) ToJSON

func (c Config) ToJSON() (string, error)

ToJSON converts a Config struct to JSON string

type ConnectionError

type ConnectionError struct {
	Title   string
	Message string
	Err     error
}

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) Close

func (tm *Manager) Close()

Close cleans up resources used by the Manager

func (*Manager) Connect

func (tm *Manager) Connect() error

Connect starts the tunnel, building the configuration internally

func (*Manager) Disconnect

func (tm *Manager) Disconnect() error

Disconnect stops the tunnel

func (*Manager) GetOLMStatus

func (tm *Manager) GetOLMStatus() (*OLMStatusResponse, error)

GetOLMStatus retrieves the status from OLM via the named pipe API

func (*Manager) IsConnected

func (tm *Manager) IsConnected() bool

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

func (tm *Manager) RegisterStateChangeCallback(cb func(State))

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) State

func (tm *Manager) State() State

State returns the current tunnel state

func (*Manager) StopStatusPolling

func (tm *Manager) StopStatusPolling()

StopStatusPolling stops the status polling

func (*Manager) SwitchOLMOrg

func (tm *Manager) SwitchOLMOrg(orgID string) error

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

type OLMStatusError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

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

const (
	StateStopped State = iota
	StateStarting
	StateRegistering
	StateRegistered
	StateRunning
	StateReconnecting
	StateStopping
	StateInvalid
	StateError
)

func GetState

func GetState() State

func (State) DisplayText

func (s State) DisplayText() string

DisplayText returns a human-readable display text for the tunnel state

func (State) String

func (s State) String() string

String returns the string representation of the tunnel state

type SwitchOrgRequest

type SwitchOrgRequest struct {
	OrgID string `json:"org_id"`
}

SwitchOrgRequest represents the request body for switching organizations

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL