Skip to content

Commit 58fd8f2

Browse files
authored
Merge pull request #19 from Madriix/master
Update bouncer.js
2 parents 5f582d9 + 803b49d commit 58fd8f2

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

bouncer.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ server = doServer(tlsOptions,function(socket) {
560560
connections[this.hash].connected=false;
561561
connections[this.hash].write("AWAY :jbnc\n");
562562
if(BOUNCER_TIMEOUT!=0 && BOUNCER_TIMEOUT!=null) {
563-
connections[this.hash].gone=setTimeout(function(x){connections[x].end();},BOUNCER_TIMEOUT*1000,this.hash);
563+
connections[this.hash].gone=setTimeout(function(x){connections[x].end();delete connections[x];},BOUNCER_TIMEOUT*1000,this.hash);
564564
}
565565
}
566566
}
@@ -748,13 +748,17 @@ function clientConnect(socket) {
748748
console.log("Connection created.");
749749
});
750750
connection.on('data', function(d){
751-
if(d.toString().substr(d.length-1)!="\n")
752-
this._buffer+=d.toString();
753-
else {
754-
_d = this._buffer + d.toString();
755-
this._buffer='';
756-
lines= _d.split("\n");
757-
for(n=0;n<lines.length;n++) {
751+
_d = this._buffer + d.toString();
752+
let lines = _d.toString().split('\n');
753+
if (lines[lines.length - 1] !== '') {
754+
this._buffer = lines.pop();
755+
} else {
756+
lines.pop();
757+
this._buffer = '';
758+
}
759+
760+
if (true) {
761+
for(let n=0;n<lines.length;n++) {
758762
if(DEBUG)
759763
console.log("> "+lines[n]);
760764
data = lines[n].trim().split(" ");

0 commit comments

Comments
 (0)