wgembed

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigFile

type ConfigFile struct {
	Interface IfaceConfig
	Peers     []PeerConfig `ini:"Peer,nonunique"`
	// contains filtered or unexported fields
}

func ReadConfig

func ReadConfig(path string) (*ConfigFile, error)

func (*ConfigFile) Config

func (c *ConfigFile) Config() (*wgtypes.Config, error)

func (*ConfigFile) String

func (c *ConfigFile) String() string

type IfaceConfig

type IfaceConfig struct {
	PrivateKey string
	Address    []string
	ListenPort *int
	DNS        []string
	MTU        *int
}

type KeyPair

type KeyPair struct {
	PublicKey  string
	PrivateKey string
}

func NewKeyPair

func NewKeyPair() KeyPair

type NoOpWireguardInterface

type NoOpWireguardInterface struct {
}

func (*NoOpWireguardInterface) AddPeer

func (wg *NoOpWireguardInterface) AddPeer(publicKey string, presharedKey string, addressCIDR []string) error

func (*NoOpWireguardInterface) Close

func (wg *NoOpWireguardInterface) Close() error

func (*NoOpWireguardInterface) ListPeers

func (wg *NoOpWireguardInterface) ListPeers() ([]wgtypes.Peer, error)

func (*NoOpWireguardInterface) LoadConfig

func (wg *NoOpWireguardInterface) LoadConfig(config *ConfigFile) error

func (*NoOpWireguardInterface) Ping added in v0.9.0

func (wg *NoOpWireguardInterface) Ping() error

func (*NoOpWireguardInterface) PublicKey

func (wg *NoOpWireguardInterface) PublicKey() (string, error)

func (*NoOpWireguardInterface) RemovePeer

func (wg *NoOpWireguardInterface) RemovePeer(publicKey string) error

type Options

type Options struct {
	// InterfaceName will be the name of the network interface, this is required
	InterfaceName string
	// AllowKernelModule enables the usage of the WireGuard kernel module.
	// Falls back to userspace if creation fails. No effect on Windows or Darwin
	AllowKernelModule bool
}

Options contains configuration options for the interface

type PeerConfig

type PeerConfig struct {
	PublicKey  string
	AllowedIPs []string
	Endpoint   *string
}

type WireGuardInterface

type WireGuardInterface interface {
	LoadConfig(config *ConfigFile) error
	AddPeer(publicKey string, presharedKey string, addressCIDR []string) error
	ListPeers() ([]wgtypes.Peer, error)
	RemovePeer(publicKey string) error
	PublicKey() (string, error)
	Close() error
	Ping() error
}

func New

func New(interfaceName string) (WireGuardInterface, error)

New creates a wireguard interface and starts the userspace wireguard configuration api

func NewNoOpInterface

func NewNoOpInterface() WireGuardInterface

func NewWithOpts

func NewWithOpts(opts Options) (WireGuardInterface, error)

NewWithOpts creates a new network interface, needs to be enabled with WireGuardInterface.Up() afterwards. opts.Name is require and must be set to a unique interface name

Jump to

Keyboard shortcuts

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