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
- Variables
- 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 = Errno(0) ErrnoIO = Errno(ipc.IpcErrorIO) ErrnoProtocol = Errno(ipc.IpcErrorProtocol) ErrnoInvalid = Errno(ipc.IpcErrorInvalid) ErrnoPortInUse = Errno(ipc.IpcErrorPortInUse) ErrnoUnknown = Errno(int64(ipc.IpcErrorUnknown)) )
Variables ¶
var EmptySubnet = parseAllowedIP("0.0.0.0/0")
EmptySubnet represents a subnet configuration that permits all IP addresses. It's defined by setting the allowed IP range to '0.0.0.0/0', which effectively means there are no restrictions on the IP addresses allowed through this subnet. It's typically used in VPN configurations to indicate that all traffic should be routed through the VPN.
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.
func IdentitySubnet ¶
IdentitySubnet takes an IP address (either IPv4 or IPv6) and returns it as an IPv6 address with a subnet mask of /128. This effectively identifies a single address, as a /128 mask specifies all 128 bits of the IPv6 address, leaving no room for a range of addresses.
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 the 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
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
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.
Directories ¶
Path | Synopsis |
---|---|
Package internal contains packages that assist with wireguard types.
|
Package internal contains packages that assist with wireguard types. |
key
Package keys contains the keys used by the wireguard-go ipc.
|
Package keys contains the keys used by the wireguard-go ipc. |
parser
Package parser contains functions that assist with parsing a wireguard-go ipc response.
|
Package parser contains functions that assist with parsing a wireguard-go ipc response. |
value
Package value manages key-value pairs, conforming to the [internal.KeyValue] interface.
|
Package value manages key-value pairs, conforming to the [internal.KeyValue] interface. |
value/wgkey
Package wgkey holds basic types for wireguard keys.
|
Package wgkey holds basic types for wireguard keys. |
Package wgconfig provides examples of simple client and server configurations using the WireGuard API.
|
Package wgconfig provides examples of simple client and server configurations using the WireGuard API. |