Skip to content

Commit 81bb977

Browse files
authored
Merge pull request #31 from Madriix/master
Fixed undefined in userhosts
2 parents c545006 + 4c58662 commit 81bb977

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

bouncer.js

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ function clientConnect(socket) {
805805
}
806806

807807
if (true) {
808-
for(let n=0;n<lines.length;n++) {
808+
for(n=0;n<lines.length;n++) {
809809
if(DEBUG)
810810
console.log("> "+lines[n]);
811811
data = lines[n].trim().split(" ");
@@ -862,9 +862,18 @@ function clientConnect(socket) {
862862
continue;
863863
}
864864

865-
if(SASL && data[1]=="903") {
866-
this.write("CAP END\n");
867-
continue;
865+
// :irc.server 904 <nick> :SASL authentication failed
866+
if(data[1]=="904") {
867+
if(!this.authenticated) {
868+
this.end();
869+
}
870+
}
871+
872+
// :x 903 y :SASL authentication successful
873+
if(data[1]=="903") {
874+
if(!this.authenticated) {
875+
this.write("CAP END\n");
876+
}
868877
}
869878

870879
let s = (data[2]=="JOIN" || data[2]=="PART" || data[2]=="QUIT" || data[2]=="MODE" || data[2]=="PING" || data[2]=="NICK" || data[2]=="KICK" ? data[2] : data[1]);
@@ -1207,10 +1216,14 @@ function clientConnect(socket) {
12071216
}
12081217
for(x=0;x<_names.length;x++) {
12091218
this.channels[_channel].names.push(_names[x].trim().split("!")[0]);
1210-
if(typeof this.channels[_channel].userhosts !== 'undefined' && _names[x].trim().indexOf("!")>=0)
1219+
1220+
if (typeof this.channels[_channel].userhosts === 'undefined')
1221+
this.channels[_channel].userhosts=[];
1222+
1223+
if(_names[x].trim().indexOf("!")>=0)
12111224
this.channels[_channel].userhosts.push(_names[x].trim().split("!")[1]);
1212-
/*else
1213-
this.channels[_channel].userhosts.push("*@*"); */
1225+
/*else
1226+
this.channels[_channel].userhosts.push("*@*"); */
12141227
}
12151228
break;
12161229
case '366':
@@ -1247,7 +1260,7 @@ function clientConnect(socket) {
12471260
}
12481261
break;
12491262
}
1250-
if(data[1] == "PING") {
1263+
if(data[1] == "PING") {
12511264
this.write("PONG "+data[2].substr(1).trim()+"\n");
12521265
continue;
12531266
}
@@ -1291,7 +1304,7 @@ function clientConnect(socket) {
12911304
this.parents[x].end();
12921305
}
12931306
this.buffers=false;
1294-
delete connections[hash(this.nick+this.password+this.server+this.port.toString())];
1307+
delete connections[hash(this.nick+this.password+this.server+this.port.toString())];
12951308
this.destroy();
12961309
});
12971310
connection.on('error', function(err) {

0 commit comments

Comments
 (0)