@samitouri / QOSami-HFS / commits / a60c1329

fix: admin/logs/disconnections: order was inverted

Massimo Melina committed Jul 15, 2026 at 13:37 UTC a60c13294eddae9091cf9bea9c1bd395b3e28722
1 file changed +4 -3
src/connections.ts
+4 -3
@@ -96,8 +96,9 @@ export function disconnect(what: Context | Socket | Connection, logMessage='') {
96 console.debug("Disconnection:", logMessage, ip)
97 ip2country(ip).then(res => {
98 const rec = { ip, country: res || undefined, ts: new Date, msg: logMessage || undefined }
99 - disconnectionsLog.unshift(rec)
100 - disconnectionsLog.length = Math.min(1000, disconnectionsLog.length)
99 + disconnectionsLog.push(rec)
100 + if (disconnectionsLog.length > 1000)
101 + disconnectionsLog.shift()
102 events.emit('disconnection', rec)
103 })
104 return what.destroy()
@@ -118,4 +119,4 @@ events.once('app', app => { // can't simply import 'app', as it's not defined at
119 app.context.disconnect = function(logMessage='') {
120 return disconnect(this as Context, logMessage)
121 }
121 -})
\ No newline at end of file
122 +})