wireguard

package
v0.0.0-...-23a443e Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RouteProto = 157
)

Variables

View Source
var ErrNotWireguard = errors.New("named link is not a wireguard tunnel")

Functions

This section is empty.

Types

type AddrScope

type AddrScope int
const (
	ScopeGlobal AddrScope = unix.RT_SCOPE_UNIVERSE
	ScopeLink   AddrScope = unix.RT_SCOPE_LINK
)

type Address

type Address struct {
	net.IPNet
	Peer  *net.IPNet
	Scope AddrScope
}
type Link interface {
	Interface() net.Interface
	Name() string
	Index() int

	IsUp() bool
	SetUp(bool) error
	Addrs() ([]Address, error)
	DelAddr(a Address) error
	AddAddr(a Address) error

	ConfigureWG(wgtypes.Config) error
	WGConfig() (*wgtypes.Device, error)

	DialUDP(local, remote net.UDPAddr) (*net.UDPConn, error)
	ListenUDP(local net.UDPAddr) (*net.UDPConn, error)

	GetRoutes() ([]Route, error)
	AddRoute(Route) error
	DelRoute(Route) error
}

func CreateWG

func CreateWG(m Manager, name string, cfg wgtypes.Config, addrs []Address) (link Link, created bool, err error)

type LinkError

type LinkError struct {
	LinkName string
	E        error
}

func (LinkError) Error

func (err LinkError) Error() string

func (LinkError) Unwrap

func (err LinkError) Unwrap() error

type Manager

type Manager interface {
	Links() ([]Link, error)
	CreateLink(name string) (Link, error)
	DelLink(name string) error
	GetLink(name string) (Link, error)

	Close() error
}

func NewManager

func NewManager() (Manager, error)

type Route

type Route struct {
	Dest net.IPNet
	Src  net.IP
}

Jump to

Keyboard shortcuts

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