Skip to content

Commit 73f18fb

Browse files
authored
Merge pull request #79 from Madriix/master
Correction: "Cannot create property 'mobile' on boolean 'false'"
2 parents 2d8a784 + a550d20 commit 73f18fb

File tree

2 files changed

+38
-16
lines changed

2 files changed

+38
-16
lines changed

bouncer.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ global.SERVER = global.BOUNCER_MODE == 'gateway' ? (config.server ? config.serve
3737
global.MSG_REDISTRIBUTION = config.MsgRedistribution ? true : false;
3838
global.DEBUG = config.debug ? config.debug : false;
3939
global.WEBIRCSPECIAL = config.webircSpecial ? config.webircSpecial : false;
40+
global.IRC_STANDARDS = config.ircStandards ? config.ircStandards : true;
41+
global.UNCAUGHTEXCEPTION = config.uncaughtException ? config.uncaughtException : true;
4042

4143
global.ircCommandList = new Set(["JOIN", "PART", "QUIT", "MODE", "PING", "NICK", "KICK"]);
4244
global.ircCommandRedistributeMessagesOnConnect = new Set(["AWAY", "NICK", "ACCOUNT", "PART", "QUIT", "MODE", "KICK", "TOPIC"]);
@@ -53,12 +55,12 @@ process.on('SIGHUP', function () {
5355
global.BOUNCER_ADMIN = config.bouncerAdmin ? config.bouncerAdmin : '';
5456
});
5557

56-
/*
57-
// Prevent BNC from crashing for all other users when an error is caused by a user (with log error and time)
58-
process.on('uncaughtException', (err, origin) => {
59-
console.error(`${parseInt(Number(new Date()) / 1000)} # Serious problem (${origin}) - this should not happen but the JBNC is still running. ${err.stack}`);
60-
});
61-
*/
58+
if (global.UNCAUGHTEXCEPTION) {
59+
// Prevent BNC from crashing for all other users when an error is caused by a user (with log error and time)
60+
process.on('uncaughtException', (err, origin) => {
61+
console.error(`${parseInt(Number(new Date()) / 1000)} # Serious problem (${origin}) - this should not happen but the JBNC is still running. ${err.stack}`);
62+
});
63+
}
6264

6365
const jBNC = require('./lib/Server');
6466

lib/ClientConnect.js

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -719,23 +719,43 @@ class ClientConnect {
719719
case '433': // ERR_NICKNAMEINUSE
720720
if (this.client.parents.length == 0) {
721721
if (data[2] == '*') {
722-
if (global.DEBUG)
723-
console.log("Une erreur 433 est détecté, un quit ?");
724-
this.client.end();
725-
/*this.write("NICK "+data[3].trim()+"_"+"\n");
726-
this.nick=data[3].trim()+"_";*/
722+
if (global.IRC_STANDARDS) {
723+
this.write("NICK "+data[3].trim()+"_"+"\n");
724+
this.nick=data[3].trim()+"_";
725+
} else {
726+
if (global.DEBUG)
727+
console.log("ERROR 433 is detected. Quit ?");
728+
this.client.end();
729+
}
727730
}
731+
} else {
732+
if (global.DEBUG)
733+
console.log("ERROR 433 !this.client.parents.length is detected. Quit ?");
734+
try {
735+
this.connections[this.client.hash].end();
736+
} catch (e) { }
737+
delete this.connections[this.client.hash];
728738
}
729739
break;
730740
case '451': // ERR_NOTREGISTERED
731741
if (this.client.parents.length == 0) {
732742
if (data[2] == '*') {
733-
if (global.DEBUG)
734-
console.log("Une erreur 451 est détecté, un quit ?");
735-
this.client.end();
736-
/*this.write("NICK "+data[3].trim()+"_"+"\n");
737-
this.nick=data[3].trim()+"_";*/
743+
if (global.IRC_STANDARDS) {
744+
this.write("NICK "+data[3].trim()+"_"+"\n");
745+
this.nick=data[3].trim()+"_";
746+
} else {
747+
if (global.DEBUG)
748+
console.log("ERROR 451 is detected. Quit ?");
749+
this.client.end();
750+
}
738751
}
752+
} else {
753+
if (global.DEBUG)
754+
console.log("ERROR 451 !this.client.parents.length is detected. Quit ?");
755+
try {
756+
this.connections[this.client.hash].end();
757+
} catch (e) { }
758+
delete this.connections[this.client.hash];
739759
}
740760
break;
741761
}

0 commit comments

Comments
 (0)