blob: b271bb1e3810b47a3f9da9c78b3c11e20e26d159 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
/*
Description: Legacy stats output, kept for compatibility, outputs user and channel count
*/
// module main
exports.run = async (core, server, socket, data) => {
// gather connection and channel count
let ips = {};
let channels = {};
for (let client of server.clients) {
if (client.channel) {
channels[client.channel] = true;
ips[client.remoteAddress] = true;
}
}
let uniqueClientCount = Object.keys(ips).length;
let uniqueChannels = Object.keys(channels).length;
ips = null;
channels = null;
// dispatch info
server.reply({
cmd: 'info',
text: `${uniqueClientCount} unique IPs in ${uniqueChannels} channels`
}, socket);
// stats are fun
core.managers.stats.increment('stats-requested');
};
// module meta
exports.info = {
name: 'stats',
description: 'Sends back legacy server stats to the calling client',
usage: `
API: { cmd: 'stats' }`
};
|