Documentation ¶
Index ¶
- Variables
- func AnyError(errs ...error) bool
- func FirstError(errs ...error) error
- func GetConfigPath() string
- func GetInstanceFromArg(path string) string
- func GetKey(t *testing.T) []byte
- type Config
- type IPMask
- type IPNet
- type Interface
- type Key
- type Peer
- type PresharedKey
- type PrivateKey
- type UDPAddr
Constants ¶
This section is empty.
Variables ¶
var EmptyPSK = [32]byte{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
}
EmptyPSK is the byte representation used when no preshared key is set on a peer
Functions ¶
func FirstError ¶
FirstError returns the first non-nil error in the given arguments, and otherwise retuens nil
func GetConfigPath ¶
func GetConfigPath() string
GetConfigPath returns the directory where the configuration files should be looked for This path can be overridden by setting the WGCTL_CONFIG_PATH environment variable
func GetInstanceFromArg ¶
GetInstanceFromArg returns the normalized name of a WireGuard tunnel instance (and interface)
Types ¶
type Config ¶
Config represents a YAML-encodable configuration for a WireGuard tunnel
func ParseConfig ¶
ParseConfig unmarshals a Config from a YAML string
func ParseConfigReader ¶
ParseConfigReader unmarshals a Config from an io.Reader mapped to a YAML file
type IPMask ¶
IPMask represents an IP address and its subnet mask, to be assigned to an interface
func (*IPMask) MarshalYAML ¶
MarshalYAML returns the YAML string representation of an IPMask
func (IPMask) String ¶
String returns the classic CIDR representation of an IPMask (e.g. 192.168.0.1/24)
func (*IPMask) UnmarshalYAML ¶
UnmarshalYAML returns an IPMask from a YAML string
type IPNet ¶
IPNet is an unmarshalable version of net.IPNet
func (IPNet) MarshalYAML ¶
MarshalYAML returns the YAML string representation of an IPNet
func (*IPNet) UnmarshalYAML ¶
UnmarshalYAML returns an IPNet from a YAML string
type Interface ¶
type Interface struct { Description string `yaml:"description"` Address *IPMask `yaml:"address"` ListenPort int `yaml:"listen_port"` PrivateKey PrivateKey `yaml:"private_key"` FWMark int `yaml:"fwmark,omitempty"` PostUp [][]string `yaml:"post_up,omitempty"` PreDown [][]string `yaml:"pre_down,omitempty"` SetUpRoutes *bool `yaml:"routes,omitempty"` }
Interface represents a YAML-encodable configuration for a WireGuard interface
type Key ¶
type Key []byte
Key is an unmarshalable ED25519 key
func ComputePublicKey ¶
ComputePublicKey computes the matching Curve25519 public key from a private key
func (Key) MarshalYAML ¶
MarshalYAML returns the YAML string representation of a Key
func (*Key) UnmarshalYAML ¶
UnmarshalYAML returns a Key from a YAML string
type Peer ¶
type Peer struct { Description string `yaml:"description"` PublicKey Key `yaml:"public_key"` Endpoint *UDPAddr `yaml:"endpoint,omitempty"` AllowedIPS []IPNet `yaml:"allowed_ips,omitempty"` KeepaliveInterval time.Duration `yaml:"keepalive_interval,omitempty"` }
Peer represents a YAML-encodable configuration for a WireGuard peer
type PresharedKey ¶
type PresharedKey []byte
PresharedKey is un unmarshable preshared key
func GeneratePSK ¶
func GeneratePSK() (PresharedKey, error)
GeneratePSK generates a random preshared key to be used with a WireGuard peer
func GetPSK ¶
func GetPSK(t *testing.T) *PresharedKey
GetPSK returns a []byte PSK to be used in test functions
func (*PresharedKey) Bytes ¶
func (k *PresharedKey) Bytes() [wgtypes.KeyLen]byte
Bytes returns the byte representation of a preshared key
func (PresharedKey) MarshalYAML ¶
func (k PresharedKey) MarshalYAML() (interface{}, error)
MarshalYAML returns the YAML string representation of a PresharedKey
func (*PresharedKey) String ¶
func (k *PresharedKey) String() string
String returns the hex string representation of a preshared key
func (*PresharedKey) UnmarshalYAML ¶
func (k *PresharedKey) UnmarshalYAML(f func(interface{}) error) error
UnmarshalYAML returns a PresharedKey from a YAML string
type PrivateKey ¶
PrivateKey is an unmarshalable file path
func GeneratePrivateKey ¶
func GeneratePrivateKey() (*PrivateKey, error)
GeneratePrivateKey generates a new Curve25519 private key from crypto/rand
func NewPrivateKey ¶
func NewPrivateKey(bk []byte) PrivateKey
NewPrivateKey retirns a PrivateKey from a []byte
func (*PrivateKey) Bytes ¶
func (k *PrivateKey) Bytes() [wgtypes.KeyLen]byte
Bytes returns the byte representation of a private key
func (PrivateKey) MarshalYAML ¶
func (k PrivateKey) MarshalYAML() (interface{}, error)
MarshalYAML returns the YAML string representation of a PrivateKeyFile
func (*PrivateKey) String ¶
func (k *PrivateKey) String() string
String returns the string repsentation of a private key
func (*PrivateKey) UnmarshalYAML ¶
func (k *PrivateKey) UnmarshalYAML(f func(interface{}) error) error
UnmarshalYAML returns an private key from a YAML file path
type UDPAddr ¶
UDPAddr is an unmarshalable version of net.UDPAddr
func GetEndpoint ¶
GetEndpoint returns a random IPv4 UDPAddr to be used in test functions
func (UDPAddr) MarshalYAML ¶
MarshalYAML returns the YAML string representation of an UDPAddr
func (*UDPAddr) UnmarshalYAML ¶
UnmarshalYAML returns an UDPAddr from a YAML string