generate interface and peer configuration filenames in backend only (#395)

This commit is contained in:
Christoph
2025-04-19 13:12:31 +02:00
parent a60feb7fc9
commit 6681dfa96f
14 changed files with 91 additions and 20 deletions

View File

@@ -47,8 +47,9 @@ type Interface struct {
// Calculated values
EnabledPeers int `json:"EnabledPeers"`
TotalPeers int `json:"TotalPeers"`
EnabledPeers int `json:"EnabledPeers"`
TotalPeers int `json:"TotalPeers"`
Filename string `json:"Filename"` // the filename of the config file, for example: wg0.conf
}
func NewInterface(src *domain.Interface, peers []domain.Peer) *Interface {
@@ -88,6 +89,7 @@ func NewInterface(src *domain.Interface, peers []domain.Peer) *Interface {
EnabledPeers: 0,
TotalPeers: 0,
Filename: src.GetConfigFileName(),
}
if len(peers) > 0 {

View File

@@ -73,6 +73,10 @@ type Peer struct {
PostUp ConfigOption[string] `json:"PostUp"` // action that is executed after the device is up
PreDown ConfigOption[string] `json:"PreDown"` // action that is executed before the device is down
PostDown ConfigOption[string] `json:"PostDown"` // action that is executed after the device is down
// Calculated values
Filename string `json:"Filename"` // the filename of the config file, for example: wg_peer_x.conf
}
func NewPeer(src *domain.Peer) *Peer {
@@ -105,6 +109,7 @@ func NewPeer(src *domain.Peer) *Peer {
PostUp: ConfigOptionFromDomain(src.Interface.PostUp),
PreDown: ConfigOptionFromDomain(src.Interface.PreDown),
PostDown: ConfigOptionFromDomain(src.Interface.PostDown),
Filename: src.GetConfigFileName(),
}
}