Skip to content

Commit 495dbf2

Browse files
committed
userhosts in aop/aov/hop if userhost-in-names available, else nick
1 parent a178ce4 commit 495dbf2

File tree

1 file changed

+40
-21
lines changed

1 file changed

+40
-21
lines changed

bouncer.js

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,7 @@ function clientConnect(socket) {
696696
connection.authenticated = false;
697697
connection.connected = true;
698698
connection.opmode = BOUNCER_DEFAULT_OPMODE;
699+
connection.userhostInNames=false;
699700

700701
// Temp Buffer
701702
connection._buffer='';
@@ -740,12 +741,14 @@ function clientConnect(socket) {
740741
data = lines[n].trim().split(" ");
741742
if(data[1]=="CAP") {
742743
if(data[3] && data[3]=='LS') {
743-
if(lines[n].trim().indexOf("multi-prefix")>0) {
744+
if(lines[n].trim().indexOf("multi-prefix")>=0) {
744745
this.write("CAP REQ :multi-prefix\n");
745746
}
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;
748750
}
751+
this.write("CAP END\n");
749752
}
750753
else {
751754
this.write("CAP END\n");
@@ -813,15 +816,17 @@ function clientConnect(socket) {
813816
if(curchan.names[c].replace("@","").replace("+","").replace("%","")==_mode_target[_mode_count]) {
814817
switch(_mode[i]) {
815818
case 'o':
819+
_this_target = _mode_target[_mode_count] + "!" + (curchan.userhosts[c]?curchan.userhosts[c]:"*@*");
816820
if(curchan.names[c].indexOf("@")==-1) {
817821
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);
820824
}
821825
}
822826
if(_mode_target[_mode_count]==this.nick) curchan.isop=true;
823827
break;
824828
case 'v':
829+
_this_target = _mode_target[_mode_count] + "!" + (curchan.userhosts[c]?curchan.userhosts[c]:"*@*");
825830
if(curchan.names[c].indexOf("+")==-1) {
826831
if(curchan.names[c].indexOf("@")==-1) {
827832
if(curchan.names[c].indexOf("%")==-1) {
@@ -839,21 +844,22 @@ function clientConnect(socket) {
839844
curchan.names[c]=curchan.names[c].substr(0,2)+"+"+curchan.names[c].substr(2);
840845
}
841846
}
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]);
844849
}
845850
}
846851
if(_mode_target[_mode_count]==this.nick) curchan.isvoice=true;
847852
break;
848853
case 'h':
854+
_this_target = _mode_target[_mode_count] + "!" + (curchan.userhosts[c]?curchan.userhosts[c]:"*@*");
849855
if(curchan.names[c].indexOf("%")==-1) {
850856
if(curchan.names[c].indexOf("@")==-1) {
851857
curchan.names[c]="%"+curchan.names[c];
852858
}
853859
else
854860
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]);
857863
}
858864
}
859865
if(_mode_target[_mode_count]==this.nick) curchan.ishop=true;
@@ -894,23 +900,26 @@ function clientConnect(socket) {
894900
if(curchan.names[c].replace(/\@/,"").replace(/\%/,"").replace(/\+/,"")==_mode_target[_mode_count]) {
895901
switch(_mode[i]) {
896902
case 'o':
903+
_this_target = _mode_target[_mode_count] + "!" + (curchan.userhosts[c]?curchan.userhosts[c]:"*@*");
897904
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);
900907
}
901908
if(_mode_target[_mode_count]==this.nick) this.isop=false;
902909
break;
903910
case 'v':
911+
_this_target = _mode_target[_mode_count] + "!" + (curchan.userhosts[c]?curchan.userhosts[c]:"*@*");
904912
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);
907915
}
908916
if(_mode_target[_mode_count]==this.nick) this.isvoice=false;
909917
break;
910918
case 'h':
919+
_this_target = _mode_target[_mode_count] + "!" + (curchan.userhosts[c]?curchan.userhosts[c]:"*@*");
911920
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);
914923
}
915924
if(_mode_target[_mode_count]==this.nick) this.ishop=false;
916925
break;
@@ -947,6 +956,8 @@ function clientConnect(socket) {
947956
case 'JOIN':
948957
_temp = data[0].substr(1).split("!");
949958
_nick = _temp[0];
959+
if(_temp[1])
960+
_userhost = _temp[1];
950961
if(_temp[1] && this.nick==_nick) {
951962
this.ircuser=_temp[1].split("@")[0];
952963
}
@@ -968,6 +979,7 @@ function clientConnect(socket) {
968979
this.channels[__channel].forward=null;
969980
this.channels[__channel].throttle=null;
970981
this.channels[__channel].names=[];
982+
this.channels[__channel].userhosts=[];
971983
this.channels[__channel].name=_channel;
972984
this.channels[__channel].aop=[];
973985
this.channels[__channel].aoh=[];
@@ -979,14 +991,15 @@ function clientConnect(socket) {
979991
}
980992
else {
981993
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) {
984997
this.write("MODE "+this.channels[__channel].name+" +o "+_nick+"\n");
985998
}
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) {
9871000
this.write("MODE "+this.channels[__channel].name+" +h "+_nick+"\n");
9881001
}
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) {
9901003
this.write("MODE "+this.channels[__channel].name+" +v "+_nick+"\n");
9911004
}
9921005
}
@@ -1042,6 +1055,7 @@ function clientConnect(socket) {
10421055
if(this.channels[_target].names[x].replace("@","").replace("\+","").replace("~","").replace("%","")==_sender)
10431056
break;
10441057
this.channels[_target].names.splice(x,1);
1058+
this.channels[_target].userhosts.splice(x,1);
10451059
}
10461060
break;
10471061
case 'QUIT':
@@ -1065,8 +1079,13 @@ function clientConnect(socket) {
10651079
}
10661080
this.channels[_channel].names=[];
10671081
}
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+
}
10701089
break;
10711090
case '366':
10721091
_channel=data[3].toUpperCase().trim();

0 commit comments

Comments
 (0)