vpn

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: GPL-3.0 Imports: 44 Imported by: 0

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

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

func ActiveServer(ctx context.Context) (group, tag string, err 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 Disconnect

func Disconnect() error

Disconnect closes the tunnel and all active connections.

func InitIPC

func InitIPC(basePath string, provider func() libbox.PlatformInterface) (*ipc.Server, error)

InitIPC starts the long-lived IPC server and hooks it up to establishConnection

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

type AutoSelections struct {
	Lantern string
	User    string
	AutoAll string
}

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 Filter struct {
	Domain           []string
	DomainSuffix     []string
	DomainKeyword    []string
	DomainRegex      []string
	ProcessName      []string
	ProcessPath      []string
	ProcessPathRegex []string
	PackageName      []string
}

func (Filter) String

func (f Filter) String() string

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.

func GetStatus

func GetStatus() (Status, error)

Directories

Path Synopsis
Package ipc implements the IPC server for communicating between the client and the VPN service.
Package ipc implements the IPC server for communicating between the client and the VPN service.

Jump to

Keyboard shortcuts

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