Documentation ¶
Overview ¶
Package wgcfg has types and a parser for representing WireGuard config.
Index ¶
- Constants
- func ReconfigDevice(d *device.Device, cfg *Config, logf logger.Logf) (err error)
- type Config
- type Key
- func (k Key) Base64() string
- func (k Key) Equal(k2 Key) bool
- func (k Key) HexString() string
- func (k *Key) IsZero() bool
- func (a *Key) LessThan(b *Key) bool
- func (k *Key) MarshalJSON() ([]byte, error)
- func (k *Key) ShortString() string
- func (k Key) String() string
- func (k *Key) UnmarshalJSON(b []byte) error
- type ParseError
- type Peer
- type PrivateKey
- func (k *PrivateKey) Equal(k2 PrivateKey) bool
- func (k *PrivateKey) HexString() string
- func (k *PrivateKey) IsZero() bool
- func (k PrivateKey) MarshalText() ([]byte, error)
- func (k *PrivateKey) Public() Key
- func (k PrivateKey) SharedSecret(pub Key) (ss [KeySize]byte)
- func (k *PrivateKey) String() string
- func (k *PrivateKey) UnmarshalText(b []byte) error
- type SymmetricKey
Constants ¶
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.
const KeySize = 32
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Name string PrivateKey PrivateKey Addresses []netaddr.IPPrefix ListenPort uint16 MTU uint16 DNS []netaddr.IP Peers []Peer }
Config is a WireGuard configuration. It only supports the set of things Tailscale uses.
func FromUAPI ¶
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 ¶
Copy makes a deep copy of Config. The result aliases no memory with the original.
func (Config) PeerWithKey ¶
PeerWithKey returns the Peer with key k and reports whether it was found.
type Key ¶
Key is curve25519 key. It is used by WireGuard to represent public and preshared keys.
func NewPresharedKey ¶
NewPresharedKey generates a new random key.
func ParseHexKey ¶
func (*Key) MarshalJSON ¶
func (*Key) ShortString ¶
func (*Key) UnmarshalJSON ¶
type ParseError ¶
type ParseError struct {
// contains filtered or unexported fields
}
func (*ParseError) Error ¶
func (e *ParseError) Error() string
type Peer ¶
type PrivateKey ¶
PrivateKey is curve25519 key. It is used by WireGuard to represent private keys.
func NewPrivateKey ¶
func NewPrivateKey() (PrivateKey, error)
NewPrivateKey generates a new curve25519 secret key. It conforms to the format described on https://cr.yp.to/ecdh.html.
func ParsePrivateHexKey ¶
func ParsePrivateHexKey(v string) (PrivateKey, error)
func ParsePrivateKey ¶
func ParsePrivateKey(b64 string) (*PrivateKey, error)
func (*PrivateKey) Equal ¶
func (k *PrivateKey) Equal(k2 PrivateKey) bool
func (*PrivateKey) HexString ¶
func (k *PrivateKey) HexString() string
func (*PrivateKey) IsZero ¶
func (k *PrivateKey) IsZero() bool
func (PrivateKey) MarshalText ¶
func (k PrivateKey) MarshalText() ([]byte, error)
func (*PrivateKey) Public ¶
func (k *PrivateKey) Public() Key
Public computes the public key matching this curve25519 secret key.
func (PrivateKey) SharedSecret ¶
func (k PrivateKey) SharedSecret(pub Key) (ss [KeySize]byte)
func (*PrivateKey) String ¶
func (k *PrivateKey) String() string
func (*PrivateKey) UnmarshalText ¶
func (k *PrivateKey) UnmarshalText(b []byte) error
type SymmetricKey ¶
type SymmetricKey [chacha20poly1305.KeySize]byte
SymmetricKey is a chacha20poly1305 key. It is used by WireGuard to represent pre-shared symmetric keys.
func ParseSymmetricHexKey ¶
func ParseSymmetricHexKey(s string) (SymmetricKey, error)
func ParseSymmetricKey ¶
func ParseSymmetricKey(b64 string) (SymmetricKey, error)
func (SymmetricKey) Base64 ¶
func (k SymmetricKey) Base64() string
func (SymmetricKey) Equal ¶
func (k SymmetricKey) Equal(k2 SymmetricKey) bool
func (SymmetricKey) HexString ¶
func (k SymmetricKey) HexString() string
func (SymmetricKey) IsZero ¶
func (k SymmetricKey) IsZero() bool
func (SymmetricKey) String ¶
func (k SymmetricKey) String() string