Filter out no bandwidth peers

This commit is contained in:
Owen
2026-01-16 17:54:05 -08:00
parent 060d876429
commit 91bfd69179

View File

@@ -1035,21 +1035,22 @@ func (s *WireGuardService) processPeerBandwidth(publicKey string, rxBytes, txByt
// Update the last reading // Update the last reading
s.lastReadings[publicKey] = currentReading s.lastReadings[publicKey] = currentReading
// Only return bandwidth data if there was an increase
if bytesInDiff > 0 || bytesOutDiff > 0 {
return &PeerBandwidth{ return &PeerBandwidth{
PublicKey: publicKey, PublicKey: publicKey,
BytesIn: bytesInMB, BytesIn: bytesInMB,
BytesOut: bytesOutMB, BytesOut: bytesOutMB,
} }
} }
return nil
}
} }
// For first reading or if readings are too close together, report 0 // For first reading or if readings are too close together, don't report
s.lastReadings[publicKey] = currentReading s.lastReadings[publicKey] = currentReading
return &PeerBandwidth{ return nil
PublicKey: publicKey,
BytesIn: 0,
BytesOut: 0,
}
} }
func (s *WireGuardService) reportPeerBandwidth() error { func (s *WireGuardService) reportPeerBandwidth() error {