summaryrefslogtreecommitdiff
path: root/modules/protocol/unreal.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/protocol/unreal.cpp')
-rw-r--r--modules/protocol/unreal.cpp98
1 files changed, 48 insertions, 50 deletions
diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp
index 984277c14..4186ee5d0 100644
--- a/modules/protocol/unreal.cpp
+++ b/modules/protocol/unreal.cpp
@@ -13,6 +13,8 @@
#include "module.h"
+static bool sasl = true;
+
class UnrealIRCdProto : public IRCDProto
{
public:
@@ -44,18 +46,16 @@ 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;
+ UplinkSocket::Message() << "TKL - G " << x->GetUser() << " " << x->GetHost() << " " << x->by;
}
void SendTopic(BotInfo *whosets, Channel *c) anope_override
@@ -108,16 +108,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;
@@ -147,14 +145,14 @@ class UnrealIRCdProto : public IRCDProto
/* Unreal 3.2 actually sends some info about itself in the descript area */
void SendServer(const Server *server) anope_override
{
- if (!Config->Numeric.empty())
- UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :U0-*-" << Config->Numeric << " " << server->GetDescription();
+ if (!server->GetSID().empty() && server == Me)
+ UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :U0-*-" << server->GetSID() << " " << server->GetDescription();
else
UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :" << server->GetDescription();
}
/* 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 +164,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);
}
}
@@ -230,24 +227,24 @@ class UnrealIRCdProto : public IRCDProto
VL = Version Info
NS = Config->Numeric Server
*/
- if (!Config->Numeric.empty())
- UplinkSocket::Message() << "PROTOCTL NICKv2 VHP UMODE2 NICKIP SJOIN SJOIN2 SJ3 NOQUIT TKLEXT ESVID MLOCK VL";
- else
- UplinkSocket::Message() << "PROTOCTL NICKv2 VHP UMODE2 NICKIP SJOIN SJOIN2 SJ3 NOQUIT TKLEXT ESVID MLOCK";
- UplinkSocket::Message() << "PASS :" << Config->Uplinks[Anope::CurrentUplink]->password;
+ Anope::string protoctl = "NICKv2 VHP UMODE2 NICKIP SJOIN SJOIN2 SJ3 NOQUIT TKLEXT ESVID MLOCK VL";
+ if (!Me->GetSID().empty())
+ protoctl += " VL";
+ UplinkSocket::Message() << "PROTOCTL " << protoctl;
+ UplinkSocket::Message() << "PASS :" << Config->Uplinks[Anope::CurrentUplink].password;
SendServer(Me);
}
/* SVSHOLD - set */
- void SendSVSHold(const Anope::string &nick) anope_override
+ void SendSVSHold(const Anope::string &nick, time_t t) anope_override
{
- UplinkSocket::Message() << "TKL + Q H " << nick << " " << Config->ServerName << " " << Anope::CurTime + Config->NSReleaseTimeout << " " << Anope::CurTime << " :Being held for registered user";
+ UplinkSocket::Message() << "TKL + Q H " << nick << " " << Me->GetName() << " " << Anope::CurTime + t << " " << Anope::CurTime << " :Being held for registered user";
}
/* SVSHOLD - release */
void SendSVSHoldDel(const Anope::string &nick) anope_override
{
- UplinkSocket::Message() << "TKL - Q * " << nick << " " << Config->ServerName;
+ UplinkSocket::Message() << "TKL - Q * " << nick << " " << Me->GetName();
}
/* UNSGLINE */
@@ -262,7 +259,7 @@ class UnrealIRCdProto : public IRCDProto
/* UNSZLINE */
void SendSZLineDel(const XLine *x) anope_override
{
- UplinkSocket::Message() << "TKL - Z * " << x->GetHost() << " " << Config->OperServ;
+ UplinkSocket::Message() << "TKL - Z * " << x->GetHost() << " " << x->by;
}
/* SZLINE */
@@ -384,7 +381,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 +404,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;
}
}
@@ -897,7 +894,7 @@ struct IRCDMessageSASL : IRCDMessage
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
size_t p = params[1].find('!');
- if (!Config->NSSASL || p == Anope::string::npos)
+ if (!sasl || p == Anope::string::npos)
return;
if (params[2] == "S")
@@ -1001,7 +998,7 @@ struct IRCDMessageServer : IRCDMessage
else
new Server(source.GetServer(), params[0], hops, params[2]);
- IRCD->SendPing(Config->ServerName, params[0]);
+ IRCD->SendPing(Me->GetName(), params[0]);
}
};
@@ -1050,15 +1047,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);
@@ -1136,6 +1126,7 @@ class ProtoUnreal : public Module
/* Core message handlers */
Message::Away message_away;
Message::Error message_error;
+ Message::Invite message_invite;
Message::Join message_join;
Message::Kick message_kick;
Message::Kill message_kill;
@@ -1169,6 +1160,8 @@ class ProtoUnreal : public Module
IRCDMessageTopic message_topic;
IRCDMessageUmode2 message_umode2;
+ bool use_server_side_mlock;
+
void AddModes()
{
ModeManager::AddChannelMode(new ChannelModeStatus("VOICE", 'v', '+', 0));
@@ -1208,11 +1201,11 @@ class ProtoUnreal : public Module
}
public:
- ProtoUnreal(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL),
+ ProtoUnreal(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR),
ircd_proto(this),
- message_away(this), message_error(this), message_join(this), message_kick(this), message_kill(this),
- message_motd(this), message_part(this), message_ping(this), message_privmsg(this), message_quit(this),
- message_squit(this), message_stats(this), message_time(this), message_version(this),
+ message_away(this), message_error(this), message_invite(this), message_join(this), message_kick(this),
+ message_kill(this), message_motd(this), message_part(this), message_ping(this), message_privmsg(this),
+ message_quit(this), message_squit(this), message_stats(this), message_time(this), message_version(this),
message_whois(this),
message_capab(this), message_chghost(this), message_chgident(this), message_chgname(this), message_mode(this, "MODE"),
@@ -1220,15 +1213,20 @@ class ProtoUnreal : public Module
message_sasl(this), message_sdesc(this), message_sethost(this), message_setident(this), message_setname(this), message_server(this),
message_sjoin(this), message_topic(this), message_umode2(this)
{
- this->SetAuthor("Anope");
this->AddModes();
- Implementation i[] = { I_OnUserNickChange, I_OnChannelCreate, I_OnChanRegistered, I_OnDelChan, I_OnMLock, I_OnUnMLock };
+ Implementation i[] = { I_OnReload, I_OnUserNickChange, I_OnChannelCreate, I_OnChanRegistered, I_OnDelChan, I_OnMLock, I_OnUnMLock };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
ModuleManager::SetPriority(this, PRIORITY_FIRST);
}
+ void OnReload(Configuration::Conf *conf) anope_override
+ {
+ use_server_side_mlock = conf->GetModule(this)->Get<bool>("use_server_side_mlock");
+ sasl = conf->GetModule(this)->Get<bool>("sasl");
+ }
+
void OnUserNickChange(User *u, const Anope::string &) anope_override
{
u->RemoveModeInternal(ModeManager::FindUserModeByName("REGISTERED"));
@@ -1238,7 +1236,7 @@ class ProtoUnreal : public Module
void OnChannelCreate(Channel *c) anope_override
{
- if (Config->UseServerSideMLock && Servers::Capab.count("MLOCK") > 0 && c->ci)
+ if (use_server_side_mlock && Servers::Capab.count("MLOCK") > 0 && c->ci)
{
Anope::string modes = c->ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(c->creation_time) << " " << c->ci->name << " " << modes;
@@ -1247,7 +1245,7 @@ class ProtoUnreal : public Module
void OnChanRegistered(ChannelInfo *ci) anope_override
{
- if (!ci->c || !Config->UseServerSideMLock)
+ if (!ci->c || !use_server_side_mlock || !Servers::Capab.count("MLOCK"))
return;
Anope::string modes = ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes;
@@ -1255,7 +1253,7 @@ class ProtoUnreal : public Module
void OnDelChan(ChannelInfo *ci) anope_override
{
- if (!ci->c || !Config->UseServerSideMLock)
+ if (!ci->c || !use_server_side_mlock || !Servers::Capab.count("MLOCK"))
return;
UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " :";
}
@@ -1263,7 +1261,7 @@ class ProtoUnreal : public Module
EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
{
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
- if (cm && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0 && Config->UseServerSideMLock)
+ if (use_server_side_mlock && cm && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0)
{
Anope::string modes = ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "") + cm->mchar;
UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes;
@@ -1275,7 +1273,7 @@ class ProtoUnreal : public Module
EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
{
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
- if (cm && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0 && Config->UseServerSideMLock)
+ if (use_server_side_mlock && cm && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0)
{
Anope::string modes = ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "").replace_all_cs(cm->mchar, "");
UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes;