wguser

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: MIT Imports: 10 Imported by: 1

README

wguser

This is the user-mode side of our Wireguard interface. We talk to the root-mode side over a Unix socket. The user-mode side can be run without root privileges.

Documentation

Index

Constants

View Source
const MaxMsgSize = 1024 * 1024 * 1024
View Source
const UnixSocketName = "@cyclops-wg"

const UnixSocketName = "/var/opt/kernelwg"

Variables

View Source
var ErrNotConnected = errors.New("Not connected to root wireguard process") // This is generated client-side

Well known error messages

View Source
var ErrWireguardDeviceNotExist = errors.New("Wireguard device does not exist")

Functions

This section is empty.

Types

type Client

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

Client can only be used by a single thread at a time. There is a giant lock that ensures this.

func NewClient

func NewClient(secret string) *Client

func (*Client) Authenticate

func (c *Client) Authenticate() error

func (*Client) BringDeviceUp

func (c *Client) BringDeviceUp(deviceName string) error

func (*Client) Close

func (c *Client) Close()

func (*Client) Connect

func (c *Client) Connect() error

func (*Client) CreateDeviceInConfigFile

func (c *Client) CreateDeviceInConfigFile(msg *MsgCreateDeviceInConfigFile) error

func (*Client) CreatePeers

func (c *Client) CreatePeers(msg *MsgCreatePeersInMemory) error

func (*Client) GetDevice

func (c *Client) GetDevice(deviceName string) (*MsgGetDeviceResponse, error)

func (*Client) GetPeers

func (c *Client) GetPeers(deviceName string) (*MsgGetPeersResponse, error)

func (*Client) IsConnected

func (c *Client) IsConnected() bool

func (*Client) IsDeviceAlive

func (c *Client) IsDeviceAlive(deviceName string) error

func (*Client) RemovePeer

func (c *Client) RemovePeer(msg *MsgRemovePeerInMemory) error

func (*Client) SetProxyPeerInConfigFile

func (c *Client) SetProxyPeerInConfigFile(msg *MsgSetProxyPeerInConfigFile) error

func (*Client) TakeDeviceDown

func (c *Client) TakeDeviceDown(deviceName string) error

type CreatePeerInMemory

type CreatePeerInMemory struct {
	PublicKey  wgtypes.Key
	AllowedIPs []net.IPNet
	Endpoint   string
}

type Device

type Device struct {
	Name       string
	ListenPort int
	Peers      []Peer
}

Device is a cut-down clone of wgtypes.Device

type MsgAuthenticate

type MsgAuthenticate struct {
	Secret string
}

type MsgBringDeviceUp added in v1.0.5

type MsgBringDeviceUp struct {
	DeviceName string
}

type MsgCreateDeviceInConfigFile

type MsgCreateDeviceInConfigFile struct {
	DeviceName string
	PrivateKey wgtypes.Key
	Addresses  []string
}

type MsgCreatePeersInMemory

type MsgCreatePeersInMemory struct {
	DeviceName string
	Peers      []CreatePeerInMemory
}

type MsgError

type MsgError struct {
	Error string
}

type MsgGetDevice added in v1.0.5

type MsgGetDevice struct {
	DeviceName string
}

type MsgGetDeviceResponse

type MsgGetDeviceResponse struct {
	PrivateKey wgtypes.Key
	ListenPort int
	Addresses  []string // Unlike the other state returned here, this is read from the Wireguard config file, so it might be empty
}

type MsgGetPeers added in v1.0.5

type MsgGetPeers struct {
	DeviceName string
}

type MsgGetPeersResponse

type MsgGetPeersResponse struct {
	Peers []Peer
}

type MsgIsDeviceAlive added in v1.0.5

type MsgIsDeviceAlive struct {
	DeviceName string
}

type MsgRemovePeerInMemory

type MsgRemovePeerInMemory struct {
	DeviceName string
	PublicKey  wgtypes.Key
	AllowedIPs []net.IPNet
}

type MsgSetProxyPeerInConfigFile

type MsgSetProxyPeerInConfigFile struct {
	DeviceName string
	PublicKey  wgtypes.Key
	AllowedIPs []net.IPNet
	Endpoint   string
}

type MsgTakeDeviceDown added in v1.0.5

type MsgTakeDeviceDown struct {
	DeviceName string
}

type MsgType

type MsgType int
const (
	MsgTypeNone MsgType = iota
	MsgTypeError
	MsgTypeAuthenticate
	MsgTypeIsDeviceAlive
	MsgTypeGetDevice
	MsgTypeGetDeviceResponse
	MsgTypeGetPeers
	MsgTypeGetPeersResponse
	MsgTypeBringDeviceUp
	MsgTypeTakeDeviceDown
	MsgTypeCreatePeersInMemory
	MsgTypeRemovePeerInMemory
	MsgTypeCreateDeviceInConfigFile
	MsgTypeSetProxyPeerInConfigFile
)

type Peer

type Peer struct {
	PublicKey                   wgtypes.Key
	PersistentKeepaliveInterval time.Duration
	LastHandshakeTime           time.Time
	ReceiveBytes                int64
	TransmitBytes               int64
	AllowedIPs                  []net.IPNet
}

Peer is a cut-down clone of wgtypes.Peer

Jump to

Keyboard shortcuts

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