driver

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Rendered for windows/amd64

Index

Constants

View Source
const AdapterNameMax = 128

Variables

This section is empty.

Functions

func RunningVersion

func RunningVersion() (version uint32, err error)

RunningVersion returns the version of the loaded driver.

func Uninstall added in v0.4.11

func Uninstall() (err error)

Uninstall removes the driver from the system if no drivers are currently in use.

func UninstallLegacyWintun added in v0.5.3

func UninstallLegacyWintun() error

func Version added in v0.5.3

func Version() string

Version returns the version of the driver DLL.

Types

type Adapter

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

func CreateAdapter added in v0.4.11

func CreateAdapter(name, tunnelType string, requestedGUID *windows.GUID) (wireguard *Adapter, err error)

CreateAdapter creates a WireGuard adapter. name is the cosmetic name of the adapter. tunnelType represents the type of adapter and should be "WireGuard". requestedGUID is the GUID of the created network adapter, which then influences NLA generation deterministically. If it is set to nil, the GUID is chosen by the system at random, and hence a new NLA entry is created for each new adapter.

func OpenAdapter added in v0.4.11

func OpenAdapter(name string) (wireguard *Adapter, err error)

OpenAdapter opens an existing WireGuard adapter by name.

func (*Adapter) AdapterState

func (wireguard *Adapter) AdapterState() (adapterState AdapterState, err error)

AdapterState returns the current state of the adapter.

func (*Adapter) Close added in v0.4.11

func (wireguard *Adapter) Close() (err error)

Close closes a WireGuard adapter.

func (*Adapter) Configuration

func (wireguard *Adapter) Configuration() (interfaze *Interface, err error)

Configuration gets the adapter configuration.

func (*Adapter) LUID

func (wireguard *Adapter) LUID() (luid winipcfg.LUID)

LUID returns the LUID of the adapter.

func (*Adapter) SetAdapterState

func (wireguard *Adapter) SetAdapterState(adapterState AdapterState) (err error)

SetAdapterState sets the adapter either Up or Down.

func (*Adapter) SetConfiguration

func (wireguard *Adapter) SetConfiguration(interfaze *Interface, size uint32) (err error)

SetConfiguration sets the adapter configuration.

func (*Adapter) SetLogging

func (wireguard *Adapter) SetLogging(logState AdapterLogState) (err error)

SetLogging enables or disables logging on the WireGuard adapter.

type AdapterLogState

type AdapterLogState uint32
const (
	AdapterLogOff          AdapterLogState = 0
	AdapterLogOn           AdapterLogState = 1
	AdapterLogOnWithPrefix AdapterLogState = 2
)

type AdapterState

type AdapterState uint32
const (
	AdapterStateDown AdapterState = 0
	AdapterStateUp   AdapterState = 1
)

type AllowedIP

type AllowedIP struct {
	Address       [16]byte
	AddressFamily winipcfg.AddressFamily
	Cidr          uint8
	// contains filtered or unexported fields
}

func (*AllowedIP) NextAllowedIP

func (allowedIP *AllowedIP) NextAllowedIP() *AllowedIP

NextAllowedIP returns the subsequent allowed IP of the current one.

type ConfigBuilder

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

func (*ConfigBuilder) AppendAllowedIP

func (builder *ConfigBuilder) AppendAllowedIP(allowedIP *AllowedIP)

AppendAllowedIP appends an allowed IP to the building configuration. This should be called after a peer has been added.

func (*ConfigBuilder) AppendInterface

func (builder *ConfigBuilder) AppendInterface(interfaze *Interface)

AppendInterface appends an interface to the building configuration. This should be called first.

func (*ConfigBuilder) AppendPeer

func (builder *ConfigBuilder) AppendPeer(peer *Peer)

AppendPeer appends a peer to the building configuration. This should be called after an interface has been added.

func (*ConfigBuilder) Interface

func (builder *ConfigBuilder) Interface() (*Interface, uint32)

Interface assembles the configuration and returns the interface and length to be passed to SetConfiguration.

func (*ConfigBuilder) Preallocate

func (builder *ConfigBuilder) Preallocate(size uint32)

Preallocate reserves memory in the config builder to reduce allocations of append operations.

type Interface

type Interface struct {
	Flags      InterfaceFlag
	ListenPort uint16
	PrivateKey [32]byte
	PublicKey  [32]byte
	PeerCount  uint32
	// contains filtered or unexported fields
}

func (*Interface) FirstPeer

func (interfaze *Interface) FirstPeer() *Peer

FirstPeer returns the first peer attached to the interface.

type InterfaceFlag

type InterfaceFlag uint32
const (
	InterfaceHasPublicKey  InterfaceFlag = 1 << 0
	InterfaceHasPrivateKey InterfaceFlag = 1 << 1
	InterfaceHasListenPort InterfaceFlag = 1 << 2
	InterfaceReplacePeers  InterfaceFlag = 1 << 3
)

type Peer

type Peer struct {
	Flags PeerFlag

	PublicKey           [32]byte
	PresharedKey        [32]byte
	PersistentKeepalive uint16

	Endpoint        winipcfg.RawSockaddrInet
	TxBytes         uint64
	RxBytes         uint64
	LastHandshake   uint64
	AllowedIPsCount uint32
	// contains filtered or unexported fields
}

func (*Peer) FirstAllowedIP

func (peer *Peer) FirstAllowedIP() *AllowedIP

FirstAllowedIP returns the first allowed IP attached to the peer.

func (*Peer) NextPeer

func (peer *Peer) NextPeer() *Peer

NextPeer returns the subsequent peer of the current one.

type PeerFlag

type PeerFlag uint32
const (
	PeerHasPublicKey           PeerFlag = 1 << 0
	PeerHasPresharedKey        PeerFlag = 1 << 1
	PeerHasPersistentKeepalive PeerFlag = 1 << 2
	PeerHasEndpoint            PeerFlag = 1 << 3
	PeerReplaceAllowedIPs      PeerFlag = 1 << 5
	PeerRemove                 PeerFlag = 1 << 6
	PeerUpdateOnly             PeerFlag = 1 << 7
)

type TimestampedWriter added in v0.5.3

type TimestampedWriter interface {
	WriteWithTimestamp(p []byte, ts int64) (n int, err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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