Documentation
¶
Overview ¶
Package kernel is the service.Backend that drives interfaces through the AmneziaWG (or plain WireGuard) kernel module over netlink — RTM_NEWLINK to create the link, address/MTU/up on it, RTM_DELLINK to remove it. It's what the standard awg-agent binary wires in via service.SetBackend. Keeping it in its own package confines the vishvananda/netlink dependency to the kernel build, so the userspace agent (agent/internal/userspace) doesn't pull it in.
Index ¶
- type Backend
- func (Backend) Add(iface string, amnezia bool) error
- func (Backend) AddrAdd(iface, s string) error
- func (Backend) Delete(iface string) error
- func (Backend) Down(iface string) error
- func (Backend) Exists(iface string) bool
- func (Backend) Info() service.BackendInfo
- func (Backend) SetMTU(iface string, mtu int) error
- func (Backend) SyncAddr(iface, s string) error
- func (Backend) Up(iface string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct{}
Backend implements service.Backend against the kernel module via netlink.
func (Backend) Add ¶
Add creates the interface's link with the kind the config asks for: a plain WireGuard interface (amnezia false) is created as kind "wireguard" directly. An AmneziaWG interface (amnezia true) is created as kind "amneziawg" so the obfuscation params are honored, falling back to a plain "wireguard" link on hosts that only have the mainline module — or whose amnezia module doesn't allow creating a link over netlink (EINVAL/EOPNOTSUPP). That fallback is logged at warn level because obfuscation silently won't apply there.
func (Backend) Info ¶
func (Backend) Info() service.BackendInfo
Info reports the kernel backend's capabilities on this host. A plain WireGuard interface is always listed — kernel WireGuard support is a prerequisite for running this build at all. An AmneziaWG interface is listed only when the amneziawg kernel module is available (see amneziaModuleAvailable), since without it Add falls back to a plain WireGuard link and obfuscation wouldn't apply.
func (Backend) SyncAddr ¶
SyncAddr makes s the interface's only address, removing every other address already assigned to it first. netlink's AddrReplace only adds-or-updates the one address it's given — it has nothing to do with whatever *other* addresses are already on the link, so calling it alone after an admin edits an interface's addr leaves the old one still assigned alongside the new one.