aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/core/stats.js
blob: 2802579c48b6ef80a937bd4214243b4ef9880426 (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
/*
  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' };