connection

package
v0.0.0-...-365054f Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConnection

func NewConnection(opts Options, ipResolver ip.Resolver, endpointFactory wg.EndpointFactory, handshakeWaiter HandshakeWaiter) (connection.Connection, error)

NewConnection returns new WireGuard connection.

Types

type Connection

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

Connection which does wireguard tunneling.

func (*Connection) GetConfig

func (c *Connection) GetConfig() (connection.ConsumerConfig, error)

GetConfig returns the consumer configuration for session creation

func (*Connection) Reconnect

func (c *Connection) Reconnect(ctx context.Context, options connection.ConnectOptions) error

Reconnect restarts a connection with a new options.

func (*Connection) Start

func (c *Connection) Start(ctx context.Context, options connection.ConnectOptions) error

Start establish wireguard connection to the service provider.

func (*Connection) State

func (c *Connection) State() <-chan connectionstate.State

State returns connection state channel.

func (*Connection) Statistics

func (c *Connection) Statistics() (connectionstate.Statistics, error)

Statistics returns connection statistics channel.

func (*Connection) Stop

func (c *Connection) Stop()

Stop stops wireguard connection and closes connection endpoint.

type HandshakeWaiter

type HandshakeWaiter interface {
	// Wait waits until WireGuard does initial handshake.
	Wait(ctx context.Context, statsFetch func() (wgcfg.Stats, error), timeout time.Duration, stop <-chan struct{}) error
}

HandshakeWaiter waits for handshake.

func NewHandshakeWaiter

func NewHandshakeWaiter() HandshakeWaiter

NewHandshakeWaiter returns handshake waiter instance.

type Options

type Options struct {
	DNSScriptDir     string
	HandshakeTimeout time.Duration
}

Options represents connection options.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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