1
- // jbnc v0.6
1
+ // jbnc v0.7
2
2
// Copyright (C) 2020 Andrew Lee <andrew@imperialfamily.com>
3
3
// All Rights Reserved.
4
4
const tls = require ( 'tls' ) ;
@@ -249,7 +249,7 @@ server = doServer(tlsOptions,function(socket) {
249
249
}
250
250
else if ( commands [ 1 ] ) {
251
251
this . irc . nick = commands [ 1 ] . trim ( ) ;
252
- if ( this . irc . user ) {
252
+ if ( false && this . irc . user ) {
253
253
this . hash = hash ( this . irc . nick + this . irc . user + this . irc . password + this . irc . server + this . irc . port . toString ( ) ) ;
254
254
if ( connections [ socket . hash ] ) {
255
255
clientReconnect ( this ) ;
@@ -339,6 +339,8 @@ server = doServer(tlsOptions,function(socket) {
339
339
this . write ( ":*jbnc NOTICE * :CONN - Show which devices are connected to your bouncer user connection\n" ) ;
340
340
this . write ( ":*jbnc NOTICE * :BUFFERS - Show what buffers exist and their size\n" ) ;
341
341
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" ) ;
342
344
if ( ! this . admin )
343
345
this . write ( ":*jbnc NOTICE * :ADMIN - Get admin access\n" ) ;
344
346
else {
@@ -355,11 +357,20 @@ server = doServer(tlsOptions,function(socket) {
355
357
case 'CHANNELS' :
356
358
for ( key in connections [ this . hash ] . channels ) {
357
359
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" ) ;
359
361
}
360
362
}
361
363
this . write ( ":*jbnc NOTICE * :End of active channels\n" ) ;
362
364
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 ;
363
374
case 'OPMODE' :
364
375
if ( command [ 2 ] ) {
365
376
if ( command [ 2 ] . toLowerCase ( ) . trim ( ) == "on" ) {
@@ -655,6 +666,7 @@ function clientReconnect(socket) {
655
666
if ( _channel && _channel . name ) {
656
667
socket . write ( "@time=" + new Date ( ) . toISOString ( ) + ";msgid=back :" + connection . nick + "!" + connection . ircuser + "@" + connection . host + " JOIN :" + _channel . name + "\n" ) ;
657
668
} else {
669
+ console . error ( `${ parseInt ( Number ( new Date ( ) ) / 1000 ) } Probleme bug undefined on join : ${ JSON . stringify ( _channel ) } ` ) ;
658
670
continue ;
659
671
}
660
672
@@ -1010,7 +1022,7 @@ function clientConnect(socket) {
1010
1022
else if ( ( _target . indexOf ( "#" ) != - 1 || _target . indexOf ( "&" ) != - 1 ) && ( _mode [ i ] == 'o' || _mode [ i ] == 'k' || _mode [ i ] == 'v' || _mode [ i ] == 'h' || _mode [ i ] == 'l' ||
1011
1023
_mode [ i ] == 'e' || _mode [ i ] == 'b' || _mode [ i ] == 'I' || _mode [ i ] == 'q' || _mode [ i ] == 'f' ||
1012
1024
_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 ) {
1014
1026
for ( c = 0 ; c < curchan . names . length ; c ++ ) {
1015
1027
if ( curchan . names [ c ] . replace ( / ( & | ~ | @ | % | \+ ) / , "" ) == _mode_target [ _mode_count ] ) {
1016
1028
switch ( _mode [ i ] ) {
@@ -1094,7 +1106,7 @@ function clientConnect(socket) {
1094
1106
if ( ( _target . indexOf ( "#" ) != - 1 || _target . indexOf ( "&" ) != - 1 ) && ( _mode [ i ] == 'o' || _mode [ i ] == 'k' || _mode [ i ] == 'v' || _mode [ i ] == 'h' || _mode [ i ] == 'l' ||
1095
1107
_mode [ i ] == 'e' || _mode [ i ] == 'b' || _mode [ i ] == 'I' || _mode [ i ] == 'q' || _mode [ i ] == 'f' ||
1096
1108
_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 ) {
1098
1110
for ( c = 0 ; c < curchan . names . length ; c ++ ) {
1099
1111
if ( curchan . names [ c ] . replace ( / ( & | ~ | @ | % | \+ ) / , "" ) == _mode_target [ _mode_count ] ) {
1100
1112
switch ( _mode [ i ] ) {
@@ -1191,8 +1203,9 @@ function clientConnect(socket) {
1191
1203
}
1192
1204
else {
1193
1205
if ( this . channels [ __channel ] ) {
1206
+ this . channels [ __channel ] . name = _channel ;
1194
1207
this . channels [ __channel ] . names . push ( _nick ) ;
1195
- this . channels [ __channel ] . userhosts . push ( this . userHostInNames ?_userhost :"*@*" ) ;
1208
+ this . channels [ __channel ] . userhosts . push ( ! ! _userhost ?_userhost :"*@*" ) ;
1196
1209
if ( this . channels [ __channel ] . isop && this . channels [ __channel ] . aop && this . channels [ __channel ] . aop . indexOf ( _nick + "!" + _userhost ) >= 0 && this . opmode ) {
1197
1210
this . write ( "MODE " + this . channels [ __channel ] . name + " +o " + _nick + "\n" ) ;
1198
1211
}
0 commit comments