Documentation
¶
Overview ¶
Package vpn provides high-level management of VPN tunnels, including connecting to the best available server, connecting to specific servers, disconnecting, reconnecting, and querying tunnel status.
Index ¶
- Constants
- func ActiveConnections(ctx context.Context) ([]ipc.Connection, error)
- func ActiveServer(ctx context.Context) (group, tag string, err error)
- func AutoSelectionsChangeListener(ctx context.Context, pollInterval time.Duration) <-chan AutoSelections
- func ConnectToServer(group, tag string, platIfce libbox.PlatformInterface) error
- func Connections(ctx context.Context) ([]ipc.Connection, error)
- func Disconnect() error
- func InitIPC(basePath string, provider func() libbox.PlatformInterface) (*ipc.Server, error)
- func QuickConnect(group string, platIfce libbox.PlatformInterface) (err error)
- func Reconnect(platIfce libbox.PlatformInterface) error
- type AutoSelections
- type Filter
- type SplitTunnel
- func (s *SplitTunnel) AddItem(filterType, item string) error
- func (s *SplitTunnel) AddItems(items Filter) error
- func (s *SplitTunnel) Disable() error
- func (s *SplitTunnel) Enable() error
- func (s *SplitTunnel) Filters() Filter
- func (s *SplitTunnel) IsEnabled() bool
- func (s *SplitTunnel) RemoveItem(filterType, item string) error
- func (s *SplitTunnel) RemoveItems(items Filter) error
- type Status
Constants ¶
const ( TypeDomain = "domain" TypeDomainSuffix = "domainSuffix" TypeDomainKeyword = "domainKeyword" TypeDomainRegex = "domainRegex" TypeProcessName = "processName" TypeProcessPath = "processPath" TypeProcessPathRegex = "processPathRegex" TypePackageName = "packageName" )
Variables ¶
This section is empty.
Functions ¶
func ActiveConnections ¶
func ActiveConnections(ctx context.Context) ([]ipc.Connection, error)
ActiveConnections returns a list of currently active connections, ordered from newest to oldest. A non-nil error is only returned if there was an error retrieving the connections, or if the tunnel is closed. If there are no active connections and the tunnel is open, an empty slice is returned without an error.
func AutoSelectionsChangeListener ¶
func AutoSelectionsChangeListener(ctx context.Context, pollInterval time.Duration) <-chan AutoSelections
AutoSelectionsChangeListener returns a channel that receives a signal whenever any auto selection changes until the context is cancelled.
func ConnectToServer ¶
func ConnectToServer(group, tag string, platIfce libbox.PlatformInterface) error
ConnectToServer connects to a specific server identified by the group and tag. Valid groups are servers.SGLantern and servers.SGUser.
func Connections ¶
func Connections(ctx context.Context) ([]ipc.Connection, error)
Connections returns a list of all connections, both active and recently closed. A non-nil error is only returned if there was an error retrieving the connections, or if the tunnel is closed. If there are no connections and the tunnel is open, an empty slice is returned without an error.
func QuickConnect ¶
func QuickConnect(group string, platIfce libbox.PlatformInterface) (err error)
QuickConnect automatically connects to the best available server in the specified group. Valid groups are servers.ServerGroupLantern, servers.ServerGroupUser, "all", or the empty string. Using "all" or the empty string will connect to the best available server across all groups.
func Reconnect ¶
func Reconnect(platIfce libbox.PlatformInterface) error
Reconnect attempts to reconnect to the last connected server.
Types ¶
type AutoSelections ¶
AutoSelections represents the currently active servers for each auto server group.
func AutoServerSelections ¶
func AutoServerSelections() (AutoSelections, error)
AutoServerSelections returns the currently active server for each auto server group. If the group is not found or has no active server, "Unavailable" is returned for that group.
type Filter ¶
type SplitTunnel ¶
type SplitTunnel struct {
// contains filtered or unexported fields
}
SplitTunnel manages the split tunneling feature, allowing users to specify which domains, processes, or packages should bypass the VPN tunnel.
func NewSplitTunnelHandler ¶
func NewSplitTunnelHandler() (*SplitTunnel, error)
func (*SplitTunnel) AddItem ¶
func (s *SplitTunnel) AddItem(filterType, item string) error
AddItem adds a new item to the filter of the given type.
func (*SplitTunnel) AddItems ¶
func (s *SplitTunnel) AddItems(items Filter) error
AddItems adds multiple items to the filter.
func (*SplitTunnel) Disable ¶
func (s *SplitTunnel) Disable() error
func (*SplitTunnel) Enable ¶
func (s *SplitTunnel) Enable() error
func (*SplitTunnel) Filters ¶
func (s *SplitTunnel) Filters() Filter
func (*SplitTunnel) IsEnabled ¶
func (s *SplitTunnel) IsEnabled() bool
func (*SplitTunnel) RemoveItem ¶
func (s *SplitTunnel) RemoveItem(filterType, item string) error
RemoveItem removes an item from the filter of the given type.
func (*SplitTunnel) RemoveItems ¶
func (s *SplitTunnel) RemoveItems(items Filter) error
RemoveItems removes multiple items from the filter.
type Status ¶
type Status struct {
TunnelOpen bool
// SelectedServer is the server that is currently selected for the tunnel.
SelectedServer string
// ActiveServer is the server that is currently active for the tunnel. This will differ from
// SelectedServer if using auto-select mode.
ActiveServer string
}
Status represents the current status of the tunnel, including whether it is open, the selected server, and the active server. Active is only set if the tunnel is open.