diff --git a/monitor.go b/monitor.go index a7896f3..1b88146 100644 --- a/monitor.go +++ b/monitor.go @@ -26,18 +26,22 @@ func monitor(wg *WGLink, log slog.Logger) { } sb := strings.Builder{} - var activePeers int var totalRx int64 var totalTx int64 for _, peer := range peers { totalRx += peer.ReceiveBytes totalTx += peer.TransmitBytes - if isActive(peer) { - activePeers += 1 + if !isActive(peer) { + log.Info( + fmt.Sprintf("[WGMonitor] Evecting peer %s", peer.PublicKey.String()), + ) + if err := wg.DeletePeer(peer.PublicKey.String()); err != nil { + log.Error(err.Error()) + log.Warn("[WGMonitor] Could not evect peer") + } } } sb.WriteString(fmt.Sprintf("Peers: %d ", len(peers))) - sb.WriteString(fmt.Sprintf("Active peers: %d ", activePeers)) sb.WriteString(fmt.Sprintf("TX: %d RX: %d", totalTx, totalRx)) log.Info("[WGMonitor] " + sb.String())