diff options
author | Adam <adam@sigterm.info> | 2016-07-23 15:38:26 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-23 15:38:26 -0400 |
commit | b2e25db1593e7e8a6490dd42ca7e9c93bf71552c (patch) | |
tree | 42c876ab91c04e1c3e263ba64f41305846f16f15 | |
parent | 9f9371531dd166a41a1fc233d7691fcd3f78b73e (diff) | |
parent | b578ed2544e38ce7b7459951059651635b8e4255 (diff) |
Merge pull request #171 from Techman-/2.0+charybdis-resv-fixes
charybdis.cpp: Properly support RESVs
-rw-r--r-- | modules/protocol/charybdis.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/modules/protocol/charybdis.cpp b/modules/protocol/charybdis.cpp index c381ef124..f0d01c8cc 100644 --- a/modules/protocol/charybdis.cpp +++ b/modules/protocol/charybdis.cpp @@ -31,13 +31,29 @@ class ChannelModeLargeBan : public ChannelMode class CharybdisProto : public IRCDProto { + BotInfo *FindIntroduced() + { + BotInfo *bi = Config->GetClient("OperServ"); + + if (bi && bi->introduced) + return bi; + + for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it) + if (it->second->introduced) + return it->second; + + return NULL; + } + public: + CharybdisProto(Module *creator) : IRCDProto(creator, "Charybdis 3.4+") { DefaultPseudoclientModes = "+oiS"; CanCertFP = true; CanSNLine = true; CanSQLine = true; + CanSQLineChannel = true; CanSZLine = true; CanSVSNick = true; CanSVSHold = true; @@ -54,7 +70,6 @@ class CharybdisProto : public IRCDProto void SendSGLineDel(const XLine *x) anope_override { ratbox->SendSGLineDel(x); } 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(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); } @@ -77,7 +92,18 @@ class CharybdisProto : public IRCDProto void SendSQLine(User *, const XLine *x) anope_override { - UplinkSocket::Message(Me) << "RESV * " << x->mask << " :" << x->GetReason(); + /* Calculate the time left before this would expire, capping it at 2 days */ + time_t timeleft = x->expires - Anope::CurTime; + + if (timeleft > 172800 || !x->expires) + timeleft = 172800; + + UplinkSocket::Message(FindIntroduced()) << "ENCAP * RESV " << timeleft << " " << x->mask << " 0 :" << x->GetReason(); + } + + void SendSQLineDel(const XLine *x) anope_override + { + UplinkSocket::Message(Config->GetClient("OperServ")) << "ENCAP * UNRESV " << x->mask; } void SendConnect() anope_override |