Documentation ¶
Overview ¶
Package wg provides various helpers for WireGuard
Index ¶
- Constants
- Variables
- func CleanupUserSockets() error
- func CmpDevices(a, b wgtypes.Device) int
- func CmpPeerHandshakeTime(a, b wgtypes.Peer) int
- func CmpPeers(a, b wgtypes.Peer) int
- func KernelModuleExists() bool
- func SetMark(conn net.PacketConn, mark uint32) error
- type Bind
- func (b *Bind) AddConn(conn net.PacketConn)
- func (b *Bind) AddOpenHandler(h BindHandler)
- func (b *Bind) AddPacketHandler(h netx.PacketHandler)
- func (b *Bind) BatchSize() int
- func (b *Bind) Close() error
- func (b *Bind) Endpoint(ap netip.AddrPort) *BindEndpoint
- func (b *Bind) Open(port uint16) ([]wgconn.ReceiveFunc, uint16, error)
- func (b *Bind) ParseEndpoint(s string) (ep wgconn.Endpoint, err error)
- func (b *Bind) RemoveOpenHandler(h BindHandler)
- func (b *Bind) RemovePacketHandler(h netx.PacketHandler)
- func (b *Bind) Send(packets [][]byte, cep wgconn.Endpoint) error
- func (b *Bind) SetMark(mark uint32) error
- type BindConn
- type BindEndpoint
- type BindHandler
- type BindKernelConn
- type Config
- type Interface
Constants ¶
const ( SocketPath = "/var/run/wireguard" ConfigPath = "/etc/wireguard" DefaultPort = 51820 TunnelOverhead = 80 // Byte DefaultMTU = 1500 - TunnelOverhead MinimalMTU = 1280 // Byte for minimal IPv6 MTU )
Variables ¶
var ErrNoConn = errors.New("no connection for endpoint")
Functions ¶
func CleanupUserSockets ¶
func CleanupUserSockets() error
func CmpDevices ¶
func CmpPeerHandshakeTime ¶
func KernelModuleExists ¶
func KernelModuleExists() bool
Types ¶
type Bind ¶
type Bind struct { Conns []BindConn // contains filtered or unexported fields }
func (*Bind) AddConn ¶
func (b *Bind) AddConn(conn net.PacketConn)
func (*Bind) AddOpenHandler ¶
func (b *Bind) AddOpenHandler(h BindHandler)
func (*Bind) AddPacketHandler ¶
func (b *Bind) AddPacketHandler(h netx.PacketHandler)
func (*Bind) BatchSize ¶
BatchSize is the number of buffers expected to be passed to the ReceiveFuncs, and the maximum expected to be passed to SendBatch. Implements wgconn.Bind
func (*Bind) Close ¶
Close closes the Bind listener. All fns returned by Open must return net.ErrClosed after a call to Close.
func (*Bind) Endpoint ¶
func (b *Bind) Endpoint(ap netip.AddrPort) *BindEndpoint
Endpoint returns an Endpoint containing ap.
func (*Bind) Open ¶
Open puts the Bind into a listening state on a given port and reports the actual port that it bound to. Passing zero results in a random selection. fns is the set of functions that will be called to receive packets.
func (*Bind) ParseEndpoint ¶
ParseEndpoint creates a new endpoint from a string. Implements wgconn.Bind
func (*Bind) RemoveOpenHandler ¶
func (b *Bind) RemoveOpenHandler(h BindHandler)
func (*Bind) RemovePacketHandler ¶
func (b *Bind) RemovePacketHandler(h netx.PacketHandler)
type BindEndpoint ¶
func (BindEndpoint) ClearSrc ¶
func (BindEndpoint) ClearSrc()
func (BindEndpoint) DstIP ¶
func (ep BindEndpoint) DstIP() netip.Addr
func (BindEndpoint) DstToBytes ¶
func (ep BindEndpoint) DstToBytes() []byte
func (BindEndpoint) DstToString ¶
func (ep BindEndpoint) DstToString() string
func (BindEndpoint) DstUDPAddr ¶
func (ep BindEndpoint) DstUDPAddr() *net.UDPAddr
func (BindEndpoint) SrcIP ¶
func (ep BindEndpoint) SrcIP() netip.Addr
func (BindEndpoint) SrcToString ¶
func (ep BindEndpoint) SrcToString() string
type BindHandler ¶
type BindKernelConn ¶
BindKernelConn is a BindConn which is consumed by a Kernel WireGuard interface