2018-03-10 15:47:00 +08:00
|
|
|
/*
|
2018-03-14 13:26:53 +08:00
|
|
|
Description: Legacy stats output, kept for compatibility, outputs user and channel count
|
2018-03-10 15:47:00 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
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',
|
2018-03-14 13:26:53 +08:00
|
|
|
text: `${uniqueClientCount} unique IPs in ${uniqueChannels} channels`
|
2018-03-10 15:47:00 +08:00
|
|
|
}, socket);
|
|
|
|
|
|
|
|
core.managers.stats.increment('stats-requested');
|
|
|
|
};
|
|
|
|
|
2018-05-13 18:33:22 +08:00
|
|
|
exports.info = {
|
|
|
|
name: 'stats',
|
|
|
|
description: 'Sends back legacy server stats to the calling client'
|
|
|
|
};
|