summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bots.cpp8
-rw-r--r--src/channels.cpp2
-rw-r--r--src/command.cpp2
-rw-r--r--src/logger.cpp8
-rw-r--r--src/protocol.cpp179
-rw-r--r--src/servers.cpp19
-rw-r--r--src/service_manager.cpp3
-rw-r--r--src/uplink.cpp4
-rw-r--r--src/users.cpp19
9 files changed, 40 insertions, 204 deletions
diff --git a/src/bots.cpp b/src/bots.cpp
index 091caa12f..dfe46ea67 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -49,7 +49,7 @@ ServiceBot::ServiceBot(const Anope::string &nnick, const Anope::string &nuser, c
//XXX
//XLine x(this->nick, "Reserved for services");
//IRCD->SendSQLine(NULL, &x);
- IRCD->SendClientIntroduction(this);
+ IRCD->Send<messages::NickIntroduction>(this);
this->introduced = true;
}
}
@@ -92,11 +92,11 @@ void ServiceBot::OnKill()
{
this->introduced = false;
this->GenerateUID();
- IRCD->SendClientIntroduction(this);
+ IRCD->Send<messages::NickIntroduction>(this);
this->introduced = true;
for (User::ChanUserList::const_iterator cit = this->chans.begin(), cit_end = this->chans.end(); cit != cit_end; ++cit)
- IRCD->SendJoin(this, cit->second->chan, &cit->second->status);
+ IRCD->Send<messages::Join>(this, cit->second->chan, &cit->second->status);
}
void ServiceBot::SetNewNick(const Anope::string &newnick)
@@ -160,7 +160,7 @@ void ServiceBot::Join(Channel *c, ChannelStatus *status)
c->JoinUser(this, status);
if (IRCD)
- IRCD->SendJoin(this, c, status);
+ IRCD->Send<messages::Join>(this, c, status);
EventManager::Get()->Dispatch(&Event::JoinChannel::OnJoinChannel, this, c);
}
diff --git a/src/channels.cpp b/src/channels.cpp
index bb6bc3083..aed6c7b53 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -789,7 +789,7 @@ void Channel::ChangeTopic(const Anope::string &user, const Anope::string &newtop
this->topic_setter = user;
this->topic_ts = ts;
- IRCD->SendTopic(this->ci->WhoSends(), this);
+ IRCD->Send<messages::Topic>(this->ci->WhoSends(), this, newtopic, ts, user);
/* Now that the topic is set update the time set. This is *after* we set it so the protocol modules are able to tell the old last set time */
this->topic_time = Anope::CurTime;
diff --git a/src/command.cpp b/src/command.cpp
index f1cae4bb3..7a87b07f3 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -120,7 +120,7 @@ void CommandSource::Reply(const Anope::string &message)
this->reply->SendMessage(*this->service, tok);
}
-Command::Command(Module *o, const Anope::string &sname, size_t minparams, size_t maxparams) : Service(o, "Command", sname), max_params(maxparams), min_params(minparams), module(o)
+Command::Command(Module *o, const Anope::string &sname, size_t minparams, size_t maxparams) : Service(o, NAME, sname), max_params(maxparams), min_params(minparams), module(o)
{
allow_unregistered = require_user = false;
}
diff --git a/src/logger.cpp b/src/logger.cpp
index 4949860a3..2751382f6 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -321,7 +321,7 @@ void LogInfo::OpenLogFiles()
{
const Anope::string &target = this->targets[i];
- if (target.empty() || target[0] == '#' || target == "globops" || target.find(":") != Anope::string::npos)
+ if (target.empty() || target[0] == '#' || target == "opers" || target.find(":") != Anope::string::npos)
continue;
LogFile *lf = new LogFile(CreateLogName(target));
@@ -386,11 +386,11 @@ void LogInfo::ProcessMessage(const Log *l)
IRCD->SendPrivmsg(bi, c->name, buffer);
}
}
- else if (target == "globops")
+ else if (target == "opers")
{
if (UplinkSock && l->bi && l->type <= LOG_NORMAL && Me && Me->IsSynced())
{
- IRCD->SendGlobops(l->bi, buffer);
+ IRCD->SendWallops(l->bi, buffer);
}
}
}
@@ -406,7 +406,7 @@ void LogInfo::ProcessMessage(const Log *l)
{
const Anope::string &target = this->targets[i];
- if (target.empty() || target[0] == '#' || target == "globops" || target.find(":") != Anope::string::npos)
+ if (target.empty() || target[0] == '#' || target == "opers" || target.find(":") != Anope::string::npos)
continue;
Anope::string oldlog = CreateLogName(target, Anope::CurTime - 86400 * this->log_age);
diff --git a/src/protocol.cpp b/src/protocol.cpp
index 5bf474a21..e299d1c2f 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -28,18 +28,15 @@
#include "channels.h"
#include "numeric.h"
-IRCDProto *IRCD = NULL;
+IRCDProto *IRCD = nullptr;
-IRCDProto::IRCDProto(Module *creator, const Anope::string &p) : Service(creator, "IRCDProto", creator->name), proto_name(p)
+IRCDProto::IRCDProto(Module *creator, const Anope::string &p) : Service(creator, NAME, p)
+ , proto_name(p)
{
- if (IRCD == NULL)
- IRCD = this;
}
IRCDProto::~IRCDProto()
{
- if (IRCD == this)
- IRCD = NULL;
}
const Anope::string &IRCDProto::GetProtocolName() const
@@ -47,119 +44,6 @@ const Anope::string &IRCDProto::GetProtocolName() const
return this->proto_name;
}
-static inline char nextID(int pos, Anope::string &buf)
-{
- char &c = buf[pos];
- if (c == 'Z')
- c = '0';
- else if (c != '9')
- ++c;
- else if (pos)
- c = 'A';
- else
- c = '0';
- return c;
-}
-
-Anope::string IRCDProto::UID_Retrieve()
-{
- if (!IRCD || !IRCD->RequiresID)
- return "";
-
- static Anope::string current_uid = "AAAAAA";
-
- do
- {
- int current_len = current_uid.length() - 1;
- while (current_len >= 0 && nextID(current_len--, current_uid) == 'A');
- }
- while (User::Find(Me->GetSID() + current_uid) != NULL);
-
- return Me->GetSID() + current_uid;
-}
-
-Anope::string IRCDProto::SID_Retrieve()
-{
- if (!IRCD || !IRCD->RequiresID)
- return "";
-
- static Anope::string current_sid = Config->GetBlock("serverinfo")->Get<Anope::string>("id");
- if (current_sid.empty())
- current_sid = "00A";
-
- do
- {
- int current_len = current_sid.length() - 1;
- while (current_len >= 0 && nextID(current_len--, current_sid) == 'A');
- }
- while (Server::Find(current_sid) != NULL);
-
- return current_sid;
-}
-
-void IRCDProto::SendKill(const MessageSource &source, const Anope::string &target, const Anope::string &reason)
-{
- Uplink::Send(source, "KILL", target, reason);
-}
-
-void IRCDProto::SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf)
-{
- Uplink::Send(source, "KILL", user->GetUID(), buf);
-}
-
-void IRCDProto::SendMode(const MessageSource &source, Channel *dest, const Anope::string &buf)
-{
- IRCMessage message(source, "MODE", dest->name);
- message.TokenizeAndPush(buf);
- Uplink::SendMessage(message);
-}
-
-void IRCDProto::SendMode(const MessageSource &source, User *dest, const Anope::string &buf)
-{
- IRCMessage message(source, "MODE", dest->GetUID());
- message.TokenizeAndPush(buf);
- Uplink::SendMessage(message);
-}
-
-void IRCDProto::SendKick(const MessageSource &source, Channel *c, User *u, const Anope::string &r)
-{
- if (!r.empty())
- Uplink::Send(source, "KICK", c->name, u->GetUID(), r);
- else
- Uplink::Send(source, "KICK", c->name, u->GetUID());
-}
-
-void IRCDProto::SendNotice(const MessageSource &source, const Anope::string &dest, const Anope::string &msg)
-{
- Uplink::Send(source, "NOTICE", dest, msg);
-}
-
-void IRCDProto::SendPrivmsg(const MessageSource &source, const Anope::string &dest, const Anope::string &buf)
-{
- Uplink::Send(source, "PRIVMSG", dest, buf);
-}
-
-void IRCDProto::SendQuit(User *u, const Anope::string &buf)
-{
- if (!buf.empty())
- Uplink::Send(u, "QUIT", buf);
- else
- Uplink::Send(u, "QUIT");
-}
-
-void IRCDProto::SendPart(User *u, Channel *chan, const Anope::string &buf)
-{
- if (!buf.empty())
- Uplink::Send(u, "PART", chan->name, buf);
- else
- Uplink::Send(u, "PART", chan->name);
-}
-
-void IRCDProto::SendGlobops(const MessageSource &source, const Anope::string &buf)
-{
- Uplink::Send(source, "GLOBOPS", buf);
-}
-
void IRCDProto::SendCTCPReply(const MessageSource &source, const Anope::string &dest, const Anope::string &buf)
{
Anope::string s = Anope::NormalizeBuffer(buf);
@@ -171,11 +55,6 @@ void IRCDProto::SendNumeric(int numeric, User *dest, IRCMessage &message)
Uplink::SendMessage(message);
}
-void IRCDProto::SendTopic(const MessageSource &source, Channel *c)
-{
- Uplink::Send(source, "TOPIC", c->name, c->topic);
-}
-
void IRCDProto::SendAction(const MessageSource &source, const Anope::string &dest, const Anope::string &message)
{
Anope::string actionbuf = "\1ACTION ";
@@ -185,42 +64,6 @@ void IRCDProto::SendAction(const MessageSource &source, const Anope::string &des
SendPrivmsg(source, dest, actionbuf);
}
-void IRCDProto::SendPing(const Anope::string &servname, const Anope::string &who)
-{
- if (servname.empty())
- Uplink::Send(Me, "PING", who);
- else
- Uplink::Send(Me, "PING", servname, who);
-}
-
-void IRCDProto::SendPong(const Anope::string &servname, const Anope::string &who)
-{
- if (servname.empty())
- Uplink::Send(Me, "PONG", who);
- else
- Uplink::Send(Me, "PONG", servname, who);
-}
-
-void IRCDProto::SendInvite(const MessageSource &source, Channel *c, User *u)
-{
- Uplink::Send(source, "INVITE", u->GetUID(), c->name);
-}
-
-void IRCDProto::SendSquit(Server *s, const Anope::string &message)
-{
- Uplink::Send("SQUIT", s->GetSID(), message);
-}
-
-void IRCDProto::SendNickChange(User *u, const Anope::string &newnick)
-{
- Uplink::Send(u, "NICK", newnick, Anope::CurTime);
-}
-
-void IRCDProto::SendForceNickChange(User *u, const Anope::string &newnick, time_t when)
-{
- Uplink::Send(u, "SVSNICK", u->GetUID(), newnick, when);
-}
-
bool IRCDProto::IsNickValid(const Anope::string &nick)
{
/**
@@ -236,7 +79,7 @@ bool IRCDProto::IsNickValid(const Anope::string &nick)
Anope::string special = "[]\\`_^{|}";
- for (unsigned i = 0; i < nick.length(); ++i)
+ for (unsigned int i = 0; i < nick.length(); ++i)
if (!(nick[i] >= 'A' && nick[i] <= 'Z') && !(nick[i] >= 'a' && nick[i] <= 'z')
&& special.find(nick[i]) == Anope::string::npos
&& (Config && Config->NickChars.find(nick[i]) == Anope::string::npos)
@@ -262,7 +105,7 @@ bool IRCDProto::IsIdentValid(const Anope::string &ident)
if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen"))
return false;
- for (unsigned i = 0; i < ident.length(); ++i)
+ for (unsigned int i = 0; i < ident.length(); ++i)
{
const char &c = ident[i];
@@ -289,7 +132,7 @@ bool IRCDProto::IsHostValid(const Anope::string &host)
return false;
int dots = 0;
- for (unsigned i = 0; i < host.length(); ++i)
+ for (unsigned int i = 0; i < host.length(); ++i)
{
if (host[i] == '.')
++dots;
@@ -300,12 +143,6 @@ bool IRCDProto::IsHostValid(const Anope::string &host)
return dots > 0 || Config->GetBlock("networkinfo")->Get<bool>("allow_undotted_vhosts");
}
-void IRCDProto::SendOper(User *u)
-{
- SendNumeric(RPL_YOUREOPER, u, "You are now an IRC operator (set by services)");
- u->SetMode(NULL, "OPER");
-}
-
unsigned int IRCDProto::GetMaxListFor(Channel *c)
{
return c->HasMode("LBAN") ? 0 : Config->GetBlock("networkinfo")->Get<int>("modelistsize");
@@ -376,7 +213,9 @@ Server *MessageSource::GetServer() const
return this->s;
}
-IRCDMessage::IRCDMessage(Module *o, const Anope::string &n, unsigned int p) : Service(o, "IRCDMessage", o->name + "/" + n.lower()), name(n), param_count(p)
+IRCDMessage::IRCDMessage(Module *o, const Anope::string &n, unsigned int p) : Service(o, NAME, o->name + "/" + n.lower())
+ , name(n)
+ , param_count(p)
{
}
diff --git a/src/servers.cpp b/src/servers.cpp
index 5f48a5e7c..a04e36ded 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -81,7 +81,7 @@ Server::~Server()
if (this->uplink)
this->uplink->DelLink(this);
- for (unsigned i = this->links.size(); i > 0; --i)
+ for (unsigned int i = this->links.size(); i > 0; --i)
this->links[i - 1]->Delete(this->quit_reason);
Servers::ByName.erase(this->name);
@@ -101,12 +101,12 @@ void Server::Burst()
{
IRCD->SendBOB();
- for (unsigned i = 0; i < Me->GetLinks().size(); ++i)
+ for (unsigned int i = 0; i < Me->GetLinks().size(); ++i)
{
Server *s = Me->GetLinks()[i];
if (s->juped)
- IRCD->SendServer(s);
+ IRCD->Send<messages::MessageServer>(s);
}
/* We make the bots go online */
@@ -117,11 +117,12 @@ void Server::Burst()
ServiceBot *bi = ServiceBot::Find(u->GetUID());
if (bi)
{
+#warning "xline on stack"
//XLine x(bi->nick, "Reserved for services");
//IRCD->SendSQLine(NULL, &x);
}
- IRCD->SendClientIntroduction(u);
+ IRCD->Send<messages::NickIntroduction>(u);
if (bi)
bi->introduced = true;
}
@@ -131,10 +132,10 @@ void Server::Burst()
Channel *c = it->second;
if (c->users.empty())
- IRCD->SendChannel(c);
+ IRCD->Send<messages::MessageChannel>(c);
else
for (Channel::ChanUserList::const_iterator cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end; ++cit)
- IRCD->SendJoin(cit->second->user, c, &cit->second->status);
+ IRCD->Send<messages::Join>(cit->second->user, c, &cit->second->status);
for (Channel::ModeList::const_iterator it2 = c->GetModes().begin(); it2 != c->GetModes().end(); ++it2)
{
@@ -145,7 +146,7 @@ void Server::Burst()
}
if (!c->topic.empty() && !c->topic_setter.empty())
- IRCD->SendTopic(c->ci->WhoSends(), c);
+ IRCD->Send<messages::Topic>(c->ci->WhoSends(), c, c->topic, c->topic_ts, c->topic_setter);
c->syncing = true;
}
@@ -308,9 +309,9 @@ bool Server::IsQuitting() const
void Server::Notice(ServiceBot *source, const Anope::string &message)
{
if (Config->UsePrivmsg && Config->DefPrivmsg)
- IRCD->SendGlobalPrivmsg(source, this, message);
+ IRCD->Send<messages::GlobalPrivmsg>(source, this, message);
else
- IRCD->SendGlobalNotice(source, this, message);
+ IRCD->Send<messages::GlobalNotice>(source, this, message);
}
Server *Server::Find(const Anope::string &name, bool name_only)
diff --git a/src/service_manager.cpp b/src/service_manager.cpp
index abebd1c3d..4c8d2a072 100644
--- a/src/service_manager.cpp
+++ b/src/service_manager.cpp
@@ -21,6 +21,7 @@
#include "services.h"
#include "service.h"
#include "logger.h"
+#include "modules.h"
ServiceManager *ServiceManager::manager = nullptr;
@@ -79,7 +80,7 @@ void ServiceManager::Register(Service *service)
Service *s = FindService(service->GetType(), service->GetName());
if (s != nullptr)
- throw ModuleException("Service of type " + service->GetType() + " with name " + service->GetName() + " already exists");
+ throw ModuleException("Service of type " + service->GetType() + " with name " + service->GetName() + " already exists from " + service->GetOwner()->name);
}
Log(LOG_DEBUG_3) << "Service registered: " << service->GetType() << " " << service->GetName() << " address " << static_cast<void *>(this) << " by " << service->GetOwner();
diff --git a/src/uplink.cpp b/src/uplink.cpp
index c2b7579c5..1615eef9d 100644
--- a/src/uplink.cpp
+++ b/src/uplink.cpp
@@ -105,7 +105,7 @@ UplinkSocket::~UplinkSocket()
}
}
- IRCD->SendSquit(Me, Anope::QuitReason);
+ IRCD->Send<messages::SQuit>(Me, Anope::QuitReason);
this->ProcessWrite(); // Write out the last bit
}
@@ -155,7 +155,7 @@ bool UplinkSocket::ProcessRead()
void UplinkSocket::OnConnect()
{
Log(LOG_TERMINAL) << "Successfully connected to uplink #" << (Anope::CurrentUplink + 1) << " " << Config->Uplinks[Anope::CurrentUplink].host << ":" << Config->Uplinks[Anope::CurrentUplink].port;
- IRCD->SendConnect();
+ IRCD->Handshake();
EventManager::Get()->Dispatch(&Event::ServerConnect::OnServerConnect);
}
diff --git a/src/users.cpp b/src/users.cpp
index 33a4cdaf6..a9bb432b5 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -30,6 +30,7 @@
#include "sockets.h"
#include "uplink.h"
#include "event.h"
+#include "messages.h"
#include "modules/nickserv.h"
user_map UserListByNick;
@@ -105,7 +106,7 @@ static void CollideKill(User *target, const Anope::string &reason)
static void Collide(User *u, const Anope::string &id, const Anope::string &type)
{
// Kill incoming user
- IRCD->SendKill(Me, id, type);
+ IRCD->Send<messages::Kill>(Me, id, Me->GetName() + " (" + type + ")");
// Quit colliding user
CollideKill(u, type);
}
@@ -383,7 +384,7 @@ void User::Identify(NickServ::Nick *na)
na->SetLastSeen(Anope::CurTime);
}
- IRCD->SendLogin(this, na);
+ IRCD->Send<messages::Login>(this, na);
this->Login(na->GetAccount());
@@ -397,15 +398,12 @@ void User::Identify(NickServ::Nick *na)
{
this->SetModes(NULL, "%s", m.c_str());
this->SendMessage(Me, "Changing your usermodes to \002{0}\002", m.c_str());
- UserMode *um = ModeManager::FindUserModeByName("OPER");
- if (um && !this->HasMode("OPER") && m.find(um->mchar) != Anope::string::npos)
- IRCD->SendOper(this);
}
if (IRCD->CanSetVHost && !oper->GetVhost().empty())
{
this->SendMessage(Me, "Changing your vhost to \002{0}\002", oper->GetVhost());
this->SetDisplayedHost(oper->GetVhost());
- IRCD->SendVhost(this, "", oper->GetVhost());
+ IRCD->Send<messages::VhostSet>(this, "", oper->GetVhost());
}
}
}
@@ -571,15 +569,12 @@ void User::SetModeInternal(const MessageSource &source, UserMode *um, const Anop
{
this->SetModes(NULL, "%s", m.c_str());
this->SendMessage(Me, "Changing your usermodes to \002{0}\002", m);
- UserMode *oper = ModeManager::FindUserModeByName("OPER");
- if (oper && !this->HasMode("OPER") && m.find(oper->mchar) != Anope::string::npos)
- IRCD->SendOper(this);
}
if (IRCD->CanSetVHost && !oper->GetVhost().empty())
{
this->SendMessage(Me, "Changing your vhost to \002{0}\002", oper->GetVhost());
this->SetDisplayedHost(oper->GetVhost());
- IRCD->SendVhost(this, "", oper->GetVhost());
+ IRCD->Send<messages::VhostSet>(this, "", oper->GetVhost());
}
}
}
@@ -769,7 +764,7 @@ void User::Kill(const MessageSource &source, const Anope::string &reason)
{
Anope::string real_reason = source.GetName() + " (" + reason + ")";
- IRCD->SendSVSKill(source, this, real_reason);
+ IRCD->SendKill(source, this, real_reason);
}
void User::KillInternal(const MessageSource &source, const Anope::string &reason)
@@ -853,7 +848,7 @@ bool User::BadPassword()
User* User::Find(const Anope::string &name, bool nick_only)
{
- if (!nick_only && IRCD->RequiresID)
+ if (!nick_only && IRCD && IRCD->RequiresID)
{
uid_map::iterator it = UserListByUID.find(name);
if (it != UserListByUID.end())