mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-29 15:14:56 +02:00
Dont use bytes out for online
Persistant keep alive means that this will always increase
This commit is contained in:
parent
733e0e07c3
commit
8e4bccffbf
1 changed files with 4 additions and 4 deletions
|
@ -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({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue