wgcfg

package
v0.0.0-...-365054f Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeviceConfig

type DeviceConfig struct {
	IfaceName  string    `json:"iface_name"`
	MTU        int       `json:"mtu"`
	Subnet     net.IPNet `json:"subnet"`
	PrivateKey string    `json:"private_key"`
	ListenPort int       `json:"listen_port"`
	DNSPort    int       `json:"dns_port,omitempty"`
	DNS        []string  `json:"dns"`
	// Used only for unix.
	DNSScriptDir string `json:"dns_script_dir"`

	Peer         Peer `json:"peer"`
	ReplacePeers bool `json:"replace_peers,omitempty"`

	ProxyPort int `json:"proxy_port,omitempty"`
}

DeviceConfig describes wireguard device configuration.

func (*DeviceConfig) Encode

func (dc *DeviceConfig) Encode() string

Encode encodes device config into string representation which is used for userspace and kernel space wireguard configuration.

func (DeviceConfig) MarshalJSON

func (dc DeviceConfig) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface to provide human readable configuration.

func (*DeviceConfig) UnmarshalJSON

func (dc *DeviceConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface to receive human readable configuration.

type Peer

type Peer struct {
	PublicKey              string       `json:"public_key"`
	Endpoint               *net.UDPAddr `json:"endpoint"`
	AllowedIPs             []string     `json:"allowed_i_ps"`
	KeepAlivePeriodSeconds int          `json:"keep_alive_period_seconds"`
}

Peer represents wireguard peer.

func (*Peer) Encode

func (p *Peer) Encode() string

Encode encodes device peer config into string representation which is used for userspace and kernel space wireguard configuration.

type Stats

type Stats struct {
	BytesSent     uint64    `json:"bytes_sent"`
	BytesReceived uint64    `json:"bytes_received"`
	LastHandshake time.Time `json:"last_handshake"`
}

Stats represents wireguard peer statistics information.

Jump to

Keyboard shortcuts

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