diff options
Diffstat (limited to 'modules/protocol/bahamut.cpp')
-rw-r--r-- | modules/protocol/bahamut.cpp | 62 |
1 files changed, 56 insertions, 6 deletions
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index 078e19a7d..a26669a9b 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -77,7 +77,7 @@ class BahamutIRCdProto : public IRCDProto /* SQLINE */ void SendSQLine(User *, const XLine *x) anope_override { - UplinkSocket::Message() << "SQLINE " << x->Mask << " :" << x->Reason; + UplinkSocket::Message() << "SQLINE " << x->Mask << " :" << x->GetReason(); } /* UNSLINE */ @@ -103,9 +103,9 @@ class BahamutIRCdProto : public IRCDProto if (timeleft > 172800 || !x->Expires) timeleft = 172800; /* this will likely fail so its only here for legacy */ - UplinkSocket::Message() << "SZLINE " << x->GetHost() << " :" << x->Reason; + UplinkSocket::Message() << "SZLINE " << x->GetHost() << " :" << x->GetReason(); /* this is how we are supposed to deal with it */ - UplinkSocket::Message() << "AKILL " << x->GetHost() << " * " << timeleft << " " << x->By << " " << Anope::CurTime << " :" << x->Reason; + UplinkSocket::Message() << "AKILL " << x->GetHost() << " * " << timeleft << " " << x->By << " " << Anope::CurTime << " :" << x->GetReason(); } /* SVSNOOP */ @@ -117,12 +117,27 @@ class BahamutIRCdProto : public IRCDProto /* SGLINE */ void SendSGLine(User *, const XLine *x) anope_override { - UplinkSocket::Message() << "SGLINE " << x->Mask.length() << " :" << x->Mask << ":" << x->Reason; + UplinkSocket::Message() << "SGLINE " << x->Mask.length() << " :" << x->Mask << ":" << x->GetReason(); } /* RAKILL */ void SendAkillDel(const XLine *x) anope_override { + if (x->IsRegex() || x->HasNickOrReal()) + return; + + /* ZLine if we can instead */ + try + { + if (x->GetUser() == "*") + { + sockaddrs(x->GetHost()); + ircdproto->SendSZLineDel(x); + return; + } + } + catch (const SocketException &) { } + UplinkSocket::Message() << "RAKILL " << x->GetHost() << " " << x->GetUser(); } @@ -160,13 +175,48 @@ class BahamutIRCdProto : public IRCDProto } } - void SendAkill(User *, const XLine *x) anope_override + void SendAkill(User *u, XLine *x) anope_override { + if (x->IsRegex() || x->HasNickOrReal()) + { + if (!u) + { + /* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */ + for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) + if (x->manager->Check(it->second, x)) + this->SendAkill(it->second, x); + return; + } + + XLine *old = x; + + if (old->manager->HasEntry("*@" + u->host)) + return; + + /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ + x = new XLine("*@" + u->host, old->By, old->Expires, old->Reason, old->UID); + old->manager->AddXLine(x); + + Log(findbot(Config->OperServ), "akill") << "AKILL: Added an akill for " << x->Mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->Mask; + } + + /* ZLine if we can instead */ + try + { + if (x->GetUser() == "*") + { + sockaddrs(x->GetHost()); + ircdproto->SendSZLine(u, x); + return; + } + } + catch (const SocketException &) { } + // Calculate the time left before this would expire, capping it at 2 days time_t timeleft = x->Expires - Anope::CurTime; if (timeleft > 172800) timeleft = 172800; - UplinkSocket::Message() << "AKILL " << x->GetHost() << " " << x->GetUser() << " " << timeleft << " " << x->By << " " << Anope::CurTime << " :" << x->Reason; + UplinkSocket::Message() << "AKILL " << x->GetHost() << " " << x->GetUser() << " " << timeleft << " " << x->By << " " << Anope::CurTime << " :" << x->GetReason(); } /* |