Skip to content

Commit 2e14678

Browse files
authored
Merge pull request #57 from Madriix/master
Update
2 parents 03a3c8a + 4f581dc commit 2e14678

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

bouncer.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// jbnc v0.6
1+
// jbnc v0.7
22
// Copyright (C) 2020 Andrew Lee <andrew@imperialfamily.com>
33
// All Rights Reserved.
44
const tls = require('tls');
@@ -249,7 +249,7 @@ server = doServer(tlsOptions,function(socket) {
249249
}
250250
else if(commands[1]) {
251251
this.irc.nick=commands[1].trim();
252-
if(this.irc.user) {
252+
if(false&&this.irc.user) {
253253
this.hash=hash(this.irc.nick+this.irc.user+this.irc.password+this.irc.server+this.irc.port.toString());
254254
if(connections[socket.hash]) {
255255
clientReconnect(this);
@@ -339,6 +339,8 @@ server = doServer(tlsOptions,function(socket) {
339339
this.write(":*jbnc NOTICE * :CONN - Show which devices are connected to your bouncer user connection\n");
340340
this.write(":*jbnc NOTICE * :BUFFERS - Show what buffers exist and their size\n");
341341
this.write(":*jbnc NOTICE * :OPMODE - Enable or disable auto-op/hop/voice\n");
342+
this.write(":*jbnc NOTICE * :CHANNELS - List all active channels\n");
343+
this.write(":*jbnc NOTICE * :USERHOSTS - List current state of userhosts\n");
342344
if(!this.admin)
343345
this.write(":*jbnc NOTICE * :ADMIN - Get admin access\n");
344346
else {
@@ -355,11 +357,20 @@ server = doServer(tlsOptions,function(socket) {
355357
case 'CHANNELS':
356358
for (key in connections[this.hash].channels) {
357359
if (connections[this.hash].channels.hasOwnProperty(key)) {
358-
this.write(":*jbnc NOTICE * :Active channel: "+connections[this.hash].channels[key].name+"\n");
360+
this.write(":*jbnc NOTICE * :Active channel: "+connections[this.hash].channels[key].name+"\n");
359361
}
360362
}
361363
this.write(":*jbnc NOTICE * :End of active channels\n");
362364
break;
365+
case 'USERHOSTS':
366+
for (key in connections[this.hash].channels) {
367+
if (connections[this.hash].channels.hasOwnProperty(key)) {
368+
for(x=0;x<connections[this.hash].channels[key].userhosts.length;x++)
369+
this.write(":*jbnc NOTICE * :"+x+") "+connections[this.hash].channels[key].userhosts[x]+" ("+connections[this.hash].channels[key].names[x]+")\n");
370+
}
371+
}
372+
this.write(":*jbnc NOTICE * :End of active userhosts\n");
373+
break;
363374
case 'OPMODE':
364375
if(command[2]) {
365376
if(command[2].toLowerCase().trim()=="on") {
@@ -655,6 +666,7 @@ function clientReconnect(socket) {
655666
if (_channel && _channel.name) {
656667
socket.write("@time="+new Date().toISOString()+";msgid=back :"+connection.nick+"!"+connection.ircuser+"@"+connection.host+" JOIN :"+_channel.name+"\n");
657668
} else {
669+
console.error(`${parseInt(Number(new Date()) / 1000)} Probleme bug undefined on join : ${JSON.stringify(_channel)}`);
658670
continue;
659671
}
660672

@@ -1010,7 +1022,7 @@ function clientConnect(socket) {
10101022
else if((_target.indexOf("#")!=-1||_target.indexOf("&")!=-1) && (_mode[i]=='o' || _mode[i]=='k' || _mode[i]=='v' || _mode[i]=='h' || _mode[i]=='l' ||
10111023
_mode[i]=='e' || _mode[i]=='b' || _mode[i]=='I' || _mode[i]=='q' || _mode[i]=='f' ||
10121024
_mode[i]=='j')) {
1013-
if(_mode[i]=='o' || _mode[i]=='v' || _mode[i]=='h') {
1025+
if(_mode[i]=='o' && curchan.names || _mode[i]=='v' && curchan.names || _mode[i]=='h' && curchan.names) {
10141026
for(c=0;c<curchan.names.length;c++) {
10151027
if(curchan.names[c].replace(/(&|~|@|%|\+)/,"")==_mode_target[_mode_count]) {
10161028
switch(_mode[i]) {
@@ -1094,7 +1106,7 @@ function clientConnect(socket) {
10941106
if((_target.indexOf("#")!=-1||_target.indexOf("&")!=-1) && (_mode[i]=='o' || _mode[i]=='k' || _mode[i]=='v' || _mode[i]=='h' || _mode[i]=='l' ||
10951107
_mode[i]=='e' || _mode[i]=='b' || _mode[i]=='I' || _mode[i]=='q' || _mode[i]=='f' ||
10961108
_mode[i]=='j')) {
1097-
if(_mode[i]=='o' || _mode[i]=='v' || _mode[i]=='h') {
1109+
if(_mode[i]=='o' && curchan.names || _mode[i]=='v' && curchan.names || _mode[i]=='h' && curchan.names) {
10981110
for(c=0;c<curchan.names.length;c++) {
10991111
if(curchan.names[c].replace(/(&|~|@|%|\+)/,"")==_mode_target[_mode_count]) {
11001112
switch(_mode[i]) {
@@ -1191,8 +1203,9 @@ function clientConnect(socket) {
11911203
}
11921204
else {
11931205
if(this.channels[__channel]) {
1206+
this.channels[__channel].name=_channel;
11941207
this.channels[__channel].names.push(_nick);
1195-
this.channels[__channel].userhosts.push(this.userHostInNames?_userhost:"*@*");
1208+
this.channels[__channel].userhosts.push(!!_userhost?_userhost:"*@*");
11961209
if(this.channels[__channel].isop && this.channels[__channel].aop && this.channels[__channel].aop.indexOf(_nick+"!"+_userhost)>=0 && this.opmode) {
11971210
this.write("MODE "+this.channels[__channel].name+" +o "+_nick+"\n");
11981211
}

0 commit comments

Comments
 (0)