mirror of
https://github.com/h44z/wg-portal.git
synced 2026-12-05 19:56:06 +01:00
feat: add support for AmneziaWG (#649)
This commit is contained in:
@@ -2033,6 +2033,12 @@
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"domain.AmneziaWGOptions": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"model.AuditEntry": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -2150,6 +2156,9 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"AmneziaWG": {
|
||||
"$ref": "#/definitions/domain.AmneziaWGOptions"
|
||||
},
|
||||
"Backend": {
|
||||
"description": "the backend used for this interface e.g., local, mikrotik, ...",
|
||||
"type": "string",
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
basePath: /api/v0
|
||||
definitions:
|
||||
domain.AmneziaWGOptions:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
model.AuditEntry:
|
||||
properties:
|
||||
ContextUser:
|
||||
@@ -76,6 +80,8 @@ definitions:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
AmneziaWG:
|
||||
$ref: '#/definitions/domain.AmneziaWGOptions'
|
||||
Backend:
|
||||
description: the backend used for this interface e.g., local, mikrotik, ...
|
||||
example: local
|
||||
|
||||
@@ -1601,6 +1601,13 @@
|
||||
"10.11.12.1/24"
|
||||
]
|
||||
},
|
||||
"AmneziaWG": {
|
||||
"description": "AmneziaWG contains per-interface obfuscation options for the amneziawg backend.\nOmitted options preserve the current kernel settings. Values use awg configuration syntax.",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"Backend": {
|
||||
"description": "Backend is the configured backend ID used to manage this interface. Omit it on create to use the local backend, or on update to preserve the current backend.",
|
||||
"type": "string",
|
||||
|
||||
@@ -52,6 +52,13 @@ definitions:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
AmneziaWG:
|
||||
additionalProperties:
|
||||
type: string
|
||||
description: |-
|
||||
AmneziaWG contains per-interface obfuscation options for the amneziawg backend.
|
||||
Omitted options preserve the current kernel settings. Values use awg configuration syntax.
|
||||
type: object
|
||||
Backend:
|
||||
description: Backend is the configured backend ID used to manage this interface.
|
||||
Omit it on create to use the local backend, or on update to preserve the
|
||||
|
||||
@@ -49,6 +49,8 @@ type Interface struct {
|
||||
PeerDefPreDown string `json:"PeerDefPreDown"` // default action that is executed before the device is down
|
||||
PeerDefPostDown string `json:"PeerDefPostDown"` // default action that is executed after the device is down
|
||||
|
||||
AmneziaWG domain.AmneziaWGOptions `json:"AmneziaWG,omitempty"`
|
||||
|
||||
// Calculated values
|
||||
|
||||
EnabledPeers int `json:"EnabledPeers"`
|
||||
@@ -94,6 +96,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(),
|
||||
@@ -174,6 +178,7 @@ func NewDomainInterface(src *Interface) *domain.Interface {
|
||||
PeerDefPostUp: src.PeerDefPostUp,
|
||||
PeerDefPreDown: src.PeerDefPreDown,
|
||||
PeerDefPostDown: src.PeerDefPostDown,
|
||||
AmneziaWG: src.AmneziaWG,
|
||||
}
|
||||
|
||||
if src.Disabled {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user