From 8e4bccffbffe06ed5eaa730e06d10996df051714 Mon Sep 17 00:00:00 2001 From: Owen Date: Thu, 27 Feb 2025 23:54:24 -0500 Subject: [PATCH] Dont use bytes out for online Persistant keep alive means that this will always increase --- server/routers/newt/handleReceiveBandwidthMessage.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/routers/newt/handleReceiveBandwidthMessage.ts b/server/routers/newt/handleReceiveBandwidthMessage.ts index a20e2426..80b0c57d 100644 --- a/server/routers/newt/handleReceiveBandwidthMessage.ts +++ b/server/routers/newt/handleReceiveBandwidthMessage.ts @@ -27,7 +27,7 @@ export const handleReceiveBandwidthMessage: MessageHandler = async (context) => for (const peer of bandwidthData) { const { publicKey, bytesIn, bytesOut } = peer; - // Find the site by public key + // Find the client by public key const [client] = await trx .select() .from(clients) @@ -39,8 +39,8 @@ export const handleReceiveBandwidthMessage: MessageHandler = async (context) => } 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 (bytesIn > 0 || bytesOut > 0) { + // 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) { // only track the bytes in because we are always sending bytes out with persistent keep alive online = true; } else if (client.lastBandwidthUpdate) { 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 .update(clients) .set({