wgcfg

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2021 License: BSD-3-Clause Imports: 12 Imported by: 19

Documentation

Overview

Package wgcfg has types and a parser for representing WireGuard config.

Index

Constants

View Source
const EndpointDiscoSuffix = ".disco.tailscale:12345"

EndpointDiscoSuffix is appended to the hex representation of a peer's discovery key and is then the sole wireguard endpoint for peers with a non-zero discovery key. This form is then recognize by magicsock's CreateEndpoint.

Variables

This section is empty.

Functions

func ReconfigDevice

func ReconfigDevice(d *device.Device, cfg *Config, logf logger.Logf) (err error)

ReconfigDevice replaces the existing device configuration with cfg.

Types

type Config

type Config struct {
	Name       string
	PrivateKey wgkey.Private
	Addresses  []netaddr.IPPrefix
	MTU        uint16
	DNS        []netaddr.IP
	Peers      []Peer
}

Config is a WireGuard configuration. It only supports the set of things Tailscale uses.

func DeviceConfig

func DeviceConfig(d *device.Device) (*Config, error)

func FromUAPI

func FromUAPI(r io.Reader) (*Config, error)

FromUAPI generates a Config from r. r should be generated by calling device.IpcGetOperation; it is not compatible with other uapi streams.

func (Config) Copy

func (cfg Config) Copy() Config

Copy makes a deep copy of Config. The result aliases no memory with the original.

func (Config) PeerWithKey

func (config Config) PeerWithKey(k wgkey.Key) (Peer, bool)

PeerWithKey returns the Peer with key k and reports whether it was found.

func (*Config) ToUAPI

func (cfg *Config) ToUAPI(w io.Writer, prev *Config) error

ToUAPI writes cfg in UAPI format to w. Prev is the previous device Config. Prev is required so that we can remove now-defunct peers without having to remove and re-add all peers.

type ParseError

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

func (*ParseError) Error

func (e *ParseError) Error() string

type Peer

type Peer struct {
	PublicKey           wgkey.Key
	AllowedIPs          []netaddr.IPPrefix
	Endpoints           string // comma-separated host/port pairs: "1.2.3.4:56,[::]:80"
	PersistentKeepalive uint16
}

func (Peer) Copy

func (peer Peer) Copy() Peer

Copy makes a deep copy of Peer. The result aliases no memory with the original.

Directories

Path Synopsis
Package nmcfg converts a controlclient.NetMap into a wgcfg config.
Package nmcfg converts a controlclient.NetMap into a wgcfg config.

Jump to

Keyboard shortcuts

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