Dont use bytes out for online

Persistant keep alive means that this will always increase
This commit is contained in:
Owen 2025-02-27 23:54:24 -05:00
parent 733e0e07c3
commit 8e4bccffbf
No known key found for this signature in database
GPG key ID: 8271FDFFD9E0CCBD

View file

@ -27,7 +27,7 @@ export const handleReceiveBandwidthMessage: MessageHandler = async (context) =>
for (const peer of bandwidthData) { for (const peer of bandwidthData) {
const { publicKey, bytesIn, bytesOut } = peer; const { publicKey, bytesIn, bytesOut } = peer;
// Find the site by public key // Find the client by public key
const [client] = await trx const [client] = await trx
.select() .select()
.from(clients) .from(clients)
@ -39,8 +39,8 @@ export const handleReceiveBandwidthMessage: MessageHandler = async (context) =>
} }
let online = client.online; let online = client.online;
// if the bandwidth for the site is > 0 then set it to online. if it has been less than 0 (no update) for 5 minutes then set it to offline // if the bandwidth for the client is > 0 then set it to online. if it has been less than 0 (no update) for 5 minutes then set it to offline
if (bytesIn > 0 || bytesOut > 0) { if (bytesIn > 0) { // only track the bytes in because we are always sending bytes out with persistent keep alive
online = true; online = true;
} else if (client.lastBandwidthUpdate) { } else if (client.lastBandwidthUpdate) {
const lastBandwidthUpdate = new Date( const lastBandwidthUpdate = new Date(
@ -54,7 +54,7 @@ export const handleReceiveBandwidthMessage: MessageHandler = async (context) =>
} }
} }
// Update the site's bandwidth usage // Update the client's bandwidth usage
await trx await trx
.update(clients) .update(clients)
.set({ .set({