105
106
CString sRest = sLine.Token(3, true);
108
case 1: {// :irc.server.com 001 nick :Welcome to the Internet Relay Network nick
109
case 1: { // :irc.server.com 001 nick :Welcome to the Internet Relay Network nick
110
if (m_bAuthed && sServer == "irc.znc.in") {
111
// m_bAuthed == true => we already received another 001 => we might be in a traffic loop
112
m_pUser->PutStatus("ZNC seems to be connected to itself, disconnecting...");
109
117
m_pUser->SetIRCServer(sServer);
110
SetTimeout(240, TMO_READ); // Now that we are connected, let nature take its course
118
SetTimeout(240, TMO_READ); // Now that we are connected, let nature take its course
111
119
PutIRC("WHO " + sNick);
113
121
m_bAuthed = true;
627
638
if (!m_pUser->IsUserAttached()) {
628
639
m_pUser->AddQueryBuffer(":" + Nick.GetNickMask() + " WALLOPS ", ":" + m_pUser->AddTimestamp(sMsg), false);
641
} else if (sCmd.Equals("CAP")) {
642
// sRest.Token(0) is most likely "*". No idea why, the
643
// CAP spec don't mention this, but all implementations
644
// I've seen add this extra asterisk
645
CString sSubCmd = sRest.Token(1);
646
CString sArgs = sRest.Token(2, true).TrimPrefix_n(":");
648
if (sSubCmd == "LS" && !m_bAuthed) {
650
VCString::iterator it;
651
sArgs.Split(" ", vsTokens, false);
653
for (it = vsTokens.begin(); it != vsTokens.end(); ++it) {
654
if (*it == "multi-prefix" || *it == "userhost-in-names") {
655
PutIRC("CAP REQ " + *it);
659
// Tell the IRC server we are done with CAP
661
} else if (sSubCmd == "ACK" && !m_bAuthed) {
663
VCString::iterator it;
664
sArgs.Split(" ", vsTokens, false);
666
for (it = vsTokens.begin(); it != vsTokens.end(); ++it) {
667
if (*it == "multi-prefix") {
669
} else if (*it == "userhost-in-names") {
929
975
void CIRCSock::ParseISupport(const CString& sLine) {
931
CString sArg = sLine.Token(i++);
933
while (!sArg.empty()) {
934
CString sName = sArg.Token(0, false, "=");
935
CString sValue = sArg.Token(1, true, "=");
977
VCString::iterator it;
979
sLine.Split(" ", vsTokens, false);
981
for (it = vsTokens.begin(); it != vsTokens.end(); ++it) {
982
CString sName = it->Token(0, false, "=");
983
CString sValue = it->Token(1, true, "=");
937
985
if (sName.Equals("PREFIX")) {
938
986
CString sPrefixes = sValue.Token(1, false, ")");
966
1014
} else if (sName.Equals("NAMESX")) {
967
1017
m_bNamesx = true;
968
1018
PutIRC("PROTOCTL NAMESX");
969
1019
} else if (sName.Equals("UHNAMES")) {
970
1022
m_bUHNames = true;
971
1023
PutIRC("PROTOCTL UHNAMES");
974
sArg = sLine.Token(i++);
978
1028
void CIRCSock::ForwardRaw353(const CString& sLine) const {
979
1029
vector<CClient*>& vClients = m_pUser->GetClients();
1030
vector<CClient*>::iterator it;
1032
for (it = vClients.begin(); it != vClients.end(); ++it) {
1033
ForwardRaw353(sLine, *it);
1037
void CIRCSock::ForwardRaw353(const CString& sLine, CClient* pClient) const {
980
1038
CString sNicks = sLine.Token(5, true);
981
1039
if (sNicks.Left(1) == ":")
982
1040
sNicks.LeftChomp();
984
for (unsigned int a = 0; a < vClients.size(); a++) {
985
if ((!m_bNamesx || vClients[a]->HasNamesx()) && (!m_bUHNames || vClients[a]->HasUHNames())) {
986
// Client and server have both the same UHNames and Namesx stuff enabled
987
m_pUser->PutUser(sLine, vClients[a]);
989
// Get everything except the actual user list
990
CString sTmp = sLine.Token(0, false, " :") + " :";
993
// This loop runs once for every nick on the channel
995
CString sNick = sNicks.Token(i).Trim_n(" ");
999
if (m_bNamesx && !vClients[a]->HasNamesx() && IsPermChar(sNick[0])) {
1000
// Server has, client doesn't have NAMESX, so we just use the first perm char
1001
size_t pos = sNick.find_first_not_of(GetPerms());
1002
if (pos >= 2 && pos != CString::npos) {
1003
sNick = sNick[0] + sNick.substr(pos);
1007
if (m_bUHNames && !vClients[a]->HasUHNames()) {
1008
// Server has, client hasnt UHNAMES,
1009
// so we strip away ident and host.
1010
sNick = sNick.Token(0, false, "!");
1013
sTmp += sNick + " ";
1016
// Strip away the spaces we inserted at the end
1017
sTmp.TrimRight(" ");
1018
m_pUser->PutUser(sTmp, vClients[a]);
1042
if ((!m_bNamesx || pClient->HasNamesx()) && (!m_bUHNames || pClient->HasUHNames())) {
1043
// Client and server have both the same UHNames and Namesx stuff enabled
1044
m_pUser->PutUser(sLine, pClient);
1046
// Get everything except the actual user list
1047
CString sTmp = sLine.Token(0, false, " :") + " :";
1050
VCString::const_iterator it;
1052
// This loop runs once for every nick on the channel
1053
sNicks.Split(" ", vsNicks, false);
1054
for (it = vsNicks.begin(); it != vsNicks.end(); ++it) {
1055
CString sNick = *it;
1059
if (m_bNamesx && !pClient->HasNamesx() && IsPermChar(sNick[0])) {
1060
// Server has, client doesn't have NAMESX, so we just use the first perm char
1061
size_t pos = sNick.find_first_not_of(GetPerms());
1062
if (pos >= 2 && pos != CString::npos) {
1063
sNick = sNick[0] + sNick.substr(pos);
1067
if (m_bUHNames && !pClient->HasUHNames()) {
1068
// Server has, client hasnt UHNAMES,
1069
// so we strip away ident and host.
1070
sNick = sNick.Token(0, false, "!");
1073
sTmp += sNick + " ";
1075
// Strip away the spaces we inserted at the end
1076
sTmp.TrimRight(" ");
1077
m_pUser->PutUser(sTmp, pClient);