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
- func NewPrivatePublic() (private PrivateKey, public PublicKey, err error)
- type AllowedIP
- type Configurable
- type Endpoint
- type Errno
- type FWMark
- type Get
- type IPC
- type IPCGet
- type IPCKeyValue
- type LastHandshakeTimeNSec
- type LastHandshakeTimeSec
- type ListenPort
- type PersistentKeepalive
- type PresharedKey
- type PrivateKey
- type ProtocolVersion
- type PublicKey
- type RXBytes
- type Remove
- type ReplaceAllowedIPs
- type ReplacePeers
- type Set
- type TXBytes
- type UpdateOnly
Constants ¶
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 ¶
AllowedIP is an address allowed to communicate in the tunnel.
var EmptySubnet AllowedIP
EmptySubnet is the 0.0.0.0/0 subnet
func IdentitySubnet ¶
IdentitySubnet converts an IP (v4 or v6) to ipv6/128.
type Configurable ¶
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 FWMark ¶
FWMark configures the interface as specified in [wireguard cross-platform documentation]. The special value 0 clears the FWMark.
type IPC ¶
type IPC []IPCKeyValue
IPC is an IPC operation as documented by [wireguard cross-platform documentation].
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.
type IPCKeyValue ¶
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 ¶
PresharedKey is a preshared key usable by the IPC.
func NewPreshared ¶
func NewPreshared() (PresharedKey, error)
NewPreshared generates a new preshared key.
type PrivateKey ¶
PrivateKey is a private key usable by the IPC.
type ProtocolVersion ¶
type ProtocolVersion = value.One[key.ProtocolVersion]
ProtocolVersion is the version of the protocol. Generally not used.
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 UpdateOnly ¶
type UpdateOnly = value.True[key.UpdateOnly]
UpdateOnly only updates the peer if it is already present.