MODE fix, hourly status report in console
This commit is contained in:
parent
4127533f8b
commit
10abaa5706
@ -212,11 +212,13 @@ class IRCConnectionHandler {
|
|||||||
case "251":
|
case "251":
|
||||||
case "290":
|
case "290":
|
||||||
case "292":
|
case "292":
|
||||||
|
case "381":
|
||||||
case "255":
|
case "255":
|
||||||
this.conn.emit('pass_to_client', {type: "server_message", messageType: "regular", message: line.trailing, server: serverName, from: realServerName});
|
this.conn.emit('pass_to_client', {type: "server_message", messageType: "regular", message: line.trailing, server: serverName, from: realServerName});
|
||||||
break;
|
break;
|
||||||
case "252":
|
case "252":
|
||||||
case "254":
|
case "254":
|
||||||
|
case "396":
|
||||||
case "042":
|
case "042":
|
||||||
this.conn.emit('pass_to_client', {type: "server_message", messageType: "regular", message: line.arguments[1] +" "+ line.trailing, server: serverName, from: realServerName});
|
this.conn.emit('pass_to_client', {type: "server_message", messageType: "regular", message: line.arguments[1] +" "+ line.trailing, server: serverName, from: realServerName});
|
||||||
break;
|
break;
|
||||||
@ -237,6 +239,14 @@ class IRCConnectionHandler {
|
|||||||
isChannelMode = true;
|
isChannelMode = true;
|
||||||
|
|
||||||
let modes = line.arguments[1];
|
let modes = line.arguments[1];
|
||||||
|
|
||||||
|
if(!modes && line.trailing != '')
|
||||||
|
modes = line.trailing;
|
||||||
|
|
||||||
|
let sender = line.user.nickname;
|
||||||
|
if(sender == '')
|
||||||
|
sender = line.user.hostname;
|
||||||
|
|
||||||
method = modes.substring(0, 1);
|
method = modes.substring(0, 1);
|
||||||
modes = modes.substring(1).split('');
|
modes = modes.substring(1).split('');
|
||||||
let pass = [];
|
let pass = [];
|
||||||
@ -246,7 +256,7 @@ class IRCConnectionHandler {
|
|||||||
let mode = modes[i];
|
let mode = modes[i];
|
||||||
if(this.conn.data.supportedModes[mode])
|
if(this.conn.data.supportedModes[mode])
|
||||||
this.conn.emit('pass_to_client', {type: "mode_"+(method=='+'?'add':'del'), target: line.arguments[0], mode: mode,
|
this.conn.emit('pass_to_client', {type: "mode_"+(method=='+'?'add':'del'), target: line.arguments[0], mode: mode,
|
||||||
modeTarget: line.arguments[2+parseInt(i)], server: serverName, user: line.user});
|
modeTarget: line.arguments[2+parseInt(i)], server: serverName, user: {nickname: sender}});
|
||||||
else
|
else
|
||||||
pass.push(mode);
|
pass.push(mode);
|
||||||
}
|
}
|
||||||
@ -255,8 +265,8 @@ class IRCConnectionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(pass.length > 0)
|
if(pass.length > 0)
|
||||||
this.conn.emit('pass_to_client', {type: "mode", target: line.arguments[0], message: line.arguments.slice(1).join(" "),
|
this.conn.emit('pass_to_client', {type: "mode", target: line.arguments[0], message: method+pass.join(''),
|
||||||
server: serverName, user: line.user});
|
server: serverName, user: {nickname: sender}});
|
||||||
break;
|
break;
|
||||||
case "433":
|
case "433":
|
||||||
let newNick = this.conn.config.nickname + "_";
|
let newNick = this.conn.config.nickname + "_";
|
||||||
|
34
teemant.js
34
teemant.js
@ -13,6 +13,10 @@ let ircclient = require(__dirname+'/server/irc');
|
|||||||
|
|
||||||
let port = config.server.port || 8080;
|
let port = config.server.port || 8080;
|
||||||
|
|
||||||
|
let runtime_stats = {
|
||||||
|
connectionsMade: 0
|
||||||
|
};
|
||||||
|
|
||||||
let connections = {};
|
let connections = {};
|
||||||
|
|
||||||
process.stdin.resume();
|
process.stdin.resume();
|
||||||
@ -29,8 +33,31 @@ app.use('/', express.static(pubdir, { maxAge: 365*24*60*60*1000 }));
|
|||||||
app.use('/:server', express.static(pubdir, { maxAge: 365*24*60*60*1000 }));
|
app.use('/:server', express.static(pubdir, { maxAge: 365*24*60*60*1000 }));
|
||||||
app.use('/', router);
|
app.use('/', router);
|
||||||
|
|
||||||
|
function printRuntimeStats() {
|
||||||
|
let date = new Date();
|
||||||
|
let users = 0;
|
||||||
|
let servers = 0;
|
||||||
|
let serversPerUser = 0;
|
||||||
|
|
||||||
|
for(let uid in connections) {
|
||||||
|
let c = connections[uid];
|
||||||
|
users += 1;
|
||||||
|
for(let snam in c) {
|
||||||
|
if(snam == "host") continue;
|
||||||
|
let snam = c[snam];
|
||||||
|
servers += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(servers != 0)
|
||||||
|
serversPerUser = users/servers;
|
||||||
|
|
||||||
|
console.log(""+date+": Currently connected users: "+users+"; IRC server connections: "+servers+"; Average servers per user: "+serversPerUser);
|
||||||
|
}
|
||||||
|
|
||||||
let io = sockio.listen(app.listen(port, function() {
|
let io = sockio.listen(app.listen(port, function() {
|
||||||
console.log("*** Listening on http://localhost:" + port + "/");
|
console.log("*** Listening on http://localhost:" + port + "/");
|
||||||
|
setInterval(printRuntimeStats, 3600000);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function resolveHostname(ipaddr) {
|
function resolveHostname(ipaddr) {
|
||||||
@ -66,7 +93,10 @@ io.sockets.on('connection', function (socket) {
|
|||||||
hostQuery.then((arr) => {
|
hostQuery.then((arr) => {
|
||||||
if(arr.length > 0)
|
if(arr.length > 0)
|
||||||
connections[socket.id].host.hostname = arr[0];
|
connections[socket.id].host.hostname = arr[0];
|
||||||
}).catch((err) => { console.log("Host resolve for "+socket.id+" failed: ", err); });
|
}).catch((err) => {
|
||||||
|
if(config.server.debug)
|
||||||
|
console.log("Host resolve for "+socket.id+" failed: ", err);
|
||||||
|
});
|
||||||
|
|
||||||
if(config.server.debug)
|
if(config.server.debug)
|
||||||
console.log("Hostname of "+socket.id+" was determined to be "+connections[socket.id].host.hostname);
|
console.log("Hostname of "+socket.id+" was determined to be "+connections[socket.id].host.hostname);
|
||||||
@ -114,6 +144,8 @@ io.sockets.on('connection', function (socket) {
|
|||||||
socket.emit('act_client', {type: "event_connect", address: connectiondata.server, network: newConnection.data.network,
|
socket.emit('act_client', {type: "event_connect", address: connectiondata.server, network: newConnection.data.network,
|
||||||
supportedModes: newConnection.data.supportedModes, nickname: newConnection.config.nickname,
|
supportedModes: newConnection.data.supportedModes, nickname: newConnection.config.nickname,
|
||||||
max_channel_length: newConnection.data.max_channel_length});
|
max_channel_length: newConnection.data.max_channel_length});
|
||||||
|
|
||||||
|
runtime_stats.connectionsMade += 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
if(config.server.debug) {
|
if(config.server.debug) {
|
||||||
|
Reference in New Issue
Block a user