mirror of
https://github.com/fosrl/olm.git
synced 2026-02-07 21:46:40 +00:00
Fix order of when to add peer monitoring
This commit is contained in:
32
main.go
32
main.go
@@ -311,22 +311,6 @@ func main() {
|
||||
logger.Error("Failed to configure interface: %v", err)
|
||||
}
|
||||
|
||||
// loop over the sites and call ConfigurePeer for each one
|
||||
for _, site := range wgData.Sites {
|
||||
if httpServer != nil {
|
||||
httpServer.UpdatePeerStatus(site.SiteId, false, 0)
|
||||
}
|
||||
err = ConfigurePeer(dev, site, privateKey, endpoint)
|
||||
if err != nil {
|
||||
logger.Error("Failed to configure peer: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
DarwinAddRoute(site.ServerIP, "", interfaceName)
|
||||
|
||||
logger.Info("Configured peer %s", site.PublicKey)
|
||||
}
|
||||
|
||||
peerMonitor = peermonitor.NewPeerMonitor(
|
||||
func(siteID int, connected bool, rtt time.Duration) {
|
||||
if httpServer != nil {
|
||||
@@ -343,6 +327,22 @@ func main() {
|
||||
dev,
|
||||
)
|
||||
|
||||
// loop over the sites and call ConfigurePeer for each one
|
||||
for _, site := range wgData.Sites {
|
||||
if httpServer != nil {
|
||||
httpServer.UpdatePeerStatus(site.SiteId, false, 0)
|
||||
}
|
||||
err = ConfigurePeer(dev, site, privateKey, endpoint)
|
||||
if err != nil {
|
||||
logger.Error("Failed to configure peer: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
DarwinAddRoute(site.ServerIP, "", interfaceName)
|
||||
|
||||
logger.Info("Configured peer %s", site.PublicKey)
|
||||
}
|
||||
|
||||
peerMonitor.Start()
|
||||
|
||||
logger.Info("WireGuard device created.")
|
||||
|
||||
Reference in New Issue
Block a user