diff options
Diffstat (limited to 'modules/protocol')
| -rw-r--r-- | modules/protocol/bahamut.cpp | 34 | ||||
| -rw-r--r-- | modules/protocol/charybdis.cpp | 2 | ||||
| -rw-r--r-- | modules/protocol/hybrid.cpp | 30 | ||||
| -rw-r--r-- | modules/protocol/inspircd11.cpp | 27 | ||||
| -rw-r--r-- | modules/protocol/inspircd12.cpp | 41 | ||||
| -rw-r--r-- | modules/protocol/inspircd20.cpp | 6 | ||||
| -rw-r--r-- | modules/protocol/ngircd.cpp | 24 | ||||
| -rw-r--r-- | modules/protocol/plexus.cpp | 9 | ||||
| -rw-r--r-- | modules/protocol/ratbox.cpp | 2 | ||||
| -rw-r--r-- | modules/protocol/unreal.cpp | 38 |
10 files changed, 70 insertions, 143 deletions
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index 8c2c131a6..1f15e3c06 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -143,16 +143,14 @@ class BahamutIRCdProto : public IRCDProto return; /* ZLine if we can instead */ - try - { - if (x->GetUser() == "*") + if (x->GetUser() == "*" && x->GetHost().find_first_not_of("0123456789:.") == Anope::string::npos) + try { sockaddrs(x->GetHost()); IRCD->SendSZLineDel(x); return; } - } - catch (const SocketException &) { } + catch (const SocketException &) { } UplinkSocket::Message() << "RAKILL " << x->GetHost() << " " << x->GetUser(); } @@ -170,7 +168,7 @@ class BahamutIRCdProto : public IRCDProto } /* JOIN - SJOIN */ - void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override + void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override { UplinkSocket::Message(user) << "SJOIN " << c->creation_time << " " << c->name; if (status) @@ -182,12 +180,11 @@ class BahamutIRCdProto : public IRCDProto */ ChanUserContainer *uc = c->FindUser(user); if (uc != NULL) - uc->status.modes.clear(); + uc->status.Clear(); BotInfo *setter = BotInfo::Find(user->nick); - for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i) - if (cs.modes.count(ModeManager::ChannelModes[i]->name)) - c->SetMode(setter, ModeManager::ChannelModes[i], user->GetUID(), false); + for (size_t i = 0; i < cs.Modes().length(); ++i) + c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); } } @@ -217,16 +214,14 @@ class BahamutIRCdProto : public IRCDProto } /* ZLine if we can instead */ - try - { - if (x->GetUser() == "*") + if (x->GetUser() == "*" && x->GetHost().find_first_not_of("0123456789:.") == Anope::string::npos) + try { sockaddrs(x->GetHost()); IRCD->SendSZLine(u, x); return; } - } - catch (const SocketException &) { } + catch (const SocketException &) { } // Calculate the time left before this would expire, capping it at 2 days time_t timeleft = x->expires - Anope::CurTime; @@ -448,14 +443,7 @@ struct IRCDMessageSJoin : IRCDMessage for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));) { buf.erase(buf.begin()); - ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); - if (!cm) - { - Log() << "Received unknown mode prefix " << cm << " in SJOIN string"; - continue; - } - - sju.first.modes.insert(cm->name); + sju.first.AddMode(ch); } sju.second = User::Find(buf); diff --git a/modules/protocol/charybdis.cpp b/modules/protocol/charybdis.cpp index 6f41abcc5..e91478c7f 100644 --- a/modules/protocol/charybdis.cpp +++ b/modules/protocol/charybdis.cpp @@ -52,7 +52,7 @@ class CharybdisProto : public IRCDProto void SendAkill(User *u, XLine *x) anope_override { ratbox->SendAkill(u, x); } void SendAkillDel(const XLine *x) anope_override { ratbox->SendAkillDel(x); } void SendSQLineDel(const XLine *x) anope_override { ratbox->SendSQLineDel(x); } - void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override { ratbox->SendJoin(user, c, status); } + void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override { ratbox->SendJoin(user, c, status); } void SendServer(const Server *server) anope_override { ratbox->SendServer(server); } void SendChannel(Channel *c) anope_override { ratbox->SendChannel(c); } void SendTopic(BotInfo *bi, Channel *c) anope_override { ratbox->SendTopic(bi, c); } diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index ac3f88c41..3247787f1 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -88,7 +88,7 @@ class HybridProto : public IRCDProto UplinkSocket::Message(OperServ) << "UNRESV * " << x->mask; } - void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override + void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override { /* * Note that we must send our modes with the SJOIN and @@ -234,7 +234,7 @@ class HybridProto : public IRCDProto { ChannelStatus status; - status.modes.insert("OP"); + status.AddMode('o'); bi->Join(c, &status); } @@ -271,24 +271,14 @@ struct IRCDMessageBMask : IRCDMessage void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { Channel *c = Channel::Find(params[1]); + ChannelMode *mode = ModeManager::FindChannelModeByChar(params[2][0]); - if (c) + if (c && mode) { - ChannelMode *ban = ModeManager::FindChannelModeByName("BAN"), - *except = ModeManager::FindChannelModeByName("EXCEPT"), - *invex = ModeManager::FindChannelModeByName("INVITEOVERRIDE"); - spacesepstream bans(params[3]); Anope::string token; while (bans.GetToken(token)) - { - if (ban && params[2].equals_cs("b")) - c->SetModeInternal(source, ban, token); - else if (except && params[2].equals_cs("e")) - c->SetModeInternal(source, except, token); - else if (invex && params[2].equals_cs("I")) - c->SetModeInternal(source, invex, token); - } + c->SetModeInternal(source, mode, token); } } }; @@ -412,15 +402,7 @@ struct IRCDMessageSJoin : IRCDMessage for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));) { buf.erase(buf.begin()); - ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); - - if (!cm) - { - Log() << "Received unknown mode prefix " << ch << " in SJOIN string"; - continue; - } - - sju.first.modes.insert(cm->name); + sju.first.AddMode(ch); } sju.second = User::Find(buf); diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp index 0761f478c..b6cb905c2 100644 --- a/modules/protocol/inspircd11.cpp +++ b/modules/protocol/inspircd11.cpp @@ -80,16 +80,14 @@ class InspIRCdProto : public IRCDProto return; /* ZLine if we can instead */ - try - { - if (x->GetUser() == "*") + if (x->GetUser() == "*" && x->GetHost().find_first_not_of("0123456789:.") == Anope::string::npos) + try { sockaddrs(x->GetHost()); IRCD->SendSZLineDel(x); return; } - } - catch (const SocketException &) { } + catch (const SocketException &) { } UplinkSocket::Message(OperServ) << "GLINE " << x->mask; } @@ -136,16 +134,14 @@ class InspIRCdProto : public IRCDProto } /* ZLine if we can instead */ - try - { - if (x->GetUser() == "*") + if (x->GetUser() == "*" && x->GetHost().find_first_not_of("0123456789:.") == Anope::string::npos) + try { sockaddrs(x->GetHost()); IRCD->SendSZLine(u, x); return; } - } - catch (const SocketException &) { } + catch (const SocketException &) { } // Calculate the time left before this would expire, capping it at 2 days time_t timeleft = x->expires - Anope::CurTime; @@ -203,7 +199,7 @@ class InspIRCdProto : public IRCDProto } /* JOIN */ - void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override + void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override { UplinkSocket::Message(user) << "JOIN " << c->name << " " << c->creation_time; if (status) @@ -215,12 +211,11 @@ class InspIRCdProto : public IRCDProto */ ChanUserContainer *uc = c->FindUser(user); if (uc != NULL) - uc->status.modes.clear(); + uc->status.Clear(); BotInfo *setter = BotInfo::Find(user->nick); - for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i) - if (cs.modes.count(ModeManager::ChannelModes[i]->name)) - c->SetMode(setter, ModeManager::ChannelModes[i], user->GetUID(), false); + for (size_t i = 0; i < cs.Modes().length(); ++i) + c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); } } @@ -653,7 +648,7 @@ struct IRCDMessageFJoin : IRCDMessage continue; } - sju.first.modes.insert(cm->name); + sju.first.AddMode(cm->mchar); } /* Erase the , */ buf.erase(buf.begin()); diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index a79edf291..deb7bbbf1 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -180,16 +180,15 @@ class InspIRCd12Proto : public IRCDProto } /* ZLine if we can instead */ - try - { - if (x->GetUser() == "*") + if (x->GetUser() == "*" && x->GetHost().find_first_not_of("0123456789:.") == Anope::string::npos) + try { sockaddrs(x->GetHost()); IRCD->SendSZLine(u, x); return; } - } - catch (const SocketException &) { } + catch (const SocketException &) { } + SendAddLine("G", x->GetUser() + "@" + x->GetHost(), timeleft, x->by, x->GetReason()); } @@ -221,7 +220,7 @@ class InspIRCd12Proto : public IRCDProto } /* JOIN */ - void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override + void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override { UplinkSocket::Message(Me) << "FJOIN " << c->name << " " << c->creation_time << " +" << c->GetModes(true, true) << " :," << user->GetUID(); /* Note that we can send this with the FJOIN but choose not to @@ -237,19 +236,11 @@ class InspIRCd12Proto : public IRCDProto */ ChanUserContainer *uc = c->FindUser(user); if (uc != NULL) - uc->status.modes.clear(); + uc->status.Clear(); BotInfo *setter = BotInfo::Find(user->nick); - for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i) - { - ChannelMode *cm = ModeManager::ChannelModes[i]; - - if (cs.modes.count(cm->name) || cs.modes.count(cm->mchar)) - { - c->SetMode(setter, ModeManager::ChannelModes[i], user->GetUID(), false); - cs.modes.insert(cm->name); - } - } + for (size_t i = 0; i < cs.Modes().length(); ++i) + c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); } } @@ -386,7 +377,7 @@ class InspIRCdExtBan : public ChannelModeList public: InspIRCdExtBan(const Anope::string &mname, char modeChar) : ChannelModeList(mname, modeChar) { } - bool Matches(const User *u, const Entry *e) anope_override + bool Matches(User *u, const Entry *e) anope_override { const Anope::string &mask = e->GetMask(); @@ -839,20 +830,14 @@ struct IRCDMessageFJoin : IRCDMessage Message::Join::SJoinUser sju; /* Loop through prefixes and find modes for them */ - for (char c; (c = buf[0]) != ',';) + for (char c; (c = buf[0]) != ',' && c;) { buf.erase(buf.begin()); - ChannelMode *cm = ModeManager::FindChannelModeByChar(c); - if (!cm) - { - Log() << "Received unknown mode prefix " << c << " in FJOIN string"; - continue; - } - - sju.first.modes.insert(cm->name); + sju.first.AddMode(c); } /* Erase the , */ - buf.erase(buf.begin()); + if (!buf.empty()) + buf.erase(buf.begin()); sju.second = User::Find(buf); if (!sju.second) diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index bbe069466..0af696bf0 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -55,7 +55,7 @@ class InspIRCd20Proto : public IRCDProto void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override { insp12->SendModeInternal(bi, u, buf); } void SendClientIntroduction(const User *u) anope_override { insp12->SendClientIntroduction(u); } void SendServer(const Server *server) anope_override { insp12->SendServer(server); } - void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override { insp12->SendJoin(user, c, status); } + void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override { insp12->SendJoin(user, c, status); } void SendSQLineDel(const XLine *x) anope_override { insp12->SendSQLineDel(x); } void SendSQLine(User *u, const XLine *x) anope_override { insp12->SendSQLine(u, x); } void SendVhost(User *u, const Anope::string &vident, const Anope::string &vhost) anope_override { insp12->SendVhost(u, vident, vhost); } @@ -80,7 +80,7 @@ class InspIRCdExtBan : public ChannelModeList public: InspIRCdExtBan(const Anope::string &mname, char modeChar) : ChannelModeList(mname, modeChar) { } - bool Matches(const User *u, const Entry *e) anope_override + bool Matches(User *u, const Entry *e) anope_override { const Anope::string &mask = e->GetMask(); @@ -111,7 +111,7 @@ class InspIRCdExtBan : public ChannelModeList { ChanUserContainer *uc = c->FindUser(u); if (uc != NULL) - if (cm == NULL || uc->status.modes.count(cm->name)) + if (cm == NULL || uc->status.HasMode(cm->mchar)) return true; } } diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index e54a4f8f7..ef226f87e 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -83,7 +83,7 @@ class ngIRCdProto : public IRCDProto UplinkSocket::Message(Me) << "WALLOPS :" << buf; } - void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override + void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override { UplinkSocket::Message(user) << "JOIN " << c->name; if (status) @@ -95,12 +95,11 @@ class ngIRCdProto : public IRCDProto */ ChanUserContainer *uc = c->FindUser(user); if (uc != NULL) - uc->status.modes.clear(); + uc->status.Clear(); BotInfo *setter = BotInfo::Find(user->nick); - for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i) - if (cs.modes.count(ModeManager::ChannelModes[i]->name)) - c->SetMode(setter, ModeManager::ChannelModes[i], user->GetUID(), false); + for (size_t i = 0; i < cs.Modes().length(); ++i) + c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); } } @@ -245,10 +244,8 @@ struct IRCDMessageChaninfo : IRCDMessage */ void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - - Channel *c = Channel::Find(params[0]); - if (!c) - c = new Channel(params[0]); + bool created; + Channel *c = Channel::FindOrCreate(params[0], created); Anope::string modes = params[1]; @@ -470,15 +467,8 @@ struct IRCDMessageNJoin : IRCDMessage /* Get prefixes from the nick */ for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));) { - ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); buf.erase(buf.begin()); - if (!cm) - { - Log(LOG_DEBUG) << "Received unknown mode prefix " << ch << " in NJOIN string."; - continue; - } - - sju.first.modes.insert(cm->name); + sju.first.AddMode(ch); } sju.second = User::Find(buf); diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index d117389e7..c22c43192 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -48,7 +48,7 @@ class PlexusProto : public IRCDProto void SendSVSHold(const Anope::string &nick) anope_override { hybrid->SendSVSHold(nick); } void SendSVSHoldDel(const Anope::string &nick) anope_override { hybrid->SendSVSHoldDel(nick); } - void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override + void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override { UplinkSocket::Message(Me) << "SJOIN " << c->creation_time << " " << c->name << " +" << c->GetModes(true, true) << " :" << user->GetUID(); if (status) @@ -60,12 +60,11 @@ class PlexusProto : public IRCDProto */ ChanUserContainer *uc = c->FindUser(user); if (uc != NULL) - uc->status.modes.clear(); + uc->status.Clear(); BotInfo *setter = BotInfo::Find(user->nick); - for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i) - if (cs.modes.count(ModeManager::ChannelModes[i]->name)) - c->SetMode(setter, ModeManager::ChannelModes[i], user->GetUID(), false); + for (size_t i = 0; i < cs.Modes().length(); ++i) + c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); } } diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index 247b8777a..129752c06 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -37,7 +37,7 @@ class RatboxProto : public IRCDProto void SendAkill(User *u, XLine *x) anope_override { hybrid->SendAkill(u, x); } void SendAkillDel(const XLine *x) anope_override { hybrid->SendAkillDel(x); } void SendSQLineDel(const XLine *x) anope_override { hybrid->SendSQLineDel(x); } - void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override { hybrid->SendJoin(user, c, status); } + void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override { hybrid->SendJoin(user, c, status); } void SendServer(const Server *server) anope_override { hybrid->SendServer(server); } void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override { hybrid->SendModeInternal(bi, u, buf); } void SendChannel(Channel *c) anope_override { hybrid->SendChannel(c); } diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index 984277c14..25094a24d 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -44,16 +44,14 @@ class UnrealIRCdProto : public IRCDProto return; /* ZLine if we can instead */ - try - { - if (x->GetUser() == "*") + if (x->GetUser() == "*" && x->GetHost().find_first_not_of("0123456789:.") == Anope::string::npos) + try { sockaddrs(x->GetHost()); IRCD->SendSZLineDel(x); return; } - } - catch (const SocketException &) { } + catch (const SocketException &) { } UplinkSocket::Message() << "TKL - G " << x->GetUser() << " " << x->GetHost() << " " << Config->OperServ; } @@ -108,16 +106,14 @@ class UnrealIRCdProto : public IRCDProto } /* ZLine if we can instead */ - try - { - if (x->GetUser() == "*") + if (x->GetUser() == "*" && x->GetHost().find_first_not_of("0123456789:.") == Anope::string::npos) + try { sockaddrs(x->GetHost()); IRCD->SendSZLine(u, x); return; } - } - catch (const SocketException &) { } + catch (const SocketException &) { } // Calculate the time left before this would expire, capping it at 2 days time_t timeleft = x->expires - Anope::CurTime; @@ -154,7 +150,7 @@ class UnrealIRCdProto : public IRCDProto } /* JOIN */ - void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override + void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override { UplinkSocket::Message(Me) << "SJOIN " << c->creation_time << " " << c->name << " :" << user->nick; if (status) @@ -166,12 +162,11 @@ class UnrealIRCdProto : public IRCDProto */ ChanUserContainer *uc = c->FindUser(user); if (uc != NULL) - uc->status.modes.clear(); + uc->status.Clear(); BotInfo *setter = BotInfo::Find(user->nick); - for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i) - if (cs.modes.count(ModeManager::ChannelModes[i]->name)) - c->SetMode(setter, ModeManager::ChannelModes[i], user->GetUID(), false); + for (size_t i = 0; i < cs.Modes().length(); ++i) + c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); } } @@ -384,7 +379,7 @@ class UnrealExtBan : public ChannelModeList public: UnrealExtBan(const Anope::string &mname, char modeChar) : ChannelModeList(mname, modeChar) { } - bool Matches(const User *u, const Entry *e) anope_override + bool Matches(User *u, const Entry *e) anope_override { const Anope::string &mask = e->GetMask(); @@ -407,7 +402,7 @@ class UnrealExtBan : public ChannelModeList { ChanUserContainer *uc = c->FindUser(u); if (uc != NULL) - if (cm == NULL || uc->status.modes.count(cm->name)) + if (cm == NULL || uc->status.HasMode(cm->mchar)) return true; } } @@ -1050,15 +1045,8 @@ struct IRCDMessageSJoin : IRCDMessage /* Get prefixes from the nick */ for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));) { + sju.first.AddMode(ch); buf.erase(buf.begin()); - ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); - if (!cm) - { - Log(LOG_DEBUG) << "Received unknown mode prefix " << ch << " in SJOIN string"; - continue; - } - - sju.first.modes.insert(cm->name); } sju.second = User::Find(buf); |
