feat: add support for AmneziaWG (#649)

This commit is contained in:
Christoph
2026-11-10 23:20:12 +01:00
parent 61c8ceaab8
commit e314fd5e80
38 changed files with 2136 additions and 22 deletions
@@ -118,6 +118,9 @@ func (s InterfaceService) Update(ctx context.Context, id domain.InterfaceIdentif
iface.IsDynamic = existingInterface.IsDynamic
iface.DriverType = existingInterface.DriverType
iface.LdapAllowedUsers = existingInterface.LdapAllowedUsers
if iface.AmneziaWG == nil {
iface.AmneziaWG = existingInterface.AmneziaWG
}
updatedInterface, updatedPeers, err := s.interfaces.UpdateInterface(ctx, iface)
if err != nil {
@@ -134,6 +137,7 @@ func (s InterfaceService) validateBackend(backend domain.InterfaceBackend) error
// Empty is the legacy representation of the local backend in domain objects.
if id == "" || id == config.LocalBackendName ||
(id == config.AmneziaWGBackendName && s.cfg.Backend.AmneziaWG.Enabled) ||
slices.ContainsFunc(s.cfg.Backend.Mikrotik, func(b config.BackendMikrotik) bool { return b.Id == id }) ||
slices.ContainsFunc(s.cfg.Backend.Pfsense, func(b config.BackendPfsense) bool { return b.Id == id }) ||
slices.ContainsFunc(s.cfg.Backend.Opnsense, func(b config.BackendOpnsense) bool { return b.Id == id }) {
@@ -83,6 +83,10 @@ type Interface struct {
// PeerDefPostDown specifies the default action that is executed after the device is down for a new peer.
PeerDefPostDown string `json:"PeerDefPostDown"`
// AmneziaWG contains per-interface obfuscation options for the amneziawg backend.
// Omitted options preserve the current kernel settings. Values use awg configuration syntax.
AmneziaWG domain.AmneziaWGOptions `json:"AmneziaWG,omitempty" swaggertype:"object,string"`
// Calculated values
// EnabledPeers is the number of enabled peers for this interface. Only enabled peers are able to connect.
@@ -135,6 +139,8 @@ func NewInterface(src *domain.Interface, peers []domain.Peer) *Interface {
PeerDefPreDown: src.PeerDefPreDown,
PeerDefPostDown: src.PeerDefPostDown,
AmneziaWG: src.AmneziaWG,
EnabledPeers: 0,
TotalPeers: 0,
Filename: src.GetConfigFileName(),
@@ -204,6 +210,7 @@ func NewDomainInterface(src *Interface) *domain.Interface {
PeerDefPostUp: src.PeerDefPostUp,
PeerDefPreDown: src.PeerDefPreDown,
PeerDefPostDown: src.PeerDefPostDown,
AmneziaWG: src.AmneziaWG,
}
if src.Disabled {