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

@@ -84,6 +84,9 @@ type Interface struct {
EnabledPeers int `json:"EnabledPeers" readonly:"true"`
// TotalPeers is the total number of peers for this interface.
TotalPeers int `json:"TotalPeers" readonly:"true"`
// Filename is the name of the config file for this interface.
// This value is read only and is not settable by the user.
Filename string `json:"Filename" example:"wg0.conf" binding:"omitempty,max=21" readonly:"true"`
}
func NewInterface(src *domain.Interface, peers []domain.Peer) *Interface {
@@ -123,6 +126,7 @@ func NewInterface(src *domain.Interface, peers []domain.Peer) *Interface {
EnabledPeers: 0,
TotalPeers: 0,
Filename: src.GetConfigFileName(),
}
if len(peers) > 0 {

View File

@@ -72,6 +72,10 @@ type Peer struct {
PreDown ConfigOption[string] `json:"PreDown"`
// PostDown is an optional action that is executed after the device is down.
PostDown ConfigOption[string] `json:"PostDown"`
// Filename is the name of the config file for this peer.
// This value is read only and is not settable by the user.
Filename string `json:"Filename" example:"wg_peer_x.conf" binding:"omitempty,max=21" readonly:"true"`
}
func NewPeer(src *domain.Peer) *Peer {
@@ -109,6 +113,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(),
}
}