@@ -696,6 +696,7 @@ function clientConnect(socket) {
696
696
connection . authenticated = false ;
697
697
connection . connected = true ;
698
698
connection . opmode = BOUNCER_DEFAULT_OPMODE ;
699
+ connection . userhostInNames = false ;
699
700
700
701
// Temp Buffer
701
702
connection . _buffer = '' ;
@@ -740,12 +741,14 @@ function clientConnect(socket) {
740
741
data = lines [ n ] . trim ( ) . split ( " " ) ;
741
742
if ( data [ 1 ] == "CAP" ) {
742
743
if ( data [ 3 ] && data [ 3 ] == 'LS' ) {
743
- if ( lines [ n ] . trim ( ) . indexOf ( "multi-prefix" ) > 0 ) {
744
+ if ( lines [ n ] . trim ( ) . indexOf ( "multi-prefix" ) >= 0 ) {
744
745
this . write ( "CAP REQ :multi-prefix\n" ) ;
745
746
}
746
- else {
747
- this . write ( "CAP END\n" ) ;
747
+ if ( lines [ n ] . trim ( ) . indexOf ( "userhost-in-names" ) >= 0 ) {
748
+ this . write ( "CAP REQ :userhost-in-names\n" ) ;
749
+ this . userhostInNames = true ;
748
750
}
751
+ this . write ( "CAP END\n" ) ;
749
752
}
750
753
else {
751
754
this . write ( "CAP END\n" ) ;
@@ -813,15 +816,17 @@ function clientConnect(socket) {
813
816
if ( curchan . names [ c ] . replace ( "@" , "" ) . replace ( "+" , "" ) . replace ( "%" , "" ) == _mode_target [ _mode_count ] ) {
814
817
switch ( _mode [ i ] ) {
815
818
case 'o' :
819
+ _this_target = _mode_target [ _mode_count ] + "!" + ( curchan . userhosts [ c ] ?curchan . userhosts [ c ] :"*@*" ) ;
816
820
if ( curchan . names [ c ] . indexOf ( "@" ) == - 1 ) {
817
821
curchan . names [ c ] = "@" + curchan . names [ c ] ;
818
- if ( _mode_target [ _mode_count ] != this . nick && curchan . aop . indexOf ( _mode_target [ _mode_count ] ) < 0 && this . opmode ) {
819
- curchan . aop . push ( _mode_target [ _mode_count ] ) ;
822
+ if ( _mode_target [ _mode_count ] != this . nick && curchan . aop . indexOf ( _this_target ) < 0 && this . opmode ) {
823
+ curchan . aop . push ( _this_target ) ;
820
824
}
821
825
}
822
826
if ( _mode_target [ _mode_count ] == this . nick ) curchan . isop = true ;
823
827
break ;
824
828
case 'v' :
829
+ _this_target = _mode_target [ _mode_count ] + "!" + ( curchan . userhosts [ c ] ?curchan . userhosts [ c ] :"*@*" ) ;
825
830
if ( curchan . names [ c ] . indexOf ( "+" ) == - 1 ) {
826
831
if ( curchan . names [ c ] . indexOf ( "@" ) == - 1 ) {
827
832
if ( curchan . names [ c ] . indexOf ( "%" ) == - 1 ) {
@@ -839,21 +844,22 @@ function clientConnect(socket) {
839
844
curchan . names [ c ] = curchan . names [ c ] . substr ( 0 , 2 ) + "+" + curchan . names [ c ] . substr ( 2 ) ;
840
845
}
841
846
}
842
- if ( _mode_target [ _mode_count ] != this . nick && curchan . aov . indexOf ( _mode_target [ _mode_count ] ) < 0 && this . opmode ) {
843
- curchan . aov . push ( _mode_target [ _mode_count ] ) ;
847
+ if ( _mode_target [ _mode_count ] != this . nick && curchan . aov . indexOf ( _this_target ) < 0 && this . opmode ) {
848
+ curchan . aov . push ( _mode_target [ _this_target ] ) ;
844
849
}
845
850
}
846
851
if ( _mode_target [ _mode_count ] == this . nick ) curchan . isvoice = true ;
847
852
break ;
848
853
case 'h' :
854
+ _this_target = _mode_target [ _mode_count ] + "!" + ( curchan . userhosts [ c ] ?curchan . userhosts [ c ] :"*@*" ) ;
849
855
if ( curchan . names [ c ] . indexOf ( "%" ) == - 1 ) {
850
856
if ( curchan . names [ c ] . indexOf ( "@" ) == - 1 ) {
851
857
curchan . names [ c ] = "%" + curchan . names [ c ] ;
852
858
}
853
859
else
854
860
curchan . names [ c ] = curchan . names [ c ] . substr ( 0 , 1 ) + "%" + curchan . names [ c ] . substr ( 1 ) ;
855
- if ( _mode_target [ _mode_count ] != this . nick && curchan . aoh . indexOf ( _mode_target [ _mode_count ] ) < 0 && this . opmode ) {
856
- curchan . aoh . push ( _mode_target [ _mode_count ] ) ;
861
+ if ( _mode_target [ _mode_count ] != this . nick && curchan . aoh . indexOf ( _this_target ) < 0 && this . opmode ) {
862
+ curchan . aoh . push ( _mode_target [ _this_target ] ) ;
857
863
}
858
864
}
859
865
if ( _mode_target [ _mode_count ] == this . nick ) curchan . ishop = true ;
@@ -894,23 +900,26 @@ function clientConnect(socket) {
894
900
if ( curchan . names [ c ] . replace ( / \@ / , "" ) . replace ( / \% / , "" ) . replace ( / \+ / , "" ) == _mode_target [ _mode_count ] ) {
895
901
switch ( _mode [ i ] ) {
896
902
case 'o' :
903
+ _this_target = _mode_target [ _mode_count ] + "!" + ( curchan . userhosts [ c ] ?curchan . userhosts [ c ] :"*@*" ) ;
897
904
curchan . names [ c ] = curchan . names [ c ] . replace ( "@" , "" ) ;
898
- if ( _mode_target [ _mode_count ] != this . nick && curchan . aop . indexOf ( _mode_target [ _mode_count ] ) >= 0 && this . opmode ) {
899
- curchan . aop . splice ( curchan . aop . indexOf ( _mode_target [ _mode_count ] ) , 1 ) ;
905
+ if ( _mode_target [ _mode_count ] != this . nick && curchan . aop . indexOf ( _this_target ) >= 0 && this . opmode ) {
906
+ curchan . aop . splice ( curchan . aop . indexOf ( _this_target ) , 1 ) ;
900
907
}
901
908
if ( _mode_target [ _mode_count ] == this . nick ) this . isop = false ;
902
909
break ;
903
910
case 'v' :
911
+ _this_target = _mode_target [ _mode_count ] + "!" + ( curchan . userhosts [ c ] ?curchan . userhosts [ c ] :"*@*" ) ;
904
912
curchan . names [ c ] = curchan . names [ c ] . replace ( "+" , "" ) ;
905
- if ( _mode_target [ _mode_count ] != this . nick && curchan . aov . indexOf ( _mode_target [ _mode_count ] ) >= 0 && this . opmode ) {
906
- curchan . aov . splice ( curchan . aov . indexOf ( _mode_target [ _mode_count ] ) , 1 ) ;
913
+ if ( _mode_target [ _mode_count ] != this . nick && curchan . aov . indexOf ( _this_target ) >= 0 && this . opmode ) {
914
+ curchan . aov . splice ( curchan . aov . indexOf ( _this_target ) , 1 ) ;
907
915
}
908
916
if ( _mode_target [ _mode_count ] == this . nick ) this . isvoice = false ;
909
917
break ;
910
918
case 'h' :
919
+ _this_target = _mode_target [ _mode_count ] + "!" + ( curchan . userhosts [ c ] ?curchan . userhosts [ c ] :"*@*" ) ;
911
920
curchan . names [ c ] = curchan . names [ c ] . replace ( "%" , "" ) ;
912
- if ( _mode_target [ _mode_count ] != this . nick && curchan . aoh . indexOf ( _mode_target [ _mode_count ] ) >= 0 && this . opmode ) {
913
- curchan . aoh . splice ( curchan . aoh . indexOf ( _mode_target [ _mode_count ] ) , 1 ) ;
921
+ if ( _mode_target [ _mode_count ] != this . nick && curchan . aoh . indexOf ( _this_target ) >= 0 && this . opmode ) {
922
+ curchan . aoh . splice ( curchan . aoh . indexOf ( _this_target ) , 1 ) ;
914
923
}
915
924
if ( _mode_target [ _mode_count ] == this . nick ) this . ishop = false ;
916
925
break ;
@@ -947,6 +956,8 @@ function clientConnect(socket) {
947
956
case 'JOIN' :
948
957
_temp = data [ 0 ] . substr ( 1 ) . split ( "!" ) ;
949
958
_nick = _temp [ 0 ] ;
959
+ if ( _temp [ 1 ] )
960
+ _userhost = _temp [ 1 ] ;
950
961
if ( _temp [ 1 ] && this . nick == _nick ) {
951
962
this . ircuser = _temp [ 1 ] . split ( "@" ) [ 0 ] ;
952
963
}
@@ -968,6 +979,7 @@ function clientConnect(socket) {
968
979
this . channels [ __channel ] . forward = null ;
969
980
this . channels [ __channel ] . throttle = null ;
970
981
this . channels [ __channel ] . names = [ ] ;
982
+ this . channels [ __channel ] . userhosts = [ ] ;
971
983
this . channels [ __channel ] . name = _channel ;
972
984
this . channels [ __channel ] . aop = [ ] ;
973
985
this . channels [ __channel ] . aoh = [ ] ;
@@ -979,14 +991,15 @@ function clientConnect(socket) {
979
991
}
980
992
else {
981
993
if ( this . channels [ __channel ] ) {
982
- this . channels [ __channel ] . names [ this . channels [ __channel ] . names . length ] = _nick ;
983
- if ( this . channels [ __channel ] . isop && this . channels [ __channel ] . aop . indexOf ( _nick ) >= 0 && this . opmode ) {
994
+ this . channels [ __channel ] . names . push ( _nick ) ;
995
+ this . channels [ __channel ] . userhosts . push ( this . userHostInNames ?_userhost :"*@*" ) ;
996
+ if ( this . channels [ __channel ] . isop && this . channels [ __channel ] . aop . indexOf ( _nick + "!" + _userhost ) >= 0 && this . opmode ) {
984
997
this . write ( "MODE " + this . channels [ __channel ] . name + " +o " + _nick + "\n" ) ;
985
998
}
986
- if ( ( this . channels [ __channel ] . isop || this . channels [ __channel ] . ishop ) && this . channels [ __channel ] . aoh . indexOf ( _nick ) >= 0 && this . opmode ) {
999
+ if ( ( this . channels [ __channel ] . isop || this . channels [ __channel ] . ishop ) && this . channels [ __channel ] . aoh . indexOf ( _nick + "!" + _userhost ) >= 0 && this . opmode ) {
987
1000
this . write ( "MODE " + this . channels [ __channel ] . name + " +h " + _nick + "\n" ) ;
988
1001
}
989
- if ( ( this . channels [ __channel ] . isop || this . channels [ __channel ] . ishop ) && this . channels [ __channel ] . aov . indexOf ( _nick ) >= 0 && this . opmode ) {
1002
+ if ( ( this . channels [ __channel ] . isop || this . channels [ __channel ] . ishop ) && this . channels [ __channel ] . aov . indexOf ( _nick + "!" + _userhost ) >= 0 && this . opmode ) {
990
1003
this . write ( "MODE " + this . channels [ __channel ] . name + " +v " + _nick + "\n" ) ;
991
1004
}
992
1005
}
@@ -1042,6 +1055,7 @@ function clientConnect(socket) {
1042
1055
if ( this . channels [ _target ] . names [ x ] . replace ( "@" , "" ) . replace ( "\+" , "" ) . replace ( "~" , "" ) . replace ( "%" , "" ) == _sender )
1043
1056
break ;
1044
1057
this . channels [ _target ] . names . splice ( x , 1 ) ;
1058
+ this . channels [ _target ] . userhosts . splice ( x , 1 ) ;
1045
1059
}
1046
1060
break ;
1047
1061
case 'QUIT' :
@@ -1065,8 +1079,13 @@ function clientConnect(socket) {
1065
1079
}
1066
1080
this . channels [ _channel ] . names = [ ] ;
1067
1081
}
1068
- for ( x = 0 ; x < _names . length ; x ++ )
1069
- this . channels [ _channel ] . names . push ( _names [ x ] . trim ( ) ) ;
1082
+ for ( x = 0 ; x < _names . length ; x ++ ) {
1083
+ this . channels [ _channel ] . names . push ( _names [ x ] . trim ( ) . split ( "!" ) [ 0 ] ) ;
1084
+ if ( _names [ x ] . trim ( ) . indexOf ( "!" ) >= 0 )
1085
+ this . channels [ _channel ] . userhosts . push ( _names [ x ] . trim ( ) . split ( "!" ) [ 1 ] ) ;
1086
+ else
1087
+ this . channels [ _channel ] . userhosts . push ( "*@*" ) ;
1088
+ }
1070
1089
break ;
1071
1090
case '366' :
1072
1091
_channel = data [ 3 ] . toUpperCase ( ) . trim ( ) ;
0 commit comments