mirror of
https://github.com/fosrl/newt.git
synced 2026-02-08 05:56:40 +00:00
Filter out no bandwidth peers
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user