diff options
author | Neel Kamath <neelkamath@protonmail.com> | 2018-05-13 12:39:55 +0200 |
---|---|---|
committer | Neel Kamath <neelkamath@protonmail.com> | 2018-05-13 12:39:55 +0200 |
commit | 2bb5ced363b692a5696b176bc317fe525c0c05df (patch) | |
tree | 1532d9456c5f2b25ac05f7cec620a3af890eff83 /server/commands/core/stats.js | |
parent | Re-add module documentation (diff) | |
download | hackchat-2bb5ced363b692a5696b176bc317fe525c0c05df.tar.gz hackchat-2bb5ced363b692a5696b176bc317fe525c0c05df.zip |
Flatten
Diffstat (limited to 'server/commands/core/stats.js')
-rw-r--r-- | server/commands/core/stats.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/server/commands/core/stats.js b/server/commands/core/stats.js new file mode 100644 index 0000000..b9dc002 --- /dev/null +++ b/server/commands/core/stats.js @@ -0,0 +1,32 @@ +/* + Description: Legacy stats output, kept for compatibility, outputs user and channel count +*/ + +exports.run = async (core, server, socket, data) => { + 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; + + server.reply({ + cmd: 'info', + text: `${uniqueClientCount} unique IPs in ${uniqueChannels} channels` + }, socket); + + core.managers.stats.increment('stats-requested'); +}; + +exports.info = { + name: 'stats', + description: 'Sends back legacy server stats to the calling client' +};
\ No newline at end of file |