wgcommon

package
v5.52.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_proxy_wireguard_wgcommon_config_proto protoreflect.FileDescriptor

Functions

func NewDeviceLoggerAdapter

func NewDeviceLoggerAdapter() *device.Logger

NewDeviceLoggerAdapter returns a wireguard device.Logger that forwards verbose and error logs into the project's error logger using errors.New(...). Verbosef logs are recorded as Debug, Errorf logs are recorded as Error. machine generated

func NewNetPacketConnToWg

func NewNetPacketConnToWg(c net.PacketConn) conn.Bind

NewNetPacketConnToWg constructs a wireguard conn.Bind adapter from a common/net.PacketConn. It returns a Bind implementation that delegates reads/writes to the provided PacketConn.

Important: the Bind does NOT own the PacketConn lifecycle. WireGuard calls Close() + Open() internally during BindUpdate(); Close() here only marks the bind as logically closed without closing the underlying conn, so that Open() can re-use it.

Types

type DeviceConfig

type DeviceConfig struct {
	PrivateKey []byte        `protobuf:"bytes,1,opt,name=private_key,json=privateKey,proto3" json:"private_key,omitempty"`
	ListenPort uint32        `protobuf:"varint,3,opt,name=listen_port,json=listenPort,proto3" json:"listen_port,omitempty"`
	Peers      []*PeerConfig `protobuf:"bytes,4,rep,name=peers,proto3" json:"peers,omitempty"`
	Mtu        uint32        `protobuf:"varint,5,opt,name=mtu,proto3" json:"mtu,omitempty"`
	// contains filtered or unexported fields
}

func (*DeviceConfig) Descriptor deprecated

func (*DeviceConfig) Descriptor() ([]byte, []int)

Deprecated: Use DeviceConfig.ProtoReflect.Descriptor instead.

func (*DeviceConfig) GetListenPort

func (x *DeviceConfig) GetListenPort() uint32

func (*DeviceConfig) GetMtu

func (x *DeviceConfig) GetMtu() uint32

func (*DeviceConfig) GetPeers

func (x *DeviceConfig) GetPeers() []*PeerConfig

func (*DeviceConfig) GetPrivateKey

func (x *DeviceConfig) GetPrivateKey() []byte

func (*DeviceConfig) ProtoMessage

func (*DeviceConfig) ProtoMessage()

func (*DeviceConfig) ProtoReflect

func (x *DeviceConfig) ProtoReflect() protoreflect.Message

func (*DeviceConfig) Reset

func (x *DeviceConfig) Reset()

func (*DeviceConfig) String

func (x *DeviceConfig) String() string

type NetworkLayerDeviceToWireguardTunDeviceAdaptor

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

NetworkLayerDeviceToWireguardTunDeviceAdaptor is primarily machine generated.

func NewNetworkLayerDeviceToWireguardTunDeviceAdaptor

func NewNetworkLayerDeviceToWireguardTunDeviceAdaptor(mtu int, networkLayerSwitch packetswitch.NetworkLayerDevice, batchSize int, inboundChannelSize int) (*NetworkLayerDeviceToWireguardTunDeviceAdaptor, error)

func (*NetworkLayerDeviceToWireguardTunDeviceAdaptor) BatchSize

func (*NetworkLayerDeviceToWireguardTunDeviceAdaptor) Close

func (*NetworkLayerDeviceToWireguardTunDeviceAdaptor) Events

func (*NetworkLayerDeviceToWireguardTunDeviceAdaptor) File

func (*NetworkLayerDeviceToWireguardTunDeviceAdaptor) MTU

func (*NetworkLayerDeviceToWireguardTunDeviceAdaptor) Name

func (*NetworkLayerDeviceToWireguardTunDeviceAdaptor) Read

func (n *NetworkLayerDeviceToWireguardTunDeviceAdaptor) Read(bufs [][]byte, sizes []int, offset int) (ret int, err error)

func (*NetworkLayerDeviceToWireguardTunDeviceAdaptor) Write

func (n *NetworkLayerDeviceToWireguardTunDeviceAdaptor) Write(bufs [][]byte, offset int) (int, error)

type PeerConfig

type PeerConfig struct {
	PublicKey                   []byte   `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
	PresharedKey                []byte   `protobuf:"bytes,2,opt,name=preshared_key,json=presharedKey,proto3" json:"preshared_key,omitempty"`
	AllowedIps                  []string `protobuf:"bytes,3,rep,name=allowed_ips,json=allowedIps,proto3" json:"allowed_ips,omitempty"`
	Endpoint                    string   `protobuf:"bytes,4,opt,name=endpoint,proto3" json:"endpoint,omitempty"`
	PersistentKeepaliveInterval int64    `` /* 145-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*PeerConfig) Descriptor deprecated

func (*PeerConfig) Descriptor() ([]byte, []int)

Deprecated: Use PeerConfig.ProtoReflect.Descriptor instead.

func (*PeerConfig) GetAllowedIps

func (x *PeerConfig) GetAllowedIps() []string

func (*PeerConfig) GetEndpoint

func (x *PeerConfig) GetEndpoint() string

func (*PeerConfig) GetPersistentKeepaliveInterval

func (x *PeerConfig) GetPersistentKeepaliveInterval() int64

func (*PeerConfig) GetPresharedKey

func (x *PeerConfig) GetPresharedKey() []byte

func (*PeerConfig) GetPublicKey

func (x *PeerConfig) GetPublicKey() []byte

func (*PeerConfig) ProtoMessage

func (*PeerConfig) ProtoMessage()

func (*PeerConfig) ProtoReflect

func (x *PeerConfig) ProtoReflect() protoreflect.Message

func (*PeerConfig) Reset

func (x *PeerConfig) Reset()

func (*PeerConfig) String

func (x *PeerConfig) String() string

type WrappedWireguardDevice

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

func NewWrappedWireguardDevice

func NewWrappedWireguardDevice(ctx context.Context, config *DeviceConfig) (*WrappedWireguardDevice, error)

func (*WrappedWireguardDevice) AddOrReplacePeers

func (w *WrappedWireguardDevice) AddOrReplacePeers(peers []*PeerConfig) error

func (*WrappedWireguardDevice) Close

func (w *WrappedWireguardDevice) Close() error

func (*WrappedWireguardDevice) Debug

func (w *WrappedWireguardDevice) Debug() (string, error)

func (*WrappedWireguardDevice) InitDevice

func (w *WrappedWireguardDevice) InitDevice() error

func (*WrappedWireguardDevice) RemovePeer

func (w *WrappedWireguardDevice) RemovePeer(publicKey []byte) error

func (*WrappedWireguardDevice) SetConn

func (w *WrappedWireguardDevice) SetConn(c net.PacketConn)

SetConn sets the underlying packet connection used by the wrapped WireGuard device.

func (*WrappedWireguardDevice) SetTunnel

SetTunnel sets the network layer tunnel device for the wrapped WireGuard device.

func (*WrappedWireguardDevice) SetupDeviceWithoutPeers

func (w *WrappedWireguardDevice) SetupDeviceWithoutPeers() error

func (*WrappedWireguardDevice) Up

func (w *WrappedWireguardDevice) Up() error

Jump to

Keyboard shortcuts

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