Documentation
¶
Index ¶
- func GenerateAmneziaParams(cfg *InterfaceConfig)
- func IsEmpty(key Key) bool
- type AgentInfo
- type DeviceInfo
- type HostInfo
- type InterfaceConfig
- type InterfaceHistory
- type InterfacePeer
- type InterfaceSnapshot
- type Key
- type MetricsSnapshot
- type PeerHistory
- type PeerHistoryPoint
- type PeerInfo
- type PeerSnapshot
- type SystemHistory
- type SystemHistoryPoint
- type SystemSnapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateAmneziaParams ¶
func GenerateAmneziaParams(cfg *InterfaceConfig)
GenerateAmneziaParams populates the config with obfuscation values optimized for AWG 2.0.
Types ¶
type AgentInfo ¶
type AgentInfo struct {
MessageID uint64 `json:"mid"`
Devices []DeviceInfo `json:"devices"`
}
type DeviceInfo ¶
type HostInfo ¶
type HostInfo struct {
// Backend identifies which link backend this agent build drives: "kernel"
// (amneziawg-dkms over netlink) or "userspace" (in-process amneziawg-go).
Backend string `json:"backend"`
// Version is the agent build version (see each main's -ldflags).
Version string `json:"version"`
// Docker reports whether Docker is usable on the host (the docker CLI is
// present and `docker info` succeeds) — i.e. whether a docker-image agent
// deploy would work there.
Docker bool `json:"docker"`
// InDocker reports whether the agent process itself runs inside a Docker
// container, detected via the /.dockerenv file. Only the userspace agent
// ships as a container image, so this is only ever true for it.
InDocker bool `json:"inDocker"`
// KernelModule reports whether the AmneziaWG kernel module is available on
// the host (modinfo amneziawg succeeds — e.g. installed via dkms). Only
// meaningful for the kernel backend; always false for userspace.
KernelModule bool `json:"kernelModule"`
// InterfaceKinds lists the interface variants this agent can create on this
// host: "amneziawg" and/or "wireguard".
InterfaceKinds []string `json:"interfaceKinds"`
// Arch is the host CPU architecture the agent runs on (runtime.GOARCH, e.g.
// "amd64"/"arm64"). The admin uses it to offer only matching-architecture
// agent binaries in the "GitHub releases" source picker, since a binary
// built for another CPU won't run. Empty when reported by an older agent
// that predates this field.
Arch string `json:"arch"`
}
HostInfo is what the agent discovers about the host it runs on, gathered once at startup and served unchanged over GET /info (these facts don't change under a running agent). The admin uses it to show what a server supports — which interface kinds can be created, whether Docker is available — without having to SSH in and probe by hand.
type InterfaceConfig ¶
type InterfaceConfig struct {
Interface string `json:"iface"`
// PrivateKey specifies a private key configuration, if not nil.
PrivateKey Key `json:"pk"`
// ListenPort specifies a device's listening port, if not nil.
ListenPort uint16 `json:"listen"`
Address string `json:"addr"`
MTU int `json:"mtu,omitempty"`
DNS []string `json:"dns,omitempty"`
// Disabled deactivates the interface on the agent: its link is torn down
// (or never brought up at startup) and its device config is not applied,
// while the config itself stays stored. Zero value (false) keeps the
// interface active, so configs written before this field existed stay up.
Disabled bool `json:"disabled,omitempty"`
// Table the routing table number
Table int `json:"table,omitempty"`
// FirewallMark specifies a device's firewall mark, if not nil.
//
// If non-nil and set to 0, the firewall mark will be cleared.
FirewallMark *int `json:"fwMark,omitempty"`
PreUp []string `json:"preUp,omitempty"` // action that is executed before the device is up
PostUp []string `json:"postUp,omitempty"` // action that is executed after the device is up
PreDown []string `json:"preDown,omitempty"` // action that is executed before the device is down
PostDown []string `json:"postDown,omitempty"` // action that is executed after the device is down
// Peers specifies a list of peer configurations to apply to a device.
Peers []InterfacePeer `json:"peers,omitempty"`
// Junk Packet parameters
Jc *int `json:"jc,omitempty"` // Count
Jmin *int `json:"jmin,omitempty"` // Min size
Jmax *int `json:"jmax,omitempty"` // Max size
// Message Padding parameters (bytes)
S1 *int `json:"s1,omitempty"` // Init
S2 *int `json:"s2,omitempty"` // Response
S3 *int `json:"s3,omitempty"` // Cookie
S4 *int `json:"s4,omitempty"` // Transport
// Message Magic Headers
// In AmneziaWG 2.0 these should be ranges (e.g., "123456-123999")
H1 *string `json:"h1,omitempty"` // Init
H2 *string `json:"h2,omitempty"` // Response
H3 *string `json:"h3,omitempty"` // Cookie
H4 *string `json:"h4,omitempty"` // Transport
// Init Packet Magic / Custom Signature (obfuscation)
// For client-side explicit setups only.
I1 *string `json:"i1,omitempty"`
I2 *string `json:"i2,omitempty"`
I3 *string `json:"i3,omitempty"`
I4 *string `json:"i4,omitempty"`
I5 *string `json:"i5,omitempty"`
}
func (InterfaceConfig) IsAmnezia ¶
func (awg InterfaceConfig) IsAmnezia() bool
IsAmnezia reports whether this is an AmneziaWG interface (as opposed to a plain WireGuard one), i.e. any obfuscation parameter is set. The admin's "Amnezia Interface" toggle drives this: when on it sends a generated param set, when off it sends none. The backend uses it to pick the kernel link kind ("amneziawg" vs "wireguard").
func (InterfaceConfig) ToAmneziaConfig ¶
func (awg InterfaceConfig) ToAmneziaConfig() *wgtypes.Config
func (InterfaceConfig) ToWireguardPeers ¶
func (awg InterfaceConfig) ToWireguardPeers() []wgtypes.PeerConfig
type InterfaceHistory ¶
type InterfaceHistory struct {
Interface string `json:"interface"`
Peers []PeerHistory `json:"peers"`
}
InterfaceHistory groups per-peer history under their interface name, as carried in SystemHistory.Interfaces.
type InterfacePeer ¶
type InterfacePeer struct {
Key Key `json:"key"`
AllowedIPs []string `json:"ips"`
Endpoint string `json:"endpoint,omitempty"`
// Disabled deactivates this peer: it's kept in the stored InterfaceConfig
// but omitted from the device config applied via wgctrl (ToAmneziaConfig /
// ToWireguardPeers), so with ReplacePeers the peer is removed from the live
// interface and can't connect until reactivated. Zero value (false) keeps
// the peer active, so configs written before this field existed stay up.
Disabled bool `json:"disabled,omitempty"`
KeepaliveInterval time.Duration `json:"keepalive"`
}
func (InterfacePeer) PeerConfig ¶
func (p InterfacePeer) PeerConfig() wgtypes.PeerConfig
type InterfaceSnapshot ¶
type InterfaceSnapshot struct {
Interface string `json:"interface"`
Peers []PeerSnapshot `json:"peers"`
}
InterfaceSnapshot groups peer snapshots under their interface name.
type Key ¶
func GenerateKey ¶
func GeneratePrivateKey ¶
func (*Key) MarshalJSON ¶
func (*Key) UnmarshalJSON ¶
type MetricsSnapshot ¶
type MetricsSnapshot struct {
System SystemSnapshot `json:"system"`
Interfaces []InterfaceSnapshot `json:"interfaces"`
}
MetricsSnapshot is the full GET /metrics response: the latest known value of every metric the agent has collected.
type PeerHistory ¶
type PeerHistory struct {
PublicKey string `json:"publicKey"`
Points []PeerHistoryPoint `json:"points"`
}
PeerHistory is every retained sample for one peer, oldest first.
type PeerHistoryPoint ¶
type PeerHistoryPoint struct {
Timestamp time.Time `json:"timestamp"`
RxBytes uint64 `json:"rx"`
TxBytes uint64 `json:"tx"`
LastHandshake time.Time `json:"lastHandshake"`
}
PeerHistoryPoint is one retained sample for a single peer. Unlike SystemHistoryPoint's per-interval network deltas, RxBytes/TxBytes are the cumulative byte counters WireGuard reports for the peer (same as PeerSnapshot); differencing consecutive points yields per-interval traffic. LastHandshake is the peer's last successful handshake at that sample (zero value if it had never completed one yet).
type PeerSnapshot ¶
type PeerSnapshot struct {
PublicKey string `json:"publicKey"`
RxBytes uint64 `json:"rx"`
TxBytes uint64 `json:"tx"`
LastHandshake time.Time `json:"lastHandshake"`
}
PeerSnapshot is the latest recorded sample for one peer of one interface.
type SystemHistory ¶
type SystemHistory struct {
Points []SystemHistoryPoint `json:"points"`
Interfaces []InterfaceHistory `json:"interfaces"`
}
SystemHistory is the full GET /metrics/history response: every host-level sample (Points) plus every per-peer sample (Interfaces) still retained in the agent's in-memory ring buffers (up to 48h, oldest first — see agent/internal/metrics's package doc comment), for rendering charts instead of just the latest value. History is served only through this one endpoint; the per-peer series ride along here rather than on a separate route. Points stays the top-level field it always was, so existing consumers that only read host history are unaffected.
type SystemHistoryPoint ¶
type SystemHistoryPoint struct {
Timestamp time.Time `json:"timestamp"`
CPUPercent float64 `json:"cpuPercent"`
MemUsedBytes uint64 `json:"memUsedBytes"`
MemTotalBytes uint64 `json:"memTotalBytes"`
NetRxBytes uint64 `json:"netRxBytes"`
NetTxBytes uint64 `json:"netTxBytes"`
}
SystemHistoryPoint is one retained host-level sample, aligned across metrics by timestamp (see Collector.SystemHistory). Like SystemSnapshot, NetRxBytes/NetTxBytes are per-interval deltas, not cumulative counters.
type SystemSnapshot ¶
type SystemSnapshot struct {
Timestamp time.Time `json:"timestamp"`
CPUPercent float64 `json:"cpuPercent"`
MemUsedBytes uint64 `json:"memUsedBytes"`
MemTotalBytes uint64 `json:"memTotalBytes"`
Load1 float64 `json:"load1"`
Load5 float64 `json:"load5"`
Load15 float64 `json:"load15"`
// NetRxBytes/NetTxBytes are bytes transferred *during this one
// collection interval* (e.g. the last 45s, see
// AWG_AGENT_METRICS_INTERVAL), not the host's cumulative since-boot
// counters from /proc/net/dev — those only ever climb and aren't
// useful for "how much traffic is this server actually moving" (see
// agent/internal/metrics/collector.go's collectSystem).
NetRxBytes uint64 `json:"netRxBytes"`
NetTxBytes uint64 `json:"netTxBytes"`
}
SystemSnapshot is the latest recorded host-level sample.