Files
tailscale/wgengine/wgcfg/config.go
Brad FitzpatrickandDavid Anderson 911d8f84a0 wgengine/wgcfg: wire up new wireguard-go hybrid handshake field
Wire up wireguard-go's new NewPeerConfig.Hybrid field. (no current users)

Updates tailscale/corp#50068

Co-authored-by: David Anderson <[email protected]>
Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: I80d7af011b43273e6c949214c6d862f9247a82e1
2026-11-03 10:19:55 -08:00

48 lines
1.3 KiB
Go

// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause
// Package wgcfg has types and a parser for representing WireGuard config.
package wgcfg
import (
"net/netip"
"slices"
"github.com/tailscale/wireguard-go/device"
"tailscale.com/types/key"
)
//go:generate go run tailscale.com/cmd/cloner -type=Config
// 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].
type Config struct {
PrivateKey key.NodePrivate
Addresses []netip.Prefix
}
// PeerConfig is the WireGuard configuration for one peer.
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
// Hybrid is whether to use a hybrid post-quantum handshake with this peer.
Hybrid bool
}
func (c *Config) Equal(o *Config) bool {
if c == nil || o == nil {
return c == o
}
return c.PrivateKey.Equal(o.PrivateKey) &&
slices.Equal(c.Addresses, o.Addresses)
}