wgapi

package
v0.0.0-...-f611d03 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 12 Imported by: 1

Documentation

Overview

Package wgapi helps with communicating with the userspace wireguard module. Since wireguard-go uses a text based configuration this helps with programmatically creating and reading a config. Please consult wireguard cross-platform documentation for more information on configuration values.

Index

Constants

View Source
const (
	// ErrnoNone means no error occurred
	ErrnoNone = Errno(0)
	// ErrnoIO references [ipc.IpcErrorIO].
	ErrnoIO = Errno(ipc.IpcErrorIO)
	// ErrnoProtocol references [ipc.IpcErrorProtocol].
	ErrnoProtocol = Errno(ipc.IpcErrorProtocol)
	// ErrnoInvalid references [ipc.IpcErrorInvalid].
	ErrnoInvalid = Errno(ipc.IpcErrorInvalid)
	// ErrnoPortInUse references [ipc.IpcErrorPortInUse].
	ErrnoPortInUse = Errno(ipc.IpcErrorPortInUse)
	// ErrnoUnknown references [ipc.IpcErrorUnknown].
	ErrnoUnknown = Errno(int64(ipc.IpcErrorUnknown))
)

Variables

This section is empty.

Functions

func NewPrivatePublic

func NewPrivatePublic() (private PrivateKey, public PublicKey, err error)

NewPrivatePublic generates a new private key and also returns its corresponding public key.

Types

type AllowedIP

type AllowedIP = value.IPNet[key.AllowedIP]

AllowedIP is an address allowed to communicate in the tunnel.

var EmptySubnet AllowedIP

EmptySubnet is the 0.0.0.0/0 subnet

func IdentitySubnet

func IdentitySubnet(ip net.IP) AllowedIP

IdentitySubnet converts an IP (v4 or v6) to ipv6/128.

type Configurable

type Configurable interface {
	WGConfig() io.Reader
}

Configurable is something that can be converted into a reader that supplies 'key=value\n' values corresponding to the wireguard userspace configuration [wireguard cross-platform documentation].

type Endpoint

type Endpoint = value.UDPAddr[key.Endpoint]

Endpoint is the address:port of a wireguard server

type Errno

type Errno = value.Int64[key.Errno]

Errno is an error returned by the IPC.

type FWMark

type FWMark = value.Uint32[key.FWMark]

FWMark configures the interface as specified in [wireguard cross-platform documentation]. The special value 0 clears the FWMark.

type Get

type Get = value.One[key.Get]

Get specifies a get operation. Not used unless communicating with an external endpoint.

type IPC

type IPC []IPCKeyValue

IPC is an IPC operation as documented by [wireguard cross-platform documentation].

func (IPC) WGConfig

func (ir IPC) WGConfig() io.Reader

type IPCGet

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

IPCGet is used to help get information from a wireguard userspace configuration as documented in [wireguard cross-platform documentation].

func (*IPCGet) Reset

func (get *IPCGet) Reset()

Reset allows this to be reused for another operation. Without calling this IPCGet.Value will only return the data from the first time this was used.

func (*IPCGet) Value

func (get *IPCGet) Value() (IPC, error)

Value converts the text data into an IPC.

func (*IPCGet) Write

func (get *IPCGet) Write(b []byte) (int, error)

Write is used to write 'key=value\n' lines from the wireguard IPC.

type IPCKeyValue

type IPCKeyValue = internal.KeyValue

IPCKeyValue is string key and value pair. The value is represented by fmt.Stringer.

type LastHandshakeTimeNSec

type LastHandshakeTimeNSec = value.Int64[key.LastHandshakeTimeNSec]

LastHandshakeTimeNSec is the nanoseconds resolution of the last handshake relative to unix epoch.

type LastHandshakeTimeSec

type LastHandshakeTimeSec = value.Int64[key.LastHandshakeTimeSec]

LastHandshakeTimeSec is the seconds since the last handshake relative to unix epoch.

type ListenPort

type ListenPort = value.Uint16[key.ListenPort]

ListenPort is the system port used to listen for wireguard traffic.

const DefaultListenPort ListenPort = 51820

DefaultListenPort is the default wireguard server port.

type PersistentKeepalive

type PersistentKeepalive = value.Uint16[key.PersistentKeepalive]

PersistentKeepalive is the interval to send a persistent keepalive packet. Special value 0 disables this.

const DefaultPersistentKeepalive PersistentKeepalive = 25

DefaultPersistentKeepalive is the default persistent keepalive interval.

type PresharedKey

type PresharedKey = value.Key[key.PresharedKey, wgkey.PreShared]

PresharedKey is a preshared key usable by the IPC.

func NewPreshared

func NewPreshared() (PresharedKey, error)

NewPreshared generates a new preshared key.

type PrivateKey

type PrivateKey = value.Key[key.PrivateKey, wgkey.Private]

PrivateKey is a private key usable by the IPC.

func NewPrivate

func NewPrivate() (PrivateKey, error)

NewPrivate generates a new private key.

type ProtocolVersion

type ProtocolVersion = value.One[key.ProtocolVersion]

ProtocolVersion is the version of the protocol. Generally not used.

type PublicKey

type PublicKey = value.Key[key.PublicKey, wgkey.Public]

PublicKey is a public key usable by the IPC.

type RXBytes

type RXBytes = value.Uint64[key.RXBytes]

RXBytes are the number of received bytes. Only present in a get operation.

type Remove

type Remove = value.True[key.Remove]

Remove removes the peer.

type ReplaceAllowedIPs

type ReplaceAllowedIPs = value.True[key.ReplaceAllowedIPs]

ReplaceAllowedIPs replaces the current allowed IPs instead of appending.

type ReplacePeers

type ReplacePeers = value.True[key.ReplacePeers]

ReplacePeers replaces all the peers.

type Set

type Set = value.One[key.Set]

Set specifies a set operation. Not used unless communicating with an external endpoint.

type TXBytes

type TXBytes = value.Uint64[key.TXBytes]

TXBytes are the number of transferred bytes. Only present in a get operation.

type UpdateOnly

type UpdateOnly = value.True[key.UpdateOnly]

UpdateOnly only updates the peer if it is already present.

Directories

Path Synopsis
key
Package wgconfig has examples for simple client and server configuration.
Package wgconfig has examples for simple client and server configuration.

Jump to

Keyboard shortcuts

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