fix: autosave wireguard conf files (#303)

* fix: autosave wireguard conf files

- Fix subscription to Interface and Peer updates topics
- Remove admin permissions validation
- Update file on peer deletion
- Change save condition to configured storage path only, as initialized interface is not nil

* Added  comment to peer config for prometheus exporter
This commit is contained in:
Dmytro Bondar
2024-09-22 11:53:42 +02:00
committed by GitHub
parent 605841f2a0
commit 2428dedc42
3 changed files with 27 additions and 34 deletions

View File

@@ -4,11 +4,12 @@ import (
"context"
"errors"
"fmt"
"time"
"github.com/h44z/wg-portal/internal"
"github.com/h44z/wg-portal/internal/app"
"github.com/h44z/wg-portal/internal/domain"
"github.com/sirupsen/logrus"
"time"
)
func (m Manager) CreateDefaultPeer(ctx context.Context, userId domain.UserIdentifier) error {
@@ -253,6 +254,11 @@ func (m Manager) DeletePeer(ctx context.Context, id domain.PeerIdentifier) error
return fmt.Errorf("failed to delete peer %s: %w", id, err)
}
// Update routes after peers have changed
m.bus.Publish(app.TopicRouteUpdate, "peers updated")
// Update interface after peers have changed
m.bus.Publish(app.TopicPeerInterfaceUpdated, peer.InterfaceIdentifier)
return nil
}