diff options
author | lethality <lethality@anope.org> | 2012-02-23 00:04:36 +0000 |
---|---|---|
committer | lethality <lethality@anope.org> | 2012-02-23 00:04:36 +0000 |
commit | f01aab5f9bf5c14162438d1707e6e6cd9730c703 (patch) | |
tree | 4df360cd61e7dd1fd749d90e9dbe9e3cf1d739af /modules/protocol/unreal.cpp | |
parent | 826de43724d4584f9150a1fb8cebe8f49d9431a7 (diff) | |
parent | 3850b073ddf610415de54dced9ff134397779676 (diff) |
Merge branch '1.9' of ssh://anope.git.sf.net/gitroot/anope/anope into 1.9
Diffstat (limited to 'modules/protocol/unreal.cpp')
-rw-r--r-- | modules/protocol/unreal.cpp | 101 |
1 files changed, 74 insertions, 27 deletions
diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index 78d4a04be..f7c752095 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -13,8 +13,8 @@ #include "module.h" -IRCDVar myIrcd[] = { - {"UnrealIRCd 3.2.x", /* ircd name */ +IRCDVar myIrcd = { + "UnrealIRCd 3.2.x", /* ircd name */ "+Soiq", /* Modes used by pseudoclients */ 1, /* SVSNICK */ 1, /* Vhost */ @@ -35,10 +35,7 @@ IRCDVar myIrcd[] = { 0, /* ts6 */ "$", /* TLD Prefix for Global */ 12, /* Max number of modes we can send per line */ - 0, /* IRCd sends a SSL users certificate fingerprint */ - } - , - {NULL} + 0 /* IRCd sends a SSL users certificate fingerprint */ }; class UnrealIRCdProto : public IRCDProto @@ -51,12 +48,27 @@ class UnrealIRCdProto : public IRCDProto 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() << "BD - G " << x->GetUser() << " " << x->GetHost() << " " << Config->OperServ; } void SendTopic(BotInfo *whosets, Channel *c) anope_override { - UplinkSocket::Message(whosets->nick) << ") " << c->name << " " << c->topic_setter << " " << c->topic_time + 1 << " :" << c->topic; + UplinkSocket::Message(whosets) << ") " << c->name << " " << c->topic_setter << " " << c->topic_time + 1 << " :" << c->topic; } void SendVhostDel(User *u) anope_override @@ -68,28 +80,63 @@ class UnrealIRCdProto : public IRCDProto u->SetMode(bi, UMODE_CLOAK); } - 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) + if (timeleft > 172800 || !x->Expires) timeleft = 172800; - UplinkSocket::Message() << "BD + G " << x->GetUser() << " " << x->GetHost() << " " << x->By << " " << Anope::CurTime + timeleft << " " << x->Created << " :" << x->Reason; + UplinkSocket::Message() << "BD + G " << x->GetUser() << " " << x->GetHost() << " " << x->By << " " << Anope::CurTime + timeleft << " " << x->Created << " :" << x->GetReason(); } void SendSVSKillInternal(const BotInfo *source, const User *user, const Anope::string &buf) anope_override { - UplinkSocket::Message(source ? source->nick : Config->ServerName) << "h " << user->nick << " :" << buf; + UplinkSocket::Message(source) << "h " << user->nick << " :" << buf; } void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) anope_override { - UplinkSocket::Message(source ? source->nick : Config->ServerName) << "G " << dest->name << " " << buf; + UplinkSocket::Message(source) << "G " << dest->name << " " << buf; } void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override { - UplinkSocket::Message(bi ? bi->nick : Config->ServerName) << "v " << u->nick <<" " << buf; + UplinkSocket::Message(bi) << "v " << u->nick <<" " << buf; } void SendClientIntroduction(const User *u) anope_override @@ -101,9 +148,9 @@ class UnrealIRCdProto : public IRCDProto void SendKickInternal(const BotInfo *source, const Channel *chan, const User *user, const Anope::string &buf) anope_override { if (!buf.empty()) - UplinkSocket::Message(source->nick) << "H " << chan->name << " " << user->nick << " :" << buf; + UplinkSocket::Message(source) << "H " << chan->name << " " << user->nick << " :" << buf; else - UplinkSocket::Message(source->nick) << "H " << chan->name << " " << user->nick; + UplinkSocket::Message(source) << "H " << chan->name << " " << user->nick; } /* SERVER name hop descript */ @@ -119,7 +166,7 @@ class UnrealIRCdProto : public IRCDProto /* JOIN */ void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override { - UplinkSocket::Message(Config->ServerName) << "~ " << c->creation_time << " " << c->name << " :" << user->nick; + UplinkSocket::Message(Me) << "~ " << c->creation_time << " " << c->name << " :" << user->nick; if (status) { /* First save the channel status incase uc->Status == status */ @@ -152,7 +199,7 @@ class UnrealIRCdProto : public IRCDProto */ void SendSQLine(User *, const XLine *x) anope_override { - UplinkSocket::Message() << "c " << x->Mask << " :" << x->Reason; + UplinkSocket::Message() << "c " << x->Mask << " :" << x->GetReason(); } /* @@ -161,7 +208,7 @@ class UnrealIRCdProto : public IRCDProto ** parv[1] = nick ** parv[2] = options */ - void SendSVSO(const Anope::string &source, const Anope::string &nick, const Anope::string &flag) anope_override + void SendSVSO(const BotInfo *source, const Anope::string &nick, const Anope::string &flag) anope_override { UplinkSocket::Message(source) << "BB " << nick << " " << flag; } @@ -169,7 +216,7 @@ class UnrealIRCdProto : public IRCDProto /* NICK <newnick> */ void SendChangeBotNick(const BotInfo *oldnick, const Anope::string &newnick) anope_override { - UplinkSocket::Message(oldnick->nick) << "& " << newnick << " " << Anope::CurTime; + UplinkSocket::Message(oldnick) << "& " << newnick << " " << Anope::CurTime; } /* Functions that use serval cmd functions */ @@ -177,9 +224,9 @@ class UnrealIRCdProto : public IRCDProto void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) anope_override { if (!vIdent.empty()) - UplinkSocket::Message(Config->ServerName) << "AZ " << u->nick << " " << vIdent; + UplinkSocket::Message(Me) << "AZ " << u->nick << " " << vIdent; if (!vhost.empty()) - UplinkSocket::Message(Config->ServerName) << "AL " << u->nick << " " << vhost; + UplinkSocket::Message(Me) << "AL " << u->nick << " " << vhost; } void SendConnect() anope_override @@ -240,7 +287,7 @@ class UnrealIRCdProto : public IRCDProto time_t timeleft = x->Expires - Anope::CurTime; if (timeleft > 172800 || !x->Expires) timeleft = 172800; - UplinkSocket::Message() << "BD + Z * " << x->GetHost() << " " << x->By << " " << Anope::CurTime + timeleft << " " << x->Created << " :" << x->Reason; + UplinkSocket::Message() << "BD + Z * " << x->GetHost() << " " << x->By << " " << Anope::CurTime + timeleft << " " << x->Created << " :" << x->GetReason(); } /* SGLINE */ @@ -249,7 +296,7 @@ class UnrealIRCdProto : public IRCDProto */ void SendSGLine(User *, const XLine *x) anope_override { - Anope::string edited_reason = x->Reason; + Anope::string edited_reason = x->GetReason(); edited_reason = edited_reason.replace_all_cs(" ", "_"); UplinkSocket::Message() << "BR + " << edited_reason << " :" << x->Mask; } @@ -263,7 +310,7 @@ class UnrealIRCdProto : public IRCDProto /* In older Unreal SVSJOIN and SVSNLINE tokens were mixed so SVSJOIN and SVSNLINE are broken when coming from a none TOKEN'd server */ - void SendSVSJoin(const Anope::string &source, const Anope::string &nick, const Anope::string &chan, const Anope::string ¶m) anope_override + void SendSVSJoin(const BotInfo *source, const Anope::string &nick, const Anope::string &chan, const Anope::string ¶m) anope_override { if (!param.empty()) UplinkSocket::Message(source) << "BX " << nick << " " << chan << " :" << param; @@ -271,14 +318,14 @@ class UnrealIRCdProto : public IRCDProto UplinkSocket::Message(source) << "BX " << nick << " :" << chan; } - void SendSWhois(const Anope::string &source, const Anope::string &who, const Anope::string &mask) anope_override + void SendSWhois(const BotInfo *source, const Anope::string &who, const Anope::string &mask) anope_override { UplinkSocket::Message(source) << "BA " << who << " :" << mask; } void SendEOB() anope_override { - UplinkSocket::Message(Config->ServerName) << "ES"; + UplinkSocket::Message(Me) << "ES"; } bool IsNickValid(const Anope::string &nick) anope_override @@ -1157,7 +1204,7 @@ class ProtoUnreal : public Module { this->SetAuthor("Anope"); - pmodule_ircd_var(myIrcd); + pmodule_ircd_var(&myIrcd); pmodule_ircd_proto(&this->ircd_proto); pmodule_ircd_message(&this->ircd_message); |