vpn

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DHCPNetworkService added in v0.8.6

func DHCPNetworkService(ip chan string, l log.StandardLogger, maxTime time.Duration, leasedir string, address string) node.NetworkService

DHCPNetworkService returns a DHCP network service

func Logger

func Logger(l log.StandardLogger) func(cfg *Config) error

func NetLinkBootstrap

func NetLinkBootstrap(b bool) func(cfg *Config) error

func Register added in v0.7.2

func Register(p ...Option) ([]node.Option, error)

Start the node and the vpn. Returns an error in case of failure When starting the vpn, there is no need to start the node

func VPNNetworkService added in v0.8.6

func VPNNetworkService(p ...Option) node.NetworkService

func WithInterface

func WithInterface(i io.ReadWriteCloser) func(cfg *Config) error

WithInterface sets a pre-created io.ReadWriteCloser as the tunnel interface, bypassing platform-specific interface creation entirely. When set, neither createInterface nor prepareInterface will be called. This is useful on platforms like Android where the TUN file descriptor is provided by the OS (e.g. via VpnService) and cannot be opened directly.

func WithInterfaceAddress

func WithInterfaceAddress(i string) func(cfg *Config) error

func WithInterfaceMTU

func WithInterfaceMTU(i int) func(cfg *Config) error

func WithInterfaceName

func WithInterfaceName(i string) func(cfg *Config) error

func WithInterfaceType

func WithInterfaceType(d water.DeviceType) func(cfg *Config) error

func WithLedgerAnnounceTime

func WithLedgerAnnounceTime(t time.Duration) func(cfg *Config) error

func WithMaxStreams added in v0.9.0

func WithMaxStreams(i int) func(cfg *Config) error

WithMaxStreams has no effect on the VPN, which keeps one stream per peer on the framed protocol and one per packet on the unframed one.

func WithPacketMTU

func WithPacketMTU(i int) func(cfg *Config) error

func WithRouterAddress

func WithRouterAddress(i string) func(cfg *Config) error

Types

type Config

type Config struct {
	Interface        io.ReadWriteCloser
	InterfaceName    string
	InterfaceAddress string
	RouterAddress    string
	InterfaceMTU     int
	MTU              int
	DeviceType       water.DeviceType

	LedgerAnnounceTime time.Duration
	Logger             log.StandardLogger

	NetLinkBootstrap bool

	// Frame timeout
	Timeout time.Duration

	Concurrency       int
	ChannelBufferSize int
	MaxStreams        int
	// contains filtered or unexported fields
}

func (*Config) Apply

func (cfg *Config) Apply(opts ...Option) error

Apply applies the given options to the config, returning the first error encountered (if any).

type Option

type Option func(cfg *Config) error
var LowProfile Option = func(cfg *Config) error {
	cfg.lowProfile = true

	return nil
}

LowProfile has no effect on the VPN, which keeps one stream per peer on the framed protocol whatever the profile.

func DHCP added in v0.8.1

func DHCP(l log.StandardLogger, maxTime time.Duration, leasedir string, address string) ([]node.Option, []Option)

DHCP returns a DHCP network service. It requires the Alive Service in order to determine available nodes. Nodes available are used to determine which needs an IP and when maxTime expires nodes are marked as offline and not considered.

func WithChannelBufferSize

func WithChannelBufferSize(i int) Option

func WithConcurrency

func WithConcurrency(i int) Option

func WithTimeout

func WithTimeout(s string) Option

Jump to

Keyboard shortcuts

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