service

package
v0.0.0-...-9933dd3 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPortForwarderNotSet = errors.New("port forwarder not set")
	ErrServerNameNotSet    = errors.New("server name not set")
	ErrUsernameNotSet      = errors.New("username not set")
	ErrPasswordNotSet      = errors.New("password not set")
	ErrFilepathNotSet      = errors.New("file path not set")
	ErrInterfaceNotSet     = errors.New("interface not set")
)

Functions

This section is empty.

Types

type Cmder

type Cmder interface {
	Start(cmd *exec.Cmd) (stdoutLines, stderrLines <-chan string,
		waitError <-chan error, startErr error)
}

type Logger

type Logger interface {
	Debug(s string)
	Info(s string)
	Warn(s string)
	Error(s string)
}

type PortAllower

type PortAllower interface {
	SetAllowedPort(ctx context.Context, port uint16, intf string) (err error)
	RemoveAllowedPort(ctx context.Context, port uint16) (err error)
	RedirectPort(ctx context.Context, intf string, sourcePort,
		destinationPort uint16) (err error)
}

type PortForwarder

type PortForwarder interface {
	Name() string
	PortForward(ctx context.Context, objects utils.PortForwardObjects) (
		ports []uint16, err error)
	KeepPortForward(ctx context.Context, objects utils.PortForwardObjects) (err error)
}

type Routing

type Routing interface {
	VPNLocalGatewayIP(vpnInterface string) (gateway netip.Addr, err error)
	AssignedIP(interfaceName string, family int) (ip netip.Addr, err error)
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(settings Settings, routing Routing, client *http.Client,
	portAllower PortAllower, logger Logger, cmder Cmder, puid, pgid int,
) *Service

func (*Service) GetPortsForwarded

func (s *Service) GetPortsForwarded() (ports []uint16)

func (*Service) Start

func (s *Service) Start(ctx context.Context) (runError <-chan error, err error)

func (*Service) Stop

func (s *Service) Stop() (err error)

type Settings

type Settings struct {
	Enabled        *bool
	PortForwarder  PortForwarder
	Filepath       string
	UpCommand      string
	DownCommand    string
	Interface      string // needed for PIA, PrivateVPN and ProtonVPN, tun0 for example
	ServerName     string // needed for PIA
	CanPortForward bool   // needed for PIA
	ListeningPort  uint16
	Username       string // needed for PIA
	Password       string // needed for PIA
}

func (Settings) Copy

func (s Settings) Copy() (copied Settings)

func (*Settings) OverrideWith

func (s *Settings) OverrideWith(update Settings)

func (*Settings) Validate

func (s *Settings) Validate(forStartup bool) (err error)

Jump to

Keyboard shortcuts

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