kernel

package
v0.0.0-...-b7e086b Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 10 Imported by: 0

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() 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() (*MsgGetDeviceResponse, error)

func (*Client) GetPeers

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

func (*Client) IsConnected

func (c *Client) IsConnected() bool

func (*Client) IsDeviceAlive

func (c *Client) IsDeviceAlive() 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() error

type CreatePeerInMemory

type CreatePeerInMemory struct {
	PublicKey wgtypes.Key
	AllowedIP 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 MsgCreateDeviceInConfigFile

type MsgCreateDeviceInConfigFile struct {
	PrivateKey wgtypes.Key
	Address    string
}

type MsgCreatePeersInMemory

type MsgCreatePeersInMemory struct {
	Peers []CreatePeerInMemory
}

type MsgError

type MsgError struct {
	Error string
}

type MsgGetDeviceResponse

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

type MsgGetPeersResponse

type MsgGetPeersResponse struct {
	Peers []Peer
}

type MsgRemovePeerInMemory

type MsgRemovePeerInMemory struct {
	PublicKey wgtypes.Key
	AllowedIP net.IPNet
}

type MsgSetProxyPeerInConfigFile

type MsgSetProxyPeerInConfigFile struct {
	PublicKey wgtypes.Key
	AllowedIP net.IPNet
	Endpoint  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