wireguard

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2020 License: GPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTooManyPeers = errors.New("multiple peers on a single wireguard device")
	ErrDpdTimeout   = errors.New("dpd timeout")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Name                 string        `yaml:"name,omitempty"`                 // Interface name to use for the created WireGuard interface
	ListenPort           int           `yaml:"listenPort,omitempty"`           // Local UDP listen/bind port - 0 for automatic
	FirewallMark         int           `yaml:"firewallMark,omitempty"`         // Firewall mark for the traffic generated by the wireguard module
	PrivateKey           string        `yaml:"privateKey,omitempty"`           // Explicitly specified private key
	RoutingTable         int           `yaml:"routingTable,omitempty"`         // Routing table number to operate on when managing wireguard routes
	LeakProtection       bool          `yaml:"leakProtection,omitempty"`       // Enable or disable leak protection ( loopback routes )
	ResolvConfBackupFile string        `yaml:"resolvConfBackupFile,omitempty"` // Name of the resolv.conf backup file
	DpdTimeout           time.Duration `yaml:"dpdTimeout,omitempty"`           // DPD timeout
	SplitTunnel          string        `yaml:"splitTunnel,omitempty"`          // A comma separated list of networks (CIDRs) for which to bypass the wireguard tunnel ( Split-Tunneling )
}
type Link struct {
	Config
	// contains filtered or unexported fields
}
func NewLink(config Config) *Link

func (*Link) Acct

func (l *Link) Acct() (rxBytes, txBytes int64, err error)

Get the traffic counters

func (*Link) Close

func (l *Link) Close()

Close the wireguard interface

func (*Link) DPD

func (l *Link) DPD(ctx context.Context) error

func (*Link) Down

func (l *Link) Down() (err error)

Removes the wireguard peer and un-routes it

func (*Link) LoopbackRoutesAdd

func (l *Link) LoopbackRoutesAdd() (err error)

Add loopback default routes to l.Config.RoutingTable table

func (*Link) LoopbackRoutesDel

func (l *Link) LoopbackRoutesDel()

Remove default routes from l.Config.RoutingTable table

func (*Link) Open

func (l *Link) Open() (err error)

Open the wireguard link, i.e. create or open an existing wireguard interface

func (*Link) PublicKey

func (l *Link) PublicKey() wgtypes.Key

func (*Link) RulesAdd

func (l *Link) RulesAdd() (err error)

func (*Link) RulesDel

func (l *Link) RulesDel()

func (*Link) Up

func (l *Link) Up(response *rest.ConnectResponse) (err error)

Adds a wireguard peer and routes it

Jump to

Keyboard shortcuts

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