service

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

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 10 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")
	ErrFilepathNotSet      = errors.New("file path not set")
	ErrInterfaceNotSet     = errors.New("interface not set")
)

Functions

This section is empty.

Types

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) (
		port 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)
}

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, puid, pgid int) *Service

func (*Service) GetPortForwarded

func (s *Service) GetPortForwarded() (port 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
	Interface      string // needed for PIA and ProtonVPN, tun0 for example
	ServerName     string // needed for PIA
	CanPortForward bool   // needed for PIA
	ListeningPort  uint16
}

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