wgcfg

package
v1.104.7 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: BSD-3-Clause Imports: 10 Imported by: 21

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDevice added in v1.18.0

func NewDevice(tunDev tun.Device, bind conn.Bind, logger *device.Logger) *device.Device

NewDevice returns a wireguard-go Device configured for Tailscale use.

func NewPeerLookupFunc added in v1.102.0

func NewPeerLookupFunc(bind conn.Bind, logf logger.Logf, peerConfig func(device.NoisePublicKey) (PeerConfig, bool)) device.PeerLookupFunc

NewPeerLookupFunc returns a device.PeerLookupFunc that lazily creates peers using peerConfig as the source of each peer's allowed IPs and optional pre-shared key. The peer's endpoint is derived from its public key via bind.

Types

type Config

type Config struct {
	PrivateKey key.NodePrivate
	Addresses  []netip.Prefix
}

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

Peers are not part of the config: wireguard-go learns the peer set and each peer's configuration from the live per-peer config source installed via tailscale.com/wgengine.Engine.SetPeerConfigFunc.

func (*Config) Clone added in v1.10.0

func (src *Config) Clone() *Config

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

func (*Config) Equal added in v1.90.0

func (c *Config) Equal(o *Config) bool

type PeerConfig added in v1.104.0

type PeerConfig struct {
	// AllowedIPs is the set of prefixes the peer may originate traffic from.
	AllowedIPs []netip.Prefix

	// PresharedKey is the optional WireGuard pre-shared key. The zero value
	// disables the pre-shared-key layer.
	PresharedKey device.NoisePresharedKey
}

PeerConfig is the WireGuard configuration for one peer.

Jump to

Keyboard shortcuts

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