summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-01-05 15:04:01 +0100
committerAttila Molnar <attilamolnar@hush.com>2014-01-05 15:04:01 +0100
commit11916574f67962dce1d7a2fdf7ef6a3d2d1fa49f (patch)
tree1c3c602de5512a62e2db96652ddd540e6e53e821
parent2f181fef775da4a686a892c06af843dddfb7950a (diff)
Introduce Server class
- Replaces std::string server in User - Replaces InspIRCd::ULine() and SilentULine()
-rw-r--r--include/ctables.h9
-rw-r--r--include/inspircd.h13
-rw-r--r--include/modules/sql.h2
-rw-r--r--include/server.h59
-rw-r--r--include/typedefs.h1
-rw-r--r--include/users.h16
-rw-r--r--src/commands/cmd_kick.cpp2
-rw-r--r--src/commands/cmd_privmsg.cpp2
-rw-r--r--src/commands/cmd_stats.cpp2
-rw-r--r--src/commands/cmd_who.cpp4
-rw-r--r--src/commands/cmd_whois.cpp4
-rw-r--r--src/commands/cmd_whowas.cpp2
-rw-r--r--src/helperfuncs.cpp17
-rw-r--r--src/inspircd.cpp3
-rw-r--r--src/modes/umode_o.cpp5
-rw-r--r--src/modules/m_alias.cpp2
-rw-r--r--src/modules/m_check.cpp2
-rw-r--r--src/modules/m_chghost.cpp2
-rw-r--r--src/modules/m_chgident.cpp2
-rw-r--r--src/modules/m_commonchans.cpp2
-rw-r--r--src/modules/m_deaf.cpp2
-rw-r--r--src/modules/m_lockserv.cpp4
-rw-r--r--src/modules/m_passforward.cpp2
-rw-r--r--src/modules/m_remove.cpp2
-rw-r--r--src/modules/m_sajoin.cpp2
-rw-r--r--src/modules/m_sakick.cpp2
-rw-r--r--src/modules/m_sanick.cpp2
-rw-r--r--src/modules/m_sapart.cpp2
-rw-r--r--src/modules/m_saquit.cpp2
-rw-r--r--src/modules/m_serverban.cpp2
-rw-r--r--src/modules/m_showwhois.cpp2
-rw-r--r--src/modules/m_silence.cpp2
-rw-r--r--src/modules/m_spanningtree/addline.cpp2
-rw-r--r--src/modules/m_spanningtree/commandbuilder.h4
-rw-r--r--src/modules/m_spanningtree/fjoin.cpp8
-rw-r--r--src/modules/m_spanningtree/fmode.cpp2
-rw-r--r--src/modules/m_spanningtree/main.cpp34
-rw-r--r--src/modules/m_spanningtree/nick.cpp3
-rw-r--r--src/modules/m_spanningtree/opertype.cpp6
-rw-r--r--src/modules/m_spanningtree/override_map.cpp2
-rw-r--r--src/modules/m_spanningtree/postcommand.cpp2
-rw-r--r--src/modules/m_spanningtree/servercommand.h5
-rw-r--r--src/modules/m_spanningtree/treeserver.cpp28
-rw-r--r--src/modules/m_spanningtree/treeserver.h20
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp13
-rw-r--r--src/modules/m_spanningtree/uid.cpp8
-rw-r--r--src/modules/m_spanningtree/utils.cpp20
-rw-r--r--src/modules/m_spanningtree/utils.h1
-rw-r--r--src/modules/m_sslmodes.cpp2
-rw-r--r--src/modules/m_svshold.cpp2
-rw-r--r--src/modules/m_swhois.cpp4
-rw-r--r--src/modules/m_topiclock.cpp2
-rw-r--r--src/modules/m_uninvite.cpp4
-rw-r--r--src/modules/m_watch.cpp2
-rw-r--r--src/users.cpp10
55 files changed, 222 insertions, 139 deletions
diff --git a/include/ctables.h b/include/ctables.h
index 747901459..81b841e81 100644
--- a/include/ctables.h
+++ b/include/ctables.h
@@ -75,10 +75,17 @@ struct RouteDescriptor
*/
std::string serverdest;
+ /** For unicast, the destination Server
+ */
+ Server* server;
+
/** Create a RouteDescriptor
*/
RouteDescriptor(RouteType t, const std::string &d)
- : type(t), serverdest(d) { }
+ : type(t), serverdest(d), server(NULL) { }
+
+ RouteDescriptor(RouteType t, Server* srv)
+ : type(t), server(srv) { }
};
/** Do not route this command */
diff --git a/include/inspircd.h b/include/inspircd.h
index d045b347b..a2815b8a5 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -57,6 +57,7 @@ CoreExport extern InspIRCd* ServerInstance;
#include "fileutils.h"
#include "numerics.h"
#include "uid.h"
+#include "server.h"
#include "users.h"
#include "channels.h"
#include "timer.h"
@@ -621,18 +622,6 @@ class CoreExport InspIRCd
*/
int PassCompare(Extensible* ex, const std::string &data, const std::string &input, const std::string &hashtype);
- /** Check if a given server is a uline.
- * An empty string returns true, this is by design.
- * @param server The server to check for uline status
- * @return True if the server is a uline OR the string is empty
- */
- bool ULine(const std::string& server);
-
- /** Returns true if the uline is 'silent' (doesnt generate
- * remote connect notices etc).
- */
- bool SilentULine(const std::string& server);
-
/** Returns the full version string of this ircd
* @return The version string
*/
diff --git a/include/modules/sql.h b/include/modules/sql.h
index a671cc95c..3f378d8b8 100644
--- a/include/modules/sql.h
+++ b/include/modules/sql.h
@@ -178,7 +178,7 @@ class SQLProvider : public DataProvider
userinfo["ip"] = user->GetIPString();
userinfo["gecos"] = user->fullname;
userinfo["ident"] = user->ident;
- userinfo["server"] = user->server;
+ userinfo["server"] = user->server->GetName();
userinfo["uuid"] = user->uuid;
}
};
diff --git a/include/server.h b/include/server.h
new file mode 100644
index 000000000..e6e96593d
--- /dev/null
+++ b/include/server.h
@@ -0,0 +1,59 @@
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ * Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
+ *
+ * This file is part of InspIRCd. InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#pragma once
+
+class CoreExport Server : public classbase
+{
+ protected:
+ /** The name of this server
+ */
+ const std::string name;
+
+ /** True if this server is ulined
+ */
+ bool uline;
+
+ /** True if this server is a silent uline, i.e. silent="true" in the uline block
+ */
+ bool silentuline;
+
+ public:
+ Server(const std::string& srvname)
+ : name(srvname), uline(false), silentuline(false) { }
+
+ /**
+ * Returns the name of this server
+ * @return The name of this server, for example "irc.inspircd.org".
+ */
+ const std::string& GetName() const { return name; }
+
+ /**
+ * Checks whether this server is ulined
+ * @return True if this server is ulined, false otherwise.
+ */
+ bool IsULine() const { return uline; }
+
+ /**
+ * Checks whether this server is a silent uline
+ * Silent uline servers introduce, quit and oper up users without a snotice being generated.
+ * @return True if this server is a silent uline, false otherwise.
+ */
+ bool IsSilentULine() const { return silentuline; }
+};
diff --git a/include/typedefs.h b/include/typedefs.h
index 37e6daaf0..3801a48c0 100644
--- a/include/typedefs.h
+++ b/include/typedefs.h
@@ -38,6 +38,7 @@ class Module;
class OperInfo;
class ProtocolServer;
class RemoteUser;
+class Server;
class ServerConfig;
class ServerLimits;
class Thread;
diff --git a/include/users.h b/include/users.h
index fa9d97c21..bf4ba4de2 100644
--- a/include/users.h
+++ b/include/users.h
@@ -306,7 +306,7 @@ class CoreExport User : public Extensible
/** The server the user is connected to.
*/
- const std::string server;
+ Server* server;
/** The user's away message.
* If this string is empty, the user is not marked as away.
@@ -357,7 +357,7 @@ class CoreExport User : public Extensible
/** Constructor
* @throw CoreException if the UID allocated to the user already exists
*/
- User(const std::string &uid, const std::string& srv, int objtype);
+ User(const std::string& uid, Server* srv, int objtype);
/** Returns the full displayed host of the user
* This member function returns the hostname of the user as seen by other users
@@ -818,7 +818,7 @@ class CoreExport LocalUser : public User, public InviteBase
class CoreExport RemoteUser : public User
{
public:
- RemoteUser(const std::string& uid, const std::string& srv) : User(uid, srv, USERTYPE_REMOTE)
+ RemoteUser(const std::string& uid, Server* srv) : User(uid, srv, USERTYPE_REMOTE)
{
}
virtual void SendText(const std::string& line);
@@ -827,9 +827,15 @@ class CoreExport RemoteUser : public User
class CoreExport FakeUser : public User
{
public:
- FakeUser(const std::string &uid, const std::string& srv) : User(uid, srv, USERTYPE_SERVER)
+ FakeUser(const std::string& uid, Server* srv) : User(uid, srv, USERTYPE_SERVER)
{
- nick = srv;
+ nick = srv->GetName();
+ }
+
+ FakeUser(const std::string& uid, const std::string& sname)
+ : User(uid, new Server(sname), USERTYPE_SERVER)
+ {
+ nick = sname;
}
virtual CullResult cull();
diff --git a/src/commands/cmd_kick.cpp b/src/commands/cmd_kick.cpp
index 10022d105..033a00c41 100644
--- a/src/commands/cmd_kick.cpp
+++ b/src/commands/cmd_kick.cpp
@@ -76,7 +76,7 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
return CMD_FAILURE;
}
- if (ServerInstance->ULine(u->server))
+ if (u->server->IsULine())
{
user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You may not kick a u-lined client", c->name.c_str());
return CMD_FAILURE;
diff --git a/src/commands/cmd_privmsg.cpp b/src/commands/cmd_privmsg.cpp
index 79437432f..07d4a9cf7 100644
--- a/src/commands/cmd_privmsg.cpp
+++ b/src/commands/cmd_privmsg.cpp
@@ -188,7 +188,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para
nickonly.assign(destnick, 0, targetserver - destnick);
dest = ServerInstance->FindNickOnly(nickonly);
- if (dest && strcasecmp(dest->server.c_str(), targetserver + 1))
+ if (dest && strcasecmp(dest->server->GetName().c_str(), targetserver + 1))
{
/* Incorrect server for user */
user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str());
diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp
index 846af57db..5aa608f14 100644
--- a/src/commands/cmd_stats.cpp
+++ b/src/commands/cmd_stats.cpp
@@ -164,7 +164,7 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results)
for (std::list<User*>::const_iterator i = ServerInstance->Users->all_opers.begin(); i != ServerInstance->Users->all_opers.end(); ++i)
{
User* oper = *i;
- if (!ServerInstance->ULine(oper->server))
+ if (!oper->server->IsULine())
{
LocalUser* lu = IS_LOCAL(oper);
results.push_back(sn+" 249 " + user->nick + " :" + oper->nick + " (" + oper->ident + "@" + oper->dhost + ") Idle: " +
diff --git a/src/commands/cmd_who.cpp b/src/commands/cmd_who.cpp
index edfeeda42..a059a3f9c 100644
--- a/src/commands/cmd_who.cpp
+++ b/src/commands/cmd_who.cpp
@@ -168,7 +168,7 @@ bool CommandWho::whomatch(User* cuser, User* user, const char* matchtext)
/* Don't allow server name matches if HideWhoisServer is enabled, unless the command user has the priv */
if (!match && (ServerInstance->Config->HideWhoisServer.empty() || cuser->HasPrivPermission("users/auspex")))
- match = InspIRCd::Match(user->server, matchtext);
+ match = InspIRCd::Match(user->server->GetName(), matchtext);
return match;
}
@@ -204,7 +204,7 @@ void CommandWho::SendWhoLine(User* user, const std::vector<std::string>& parms,
if (!ServerInstance->Config->HideWhoisServer.empty() && !user->HasPrivPermission("servers/auspex"))
wholine.append(ServerInstance->Config->HideWhoisServer);
else
- wholine.append(u->server);
+ wholine.append(u->server->GetName());
wholine.append(" " + u->nick + " ");
diff --git a/src/commands/cmd_whois.cpp b/src/commands/cmd_whois.cpp
index a6a4447b9..fdc2ad045 100644
--- a/src/commands/cmd_whois.cpp
+++ b/src/commands/cmd_whois.cpp
@@ -144,8 +144,8 @@ void CommandWhois::DoWhois(User* user, User* dest, unsigned long signon, unsigne
}
else
{
- std::string serverdesc = ServerInstance->GetServerDescription(dest->server);
- ServerInstance->SendWhoisLine(user, dest, 312, "%s %s :%s", dest->nick.c_str(), dest->server.c_str(), serverdesc.c_str());
+ std::string serverdesc = ServerInstance->GetServerDescription(dest->server->GetName());
+ ServerInstance->SendWhoisLine(user, dest, 312, "%s %s :%s", dest->nick.c_str(), dest->server->GetName().c_str(), serverdesc.c_str());
}
if (dest->IsAway())
diff --git a/src/commands/cmd_whowas.cpp b/src/commands/cmd_whowas.cpp
index fab65aae3..6a561907e 100644
--- a/src/commands/cmd_whowas.cpp
+++ b/src/commands/cmd_whowas.cpp
@@ -215,7 +215,7 @@ CommandWhowas::~CommandWhowas()
}
WhoWasGroup::WhoWasGroup(User* user) : host(user->host), dhost(user->dhost), ident(user->ident),
- server(user->server), gecos(user->fullname), signon(user->signon)
+ server(user->server->GetName()), gecos(user->fullname), signon(user->signon)
{
}
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 354d0a112..655bf9ae4 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -420,23 +420,6 @@ const char* InspIRCd::Format(const char* formatString, ...)
return ret;
}
-bool InspIRCd::ULine(const std::string& sserver)
-{
- if (sserver.empty())
- return true;
-
- return (Config->ulines.find(sserver.c_str()) != Config->ulines.end());
-}
-
-bool InspIRCd::SilentULine(const std::string& sserver)
-{
- std::map<irc::string,bool>::iterator n = Config->ulines.find(sserver.c_str());
- if (n != Config->ulines.end())
- return n->second;
- else
- return false;
-}
-
std::string InspIRCd::TimeString(time_t curtime)
{
#ifdef _WIN32
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index de9287270..50feab459 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -120,7 +120,10 @@ void InspIRCd::Cleanup()
/* Delete objects dynamically allocated in constructor (destructor would be more appropriate, but we're likely exiting) */
/* Must be deleted before modes as it decrements modelines */
if (FakeClient)
+ {
+ delete FakeClient->server;
FakeClient->cull();
+ }
DeleteZero(this->FakeClient);
DeleteZero(this->Users);
DeleteZero(this->Modes);
diff --git a/src/modes/umode_o.cpp b/src/modes/umode_o.cpp
index 45b99b1d6..affd6b50c 100644
--- a/src/modes/umode_o.cpp
+++ b/src/modes/umode_o.cpp
@@ -32,7 +32,7 @@ ModeUserOperator::ModeUserOperator() : ModeHandler(NULL, "oper", 'o', PARAM_NONE
ModeAction ModeUserOperator::OnModeChange(User* source, User* dest, Channel*, std::string&, bool adding)
{
/* Only opers can execute this class at all */
- if (!ServerInstance->ULine(source->server) && !source->IsOper())
+ if (!source->server->IsULine() && !source->IsOper())
return MODEACTION_DENY;
/* Not even opers can GIVE the +o mode, only take it away */
@@ -46,8 +46,7 @@ ModeAction ModeUserOperator::OnModeChange(User* source, User* dest, Channel*, st
* to your User!
*/
char snomask = IS_LOCAL(dest) ? 'o' : 'O';
- ServerInstance->SNO->WriteToSnoMask(snomask, "User %s de-opered (by %s)", dest->nick.c_str(),
- source->nick.empty() ? source->server.c_str() : source->nick.c_str());
+ ServerInstance->SNO->WriteToSnoMask(snomask, "User %s de-opered (by %s)", dest->nick.c_str(), source->nick.c_str());
dest->UnOper();
return MODEACTION_ALLOW;
diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp
index 78628cf06..5fea846da 100644
--- a/src/modules/m_alias.cpp
+++ b/src/modules/m_alias.cpp
@@ -274,7 +274,7 @@ class ModuleAlias : public Module
}
if ((u != NULL) && (!a->RequiredNick.empty()) && (a->ULineOnly))
{
- if (!ServerInstance->ULine(u->server))
+ if (!u->server->IsULine())
{
ServerInstance->SNO->WriteToSnoMask('a', "NOTICE -- Service "+a->RequiredNick+" required by alias "+a->AliasedCommand+" is not on a u-lined server, possibly underhanded antics detected!");
user->WriteNumeric(ERR_NOSUCHNICK, a->RequiredNick + " :is an imposter! Please inform an IRC operator as soon as possible.");
diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp
index 84e147f7b..d12d2728d 100644
--- a/src/modules/m_check.cpp
+++ b/src/modules/m_check.cpp
@@ -126,7 +126,7 @@ class CommandCheck : public Command
user->SendText(checkstr + " realname " + targuser->fullname);
user->SendText(checkstr + " modes +" + targuser->FormatModes());
user->SendText(checkstr + " snomasks " + GetSnomasks(targuser));
- user->SendText(checkstr + " server " + targuser->server);
+ user->SendText(checkstr + " server " + targuser->server->GetName());
user->SendText(checkstr + " uid " + targuser->uuid);
user->SendText(checkstr + " signon " + timestring(targuser->signon));
user->SendText(checkstr + " nickts " + timestring(targuser->age));
diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp
index f79ae4624..eefac00f1 100644
--- a/src/modules/m_chghost.cpp
+++ b/src/modules/m_chghost.cpp
@@ -64,7 +64,7 @@ class CommandChghost : public Command
if (IS_LOCAL(dest))
{
- if ((dest->ChangeDisplayedHost(parameters[1])) && (!ServerInstance->ULine(user->server)))
+ if ((dest->ChangeDisplayedHost(parameters[1])) && (!user->server->IsULine()))
{
// fix by brain - ulines set hosts silently
ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used CHGHOST to make the displayed host of "+dest->nick+" become "+dest->dhost);
diff --git a/src/modules/m_chgident.cpp b/src/modules/m_chgident.cpp
index 6d5df7be5..4607ae1a3 100644
--- a/src/modules/m_chgident.cpp
+++ b/src/modules/m_chgident.cpp
@@ -61,7 +61,7 @@ class CommandChgident : public Command
{
dest->ChangeIdent(parameters[1]);
- if (!ServerInstance->ULine(user->server))
+ if (!user->server->IsULine())
ServerInstance->SNO->WriteGlobalSno('a', "%s used CHGIDENT to change %s's ident to '%s'", user->nick.c_str(), dest->nick.c_str(), dest->ident.c_str());
}
diff --git a/src/modules/m_commonchans.cpp b/src/modules/m_commonchans.cpp
index b955184e0..eab53b9bc 100644
--- a/src/modules/m_commonchans.cpp
+++ b/src/modules/m_commonchans.cpp
@@ -45,7 +45,7 @@ class ModulePrivacyMode : public Module
if (target_type == TYPE_USER)
{
User* t = (User*)dest;
- if (!user->IsOper() && (t->IsModeSet(pm)) && (!ServerInstance->ULine(user->server)) && !user->SharesChannelWith(t))
+ if (!user->IsOper() && (t->IsModeSet(pm)) && (!user->server->IsULine()) && !user->SharesChannelWith(t))
{
user->WriteNumeric(ERR_CANTSENDTOUSER, "%s :You are not permitted to send private messages to this user (+c set)", t->nick.c_str());
return MOD_RES_DENY;
diff --git a/src/modules/m_deaf.cpp b/src/modules/m_deaf.cpp
index 468f1046a..26d5029e8 100644
--- a/src/modules/m_deaf.cpp
+++ b/src/modules/m_deaf.cpp
@@ -109,7 +109,7 @@ class ModuleDeaf : public Module
if (is_bypasschar && is_bypasschar_uline)
continue; /* deliver message */
- is_a_uline = ServerInstance->ULine(i->first->server);
+ is_a_uline = i->first->server->IsULine();
/* matched a U-line only bypass */
if (is_bypasschar_uline && is_a_uline)
continue; /* deliver message */
diff --git a/src/modules/m_lockserv.cpp b/src/modules/m_lockserv.cpp
index 56c7b9c94..65b9aa036 100644
--- a/src/modules/m_lockserv.cpp
+++ b/src/modules/m_lockserv.cpp
@@ -44,7 +44,7 @@ class CommandLockserv : public Command
}
locked = true;
- user->WriteNumeric(988, "%s :Closed for new connections", user->server.c_str());
+ user->WriteNumeric(988, "%s :Closed for new connections", user->server->GetName().c_str());
ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used LOCKSERV to temporarily disallow new connections", user->nick.c_str());
return CMD_SUCCESS;
}
@@ -69,7 +69,7 @@ class CommandUnlockserv : public Command
}
locked = false;
- user->WriteNumeric(989, "%s :Open for new connections", user->server.c_str());
+ user->WriteNumeric(989, "%s :Open for new connections", user->server->GetName().c_str());
ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used UNLOCKSERV to allow new connections", user->nick.c_str());
return CMD_SUCCESS;
}
diff --git a/src/modules/m_passforward.cpp b/src/modules/m_passforward.cpp
index 589fc06a6..b5696c8f4 100644
--- a/src/modules/m_passforward.cpp
+++ b/src/modules/m_passforward.cpp
@@ -82,7 +82,7 @@ class ModulePassForward : public Module
{
/* Check if nick exists and its server is ulined */
User* u = ServerInstance->FindNick(nickrequired);
- if (!u || !ServerInstance->ULine(u->server))
+ if (!u || !u->server->IsULine())
return;
}
diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp
index d18f57916..4dcd5aaa1 100644
--- a/src/modules/m_remove.cpp
+++ b/src/modules/m_remove.cpp
@@ -81,7 +81,7 @@ class RemoveBase : public Command
int ulevel = channel->GetPrefixValue(user);
int tlevel = channel->GetPrefixValue(target);
- if (ServerInstance->ULine(target->server))
+ if (target->server->IsULine())
{
user->WriteNumeric(482, "%s :Only a u-line may remove a u-line from a channel.", channame.c_str());
return CMD_FAILURE;
diff --git a/src/modules/m_sajoin.cpp b/src/modules/m_sajoin.cpp
index 9d1e34ff3..eda58ef96 100644
--- a/src/modules/m_sajoin.cpp
+++ b/src/modules/m_sajoin.cpp
@@ -38,7 +38,7 @@ class CommandSajoin : public Command
User* dest = ServerInstance->FindNick(parameters[0]);
if ((dest) && (dest->registered == REG_ALL))
{
- if (ServerInstance->ULine(dest->server))
+ if (dest->server->IsULine())
{
user->WriteNumeric(ERR_NOPRIVILEGES, ":Cannot use an SA command on a u-lined client");
return CMD_FAILURE;
diff --git a/src/modules/m_sakick.cpp b/src/modules/m_sakick.cpp
index 0e37acc3f..911b826dc 100644
--- a/src/modules/m_sakick.cpp
+++ b/src/modules/m_sakick.cpp
@@ -40,7 +40,7 @@ class CommandSakick : public Command
{
const std::string& reason = (parameters.size() > 2) ? parameters[2] : dest->nick;
- if (ServerInstance->ULine(dest->server))
+ if (dest->server->IsULine())
{
user->WriteNumeric(ERR_NOPRIVILEGES, ":Cannot use an SA command on a u-lined client");
return CMD_FAILURE;
diff --git a/src/modules/m_sanick.cpp b/src/modules/m_sanick.cpp
index 5f7860677..4ce6a5fb2 100644
--- a/src/modules/m_sanick.cpp
+++ b/src/modules/m_sanick.cpp
@@ -40,7 +40,7 @@ class CommandSanick : public Command
/* Do local sanity checks and bails */
if (IS_LOCAL(user))
{
- if (target && ServerInstance->ULine(target->server))
+ if (target && target->server->IsULine())
{
user->WriteNumeric(ERR_NOPRIVILEGES, ":Cannot use an SA command on a u-lined client");
return CMD_FAILURE;
diff --git a/src/modules/m_sapart.cpp b/src/modules/m_sapart.cpp
index 6de01c852..fa5ab176a 100644
--- a/src/modules/m_sapart.cpp
+++ b/src/modules/m_sapart.cpp
@@ -43,7 +43,7 @@ class CommandSapart : public Command
if (parameters.size() > 2)
reason = parameters[2];
- if (ServerInstance->ULine(dest->server))
+ if (dest->server->IsULine())
{
user->WriteNumeric(ERR_NOPRIVILEGES, ":Cannot use an SA command on a u-lined client");
return CMD_FAILURE;
diff --git a/src/modules/m_saquit.cpp b/src/modules/m_saquit.cpp
index 27ef86eb2..ee6de5e94 100644
--- a/src/modules/m_saquit.cpp
+++ b/src/modules/m_saquit.cpp
@@ -37,7 +37,7 @@ class CommandSaquit : public Command
User* dest = ServerInstance->FindNick(parameters[0]);
if ((dest) && (!IS_SERVER(dest)))
{
- if (ServerInstance->ULine(dest->server))
+ if (dest->server->IsULine())
{
user->WriteNumeric(ERR_NOPRIVILEGES, ":Cannot use an SA command on a u-lined client");
return CMD_FAILURE;
diff --git a/src/modules/m_serverban.cpp b/src/modules/m_serverban.cpp
index 87fe08670..f51d1d373 100644
--- a/src/modules/m_serverban.cpp
+++ b/src/modules/m_serverban.cpp
@@ -31,7 +31,7 @@ class ModuleServerBan : public Module
{
if ((mask.length() > 2) && (mask[0] == 's') && (mask[1] == ':'))
{
- if (InspIRCd::Match(user->server, mask.substr(2)))
+ if (InspIRCd::Match(user->server->GetName(), mask.substr(2)))
return MOD_RES_DENY;
}
return MOD_RES_PASSTHRU;
diff --git a/src/modules/m_showwhois.cpp b/src/modules/m_showwhois.cpp
index 9ae0c8d7a..7a3b2d352 100644
--- a/src/modules/m_showwhois.cpp
+++ b/src/modules/m_showwhois.cpp
@@ -110,7 +110,7 @@ class ModuleShowwhois : public Module
else
{
std::vector<std::string> params;
- params.push_back(dest->server);
+ params.push_back(dest->server->GetName());
params.push_back("WHOISNOTICE");
params.push_back(dest->uuid);
params.push_back(source->uuid);
diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp
index 1c76b72f7..03d2b7953 100644
--- a/src/modules/m_silence.cpp
+++ b/src/modules/m_silence.cpp
@@ -76,7 +76,7 @@ class CommandSVSSilence : public Command
* style command so services can modify lots of entries at once.
* leaving it backwards compatible for now as it's late. -- w
*/
- if (!ServerInstance->ULine(user->server))
+ if (!user->server->IsULine())
return CMD_FAILURE;
User *u = ServerInstance->FindNick(parameters[0]);
diff --git a/src/modules/m_spanningtree/addline.cpp b/src/modules/m_spanningtree/addline.cpp
index c6ca17db0..dbf0003bf 100644
--- a/src/modules/m_spanningtree/addline.cpp
+++ b/src/modules/m_spanningtree/addline.cpp
@@ -60,7 +60,7 @@ CmdResult CommandAddLine::Handle(User* usr, std::vector<std::string>& params)
params[1].c_str(),params[5].c_str());
}
- TreeServer* remoteserver = Utils->FindServer(usr->server);
+ TreeServer* remoteserver = TreeServer::Get(usr);
if (!remoteserver->bursting)
{
diff --git a/src/modules/m_spanningtree/commandbuilder.h b/src/modules/m_spanningtree/commandbuilder.h
index aa4778fa9..cd627227a 100644
--- a/src/modules/m_spanningtree/commandbuilder.h
+++ b/src/modules/m_spanningtree/commandbuilder.h
@@ -133,8 +133,8 @@ class CmdBuilder
return Utils->DoOneToOne(*this, target);
}
- bool Unicast(User* target) const
+ void Unicast(User* target) const
{
- return Unicast(target->server);
+ Utils->DoOneToOne(*this, target->server);
}
};
diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp
index 0fb446877..47d8efb82 100644
--- a/src/modules/m_spanningtree/fjoin.cpp
+++ b/src/modules/m_spanningtree/fjoin.cpp
@@ -73,7 +73,7 @@ CmdResult CommandFJoin::Handle(User* srcuser, std::vector<std::string>& params)
if (!TS)
{
ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "*** BUG? *** TS of 0 sent to FJOIN. Are some services authors smoking craq, or is it 1970 again?. Dropped.");
- ServerInstance->SNO->WriteToSnoMask('d', "WARNING: The server %s is sending FJOIN with a TS of zero. Total craq. Command was dropped.", srcuser->server.c_str());
+ ServerInstance->SNO->WriteToSnoMask('d', "WARNING: The server %s is sending FJOIN with a TS of zero. Total craq. Command was dropped.", srcuser->server->GetName().c_str());
return CMD_INVALID;
}
@@ -157,7 +157,7 @@ CmdResult CommandFJoin::Handle(User* srcuser, std::vector<std::string>& params)
}
irc::modestacker modestack(true);
- TreeSocket* src_socket = Utils->FindServer(srcuser->server)->GetSocket();
+ TreeSocket* src_socket = TreeServer::Get(srcuser)->GetSocket();
/* Now, process every 'modes,uuid' pair */
irc::tokenstream users(*params.rbegin());
@@ -190,8 +190,8 @@ bool CommandFJoin::ProcessModeUUIDPair(const std::string& item, TreeSocket* src_
}
/* Check that the user's 'direction' is correct */
- TreeServer* route_back_again = Utils->BestRouteTo(who->server);
- if ((!route_back_again) || (route_back_again->GetSocket() != src_socket))
+ TreeServer* route_back_again = TreeServer::Get(who);
+ if (route_back_again->GetSocket() != src_socket)
{
return true;
}
diff --git a/src/modules/m_spanningtree/fmode.cpp b/src/modules/m_spanningtree/fmode.cpp
index 16af5ccc0..bad68f053 100644
--- a/src/modules/m_spanningtree/fmode.cpp
+++ b/src/modules/m_spanningtree/fmode.cpp
@@ -28,7 +28,7 @@ CmdResult CommandFMode::Handle(User* who, std::vector<std::string>& params)
if (!TS)
{
ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "*** BUG? *** TS of 0 sent to FMODE. Are some services authors smoking craq, or is it 1970 again?. Dropping link.");
- ServerInstance->SNO->WriteToSnoMask('d', "WARNING: The server %s is sending FMODE with a TS of zero. Total craq, dropping link.", who->server.c_str());
+ ServerInstance->SNO->WriteToSnoMask('d', "WARNING: The server %s is sending FMODE with a TS of zero. Total craq, dropping link.", who->server->GetName().c_str());
return CMD_INVALID;
}
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 8c04d6c90..3efd012ba 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -52,6 +52,17 @@ SpanningTreeCommands::SpanningTreeCommands(ModuleSpanningTree* module)
{
}
+namespace
+{
+ void SetLocalUsersServer(Server* newserver)
+ {
+ ServerInstance->FakeClient->server = newserver;
+ const LocalUserList& list = ServerInstance->Users->local_users;
+ for (LocalUserList::const_iterator i = list.begin(); i != list.end(); ++i)
+ (*i)->server = newserver;
+ }
+}
+
void ModuleSpanningTree::init()
{
ServerInstance->SNO->EnableSnomask('l', "LINK");
@@ -62,6 +73,10 @@ void ModuleSpanningTree::init()
delete ServerInstance->PI;
ServerInstance->PI = new SpanningTreeProtocolInterface;
+
+ delete ServerInstance->FakeClient->server;
+ SetLocalUsersServer(Utils->TreeRoot);
+
loopCall = false;
SplitInProgress = false;
@@ -81,7 +96,7 @@ void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops)
for (TreeServer::ChildServers::const_iterator i = children.begin(); i != children.end(); ++i)
{
TreeServer* server = *i;
- if ((server->Hidden) || ((Utils->HideULines) && (ServerInstance->ULine(server->GetName()))))
+ if ((server->Hidden) || ((Utils->HideULines) && (server->IsULine())))
{
if (user->IsOper())
{
@@ -94,7 +109,7 @@ void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops)
}
}
/* Don't display the line if its a uline, hide ulines is on, and the user isnt an oper */
- if ((Utils->HideULines) && (ServerInstance->ULine(Current->GetName())) && (!user->IsOper()))
+ if ((Utils->HideULines) && (Current->IsULine()) && (!user->IsOper()))
return;
/* Or if the server is hidden and they're not an oper */
else if ((Current->Hidden) && (!user->IsOper()))
@@ -560,20 +575,16 @@ void ModuleSpanningTree::OnUserQuit(User* user, const std::string &reason, const
// Hide the message if one of the following is true:
// - User is being quit due to a netsplit and quietbursts is on
// - Server is a silent uline
- bool hide = (((this->SplitInProgress) && (Utils->quiet_bursts)) || (ServerInstance->SilentULine(user->server)));
+ bool hide = (((this->SplitInProgress) && (Utils->quiet_bursts)) || (user->server->IsSilentULine()));
if (!hide)
{
ServerInstance->SNO->WriteToSnoMask('Q', "Client exiting on server %s: %s (%s) [%s]",
- user->server.c_str(), user->GetFullRealHost().c_str(), user->GetIPString().c_str(), oper_message.c_str());
+ user->server->GetName().c_str(), user->GetFullRealHost().c_str(), user->GetIPString().c_str(), oper_message.c_str());
}
}
// Regardless, We need to modify the user Counts..
- TreeServer* SourceServer = Utils->FindServer(user->server);
- if (SourceServer)
- {
- SourceServer->UserCount--;
- }
+ TreeServer::Get(user)->UserCount--;
}
void ModuleSpanningTree::OnUserPostNick(User* user, const std::string &oldnick)
@@ -624,7 +635,7 @@ void ModuleSpanningTree::OnPreRehash(User* user, const std::string &parameter)
{
CmdBuilder params((user ? user->uuid : ServerInstance->Config->GetSID()), "REHASH");
params.push_back(parameter);
- params.Forward(user ? Utils->BestRouteTo(user->server) : NULL);
+ params.Forward(user ? TreeServer::Get(user)->GetRoute() : NULL);
}
}
@@ -743,6 +754,9 @@ ModuleSpanningTree::~ModuleSpanningTree()
delete ServerInstance->PI;
ServerInstance->PI = new ProtocolInterface;
+ Server* newsrv = new Server(ServerInstance->Config->ServerName);
+ SetLocalUsersServer(newsrv);
+
/* This will also free the listeners */
delete Utils;
diff --git a/src/modules/m_spanningtree/nick.cpp b/src/modules/m_spanningtree/nick.cpp
index 7ace9cc73..eb6c9396f 100644
--- a/src/modules/m_spanningtree/nick.cpp
+++ b/src/modules/m_spanningtree/nick.cpp
@@ -28,6 +28,7 @@
#include "main.h"
#include "utils.h"
#include "commands.h"
+#include "treeserver.h"
CmdResult CommandNick::HandleRemote(RemoteUser* user, std::vector<std::string>& params)
{
@@ -45,7 +46,7 @@ CmdResult CommandNick::HandleRemote(RemoteUser* user, std::vector<std::string>&
if ((x) && (x != user))
{
/* x is local, who is remote */
- int collideret = Utils->DoCollision(x, Utils->FindServer(user->server), user->age, user->ident, user->GetIPString(), user->uuid);
+ int collideret = Utils->DoCollision(x, TreeServer::Get(user), user->age, user->ident, user->GetIPString(), user->uuid);
if (collideret != 1)
{
/*
diff --git a/src/modules/m_spanningtree/opertype.cpp b/src/modules/m_spanningtree/opertype.cpp
index 6e5d473aa..1a9e36f72 100644
--- a/src/modules/m_spanningtree/opertype.cpp
+++ b/src/modules/m_spanningtree/opertype.cpp
@@ -50,12 +50,12 @@ CmdResult CommandOpertype::HandleRemote(RemoteUser* u, std::vector<std::string>&
* If quiet bursts are enabled, and server is bursting or silent uline (i.e. services),
* then do nothing. -- w00t
*/
- TreeServer* remoteserver = Utils->FindServer(u->server);
- if (remoteserver->bursting || ServerInstance->SilentULine(u->server))
+ TreeServer* remoteserver = TreeServer::Get(u);
+ if (remoteserver->bursting || remoteserver->IsSilentULine())
return CMD_SUCCESS;
}
- ServerInstance->SNO->WriteToSnoMask('O',"From %s: User %s (%s@%s) is now an IRC operator of type %s",u->server.c_str(), u->nick.c_str(),u->ident.c_str(), u->host.c_str(), opertype.c_str());
+ ServerInstance->SNO->WriteToSnoMask('O',"From %s: User %s (%s@%s) is now an IRC operator of type %s",u->server->GetName().c_str(), u->nick.c_str(),u->ident.c_str(), u->host.c_str(), opertype.c_str());
return CMD_SUCCESS;
}
diff --git a/src/modules/m_spanningtree/override_map.cpp b/src/modules/m_spanningtree/override_map.cpp
index abefa823b..a9b68eb9b 100644
--- a/src/modules/m_spanningtree/override_map.cpp
+++ b/src/modules/m_spanningtree/override_map.cpp
@@ -85,7 +85,7 @@ void CommandMap::ShowMap(TreeServer* Current, User* user, int depth, int &line,
if (!user->IsOper()) {
if (child->Hidden)
continue;
- if ((Utils->HideULines) && (ServerInstance->ULine(child->GetName())))
+ if ((Utils->HideULines) && (child->IsULine()))
continue;
}
ShowMap(child, user, depth, line, names, maxnamew, stats);
diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp
index 57fbca6bc..a059bcb5f 100644
--- a/src/modules/m_spanningtree/postcommand.cpp
+++ b/src/modules/m_spanningtree/postcommand.cpp
@@ -102,7 +102,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm
User* d = ServerInstance->FindNick(dest);
if (!d)
return;
- TreeServer* tsd = BestRouteTo(d->server);
+ TreeServer* tsd = TreeServer::Get(d)->GetRoute();
if (tsd == origin)
// huh? no routing stuff around in a circle, please.
return;
diff --git a/src/modules/m_spanningtree/servercommand.h b/src/modules/m_spanningtree/servercommand.h
index 2bd77fc84..156b405e4 100644
--- a/src/modules/m_spanningtree/servercommand.h
+++ b/src/modules/m_spanningtree/servercommand.h
@@ -20,8 +20,7 @@
#pragma once
#include "utils.h"
-
-class TreeServer;
+#include "treeserver.h"
/** Base class for server-to-server commands that may have a (remote) user source or server source.
*/
@@ -67,7 +66,7 @@ class ServerOnlyServerCommand : public ServerCommand
{
if (!IS_SERVER(user))
return CMD_INVALID;
- TreeServer* server = Utils->FindServer(user->server);
+ TreeServer* server = TreeServer::Get(user);
return static_cast<T*>(this)->HandleServer(server, parameters);
}
};
diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp
index 7d8abf4bf..34b71e07f 100644
--- a/src/modules/m_spanningtree/treeserver.cpp
+++ b/src/modules/m_spanningtree/treeserver.cpp
@@ -33,7 +33,8 @@
* no socket associated with it. Its version string is our own local version.
*/
TreeServer::TreeServer()
- : Parent(NULL), Route(NULL), ServerName(ServerInstance->Config->ServerName), ServerDesc(ServerInstance->Config->ServerDesc)
+ : Server(ServerInstance->Config->ServerName)
+ , Parent(NULL), Route(NULL), ServerDesc(ServerInstance->Config->ServerDesc)
, VersionString(ServerInstance->GetVersionString()), Socket(NULL), sid(ServerInstance->Config->GetSID()), ServerUser(ServerInstance->FakeClient)
, age(ServerInstance->Time()), Warned(false), bursting(false), UserCount(0), OperCount(0), rtt(0), StartBurst(0), Hidden(false)
{
@@ -45,9 +46,11 @@ TreeServer::TreeServer()
* its ping counters so that it will be pinged one minute from now.
*/
TreeServer::TreeServer(const std::string& Name, const std::string& Desc, const std::string& id, TreeServer* Above, TreeSocket* Sock, bool Hide)
- : Parent(Above), ServerName(Name), ServerDesc(Desc), Socket(Sock), sid(id), ServerUser(new FakeUser(id, Name))
+ : Server(Name)
+ , Parent(Above), ServerDesc(Desc), Socket(Sock), sid(id), ServerUser(new FakeUser(id, this))
, age(ServerInstance->Time()), Warned(false), bursting(true), UserCount(0), OperCount(0), rtt(0), Hidden(Hide)
{
+ CheckULine();
SetNextPingTime(ServerInstance->Time() + Utils->PingFreq);
SetPingFlag();
@@ -133,8 +136,8 @@ void TreeServer::FinishBurst()
long ts = ServerInstance->Time() * 1000 + (ServerInstance->Time_ns() / 1000000);
unsigned long bursttime = ts - this->StartBurst;
ServerInstance->SNO->WriteToSnoMask(Parent == Utils->TreeRoot ? 'l' : 'L', "Received end of netburst from \2%s\2 (burst time: %lu %s)",
- ServerName.c_str(), (bursttime > 10000 ? bursttime / 1000 : bursttime), (bursttime > 10000 ? "secs" : "msecs"));
- AddServerEvent(Utils->Creator, ServerName);
+ GetName().c_str(), (bursttime > 10000 ? bursttime / 1000 : bursttime), (bursttime > 10000 ? "secs" : "msecs"));
+ AddServerEvent(Utils->Creator, GetName());
}
int TreeServer::QuitUsers(const std::string &reason)
@@ -148,19 +151,30 @@ int TreeServer::QuitUsers(const std::string &reason)
User* user = i->second;
// Increment the iterator now because QuitUser() removes the user from the container
++i;
- if (user->server == ServerName)
+ if (user->server == this)
ServerInstance->Users->QuitUser(user, publicreason, &reason);
}
return original_size - users.size();
}
+void TreeServer::CheckULine()
+{
+ uline = silentuline = false;
+ std::map<irc::string, bool>::iterator it = ServerInstance->Config->ulines.find(GetName().c_str());
+ if (it != ServerInstance->Config->ulines.end())
+ {
+ uline = true;
+ silentuline = it->second;
+ }
+}
+
/** This method is used to add the structure to the
* hash_map for linear searches. It is only called
* by the constructors.
*/
void TreeServer::AddHashEntry()
{
- Utils->serverlist[ServerName] = this;
+ Utils->serverlist[GetName()] = this;
Utils->sidlist[sid] = this;
}
@@ -267,5 +281,5 @@ TreeServer::~TreeServer()
delete ServerUser;
Utils->sidlist.erase(sid);
- Utils->serverlist.erase(ServerName);
+ Utils->serverlist.erase(GetName());
}
diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h
index 8178c87fa..67ce96e63 100644
--- a/src/modules/m_spanningtree/treeserver.h
+++ b/src/modules/m_spanningtree/treeserver.h
@@ -37,12 +37,11 @@
* TreeServer items, deleting and inserting them as they
* are created and destroyed.
*/
-class TreeServer : public classbase
+class TreeServer : public Server
{
TreeServer* Parent; /* Parent entry */
TreeServer* Route; /* Route entry */
std::vector<TreeServer*> Children; /* List of child objects */
- std::string ServerName; /* Server's name */
std::string ServerDesc; /* Server's description */
std::string VersionString; /* Version string or empty string */
TreeSocket* Socket; /* Socket used to communicate with this server */
@@ -94,10 +93,6 @@ class TreeServer : public classbase
*/
bool IsLocal() const { return (this->Route == this); }
- /** Get server name
- */
- const std::string& GetName() const { return ServerName; }
-
/** Get server description (GECOS)
*/
const std::string& GetDesc();
@@ -180,6 +175,10 @@ class TreeServer : public classbase
/** Recursive call for child servers */
void FinishBurstInternal();
+ /** (Re)check the uline state of this server
+ */
+ void CheckULine();
+
CullResult cull();
/** Destructor
@@ -187,4 +186,13 @@ class TreeServer : public classbase
* hash maps.
*/
~TreeServer();
+
+ /** Returns the TreeServer the given user is connected to
+ * @param user The user whose server to return
+ * @return The TreeServer this user is connected to.
+ */
+ static TreeServer* Get(User* user)
+ {
+ return static_cast<TreeServer*>(user->server);
+ }
};
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index b66595bd1..f97ce5539 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -229,7 +229,6 @@ void TreeSocket::ProcessLine(std::string &line)
void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command, parameterlist& params)
{
User* who = ServerInstance->FindUUID(prefix);
- std::string direction;
if (!who)
{
@@ -269,10 +268,6 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
}
}
- // Make sure prefix is still good
- direction = who->server;
- prefix = who->uuid;
-
/*
* Check for fake direction here, and drop any instances that are found.
* What is fake direction? Imagine the following server setup:
@@ -289,12 +284,10 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
* a valid SID or a valid UUID, so that invalid UUID or SID never makes it
* to the higher level functions. -- B
*/
- TreeServer* route_back_again = Utils->BestRouteTo(direction);
- if ((!route_back_again) || (route_back_again->GetSocket() != this))
+ TreeServer* route_back_again = TreeServer::Get(who)->GetRoute();
+ if (route_back_again->GetSocket() != this)
{
- if (route_back_again)
- ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Protocol violation: Fake direction '%s' from connection '%s'",
- prefix.c_str(),linkID.c_str());
+ ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Protocol violation: Fake direction '%s' from connection '%s'", prefix.c_str(), linkID.c_str());
return;
}
diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp
index 82d78124a..0d96167b9 100644
--- a/src/modules/m_spanningtree/uid.cpp
+++ b/src/modules/m_spanningtree/uid.cpp
@@ -71,7 +71,7 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, std::vector<std::st
User* _new = NULL;
try
{
- _new = new RemoteUser(params[0], remoteserver->GetName());
+ _new = new RemoteUser(params[0], remoteserver);
}
catch (...)
{
@@ -132,11 +132,11 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, std::vector<std::st
bool dosend = true;
- if ((Utils->quiet_bursts && remoteserver->bursting) || ServerInstance->SilentULine(_new->server))
+ if ((Utils->quiet_bursts && remoteserver->bursting) || _new->server->IsSilentULine())
dosend = false;
if (dosend)
- ServerInstance->SNO->WriteToSnoMask('C',"Client connecting at %s: %s (%s) [%s]", _new->server.c_str(), _new->GetFullRealHost().c_str(), _new->GetIPString().c_str(), _new->fullname.c_str());
+ ServerInstance->SNO->WriteToSnoMask('C',"Client connecting at %s: %s (%s) [%s]", remoteserver->GetName().c_str(), _new->GetFullRealHost().c_str(), _new->GetIPString().c_str(), _new->fullname.c_str());
FOREACH_MOD(OnPostConnect, (_new));
@@ -162,7 +162,7 @@ CmdResult CommandFName::HandleRemote(RemoteUser* src, std::vector<std::string>&
}
CommandUID::Builder::Builder(User* user)
- : CmdBuilder(user->uuid.substr(0, 3), "UID")
+ : CmdBuilder(TreeServer::Get(user)->GetID(), "UID")
{
push(user->uuid);
push_int(user->age);
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index dbd246ffe..fd51fb6b4 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -93,9 +93,7 @@ TreeServer* SpanningTreeUtilities::BestRouteTo(const std::string &ServerName)
User *u = ServerInstance->FindNick(ServerName);
if (u)
{
- Found = FindServer(u->server);
- if (Found)
- return Found->GetRoute();
+ return TreeServer::Get(u)->GetRoute();
}
return NULL;
@@ -180,9 +178,8 @@ void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeSocketSet
if (exempt_list.find(i->first) == exempt_list.end())
{
- TreeServer* best = this->BestRouteTo(i->first->server);
- if (best)
- list.insert(best->GetSocket());
+ TreeServer* best = TreeServer::Get(i->first);
+ list.insert(best->GetSocket());
}
}
return;
@@ -210,10 +207,16 @@ bool SpanningTreeUtilities::DoOneToOne(const CmdBuilder& params, const std::stri
if (!Route)
return false;
- Route->GetSocket()->WriteLine(params);
+ DoOneToOne(params, Route);
return true;
}
+void SpanningTreeUtilities::DoOneToOne(const CmdBuilder& params, Server* server)
+{
+ TreeServer* ts = static_cast<TreeServer*>(server);
+ ts->GetSocket()->WriteLine(params);
+}
+
void SpanningTreeUtilities::RefreshIPCache()
{
ValidIPs.clear();
@@ -349,6 +352,9 @@ void SpanningTreeUtilities::ReadConfiguration()
AutoconnectBlocks.push_back(A);
}
+ for (server_hash::const_iterator i = serverlist.begin(); i != serverlist.end(); ++i)
+ i->second->CheckULine();
+
RefreshIPCache();
}
diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h
index 164bed1ca..4005f0db9 100644
--- a/src/modules/m_spanningtree/utils.h
+++ b/src/modules/m_spanningtree/utils.h
@@ -129,6 +129,7 @@ class SpanningTreeUtilities : public classbase
/** Send a message from this server to one other local or remote
*/
bool DoOneToOne(const CmdBuilder& params, const std::string& target);
+ void DoOneToOne(const CmdBuilder& params, Server* target);
/** Send a message from this server to all but one other, local or remote
*/
diff --git a/src/modules/m_sslmodes.cpp b/src/modules/m_sslmodes.cpp
index af0fb26f6..6ac07434f 100644
--- a/src/modules/m_sslmodes.cpp
+++ b/src/modules/m_sslmodes.cpp
@@ -52,7 +52,7 @@ class SSLMode : public ModeHandler
for(UserMembCIter i = userlist->begin(); i != userlist->end(); i++)
{
ssl_cert* cert = API->GetCertificate(i->first);
- if (!cert && !ServerInstance->ULine(i->first->server))
+ if (!cert && !i->first->server->IsULine())
{
source->WriteNumeric(ERR_ALLMUSTSSL, "%s :all members of the channel must be connected via SSL", channel->name.c_str());
return MODEACTION_DENY;
diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp
index bb2fcdbc0..b1b454e63 100644
--- a/src/modules/m_svshold.cpp
+++ b/src/modules/m_svshold.cpp
@@ -89,7 +89,7 @@ class CommandSvshold : public Command
/* syntax: svshold nickname time :reason goes here */
/* 'time' is a human-readable timestring, like 2d3h2s. */
- if (!ServerInstance->ULine(user->server))
+ if (!user->server->IsULine())
{
/* don't allow SVSHOLD from non-ulined clients */
return CMD_FAILURE;
diff --git a/src/modules/m_swhois.cpp b/src/modules/m_swhois.cpp
index 3e0ecbc8c..4eb2a9cda 100644
--- a/src/modules/m_swhois.cpp
+++ b/src/modules/m_swhois.cpp
@@ -51,11 +51,11 @@ class CommandSwhois : public Command
if (text)
{
// We already had it set...
- if (!ServerInstance->ULine(user->server))
+ if (!user->server->IsULine())
// Ulines set SWHOISes silently
ServerInstance->SNO->WriteGlobalSno('a', "%s used SWHOIS to set %s's extra whois from '%s' to '%s'", user->nick.c_str(), dest->nick.c_str(), text->c_str(), parameters[1].c_str());
}
- else if (!ServerInstance->ULine(user->server))
+ else if (!user->server->IsULine())
{
// Ulines set SWHOISes silently
ServerInstance->SNO->WriteGlobalSno('a', "%s used SWHOIS to set %s's extra whois to '%s'", user->nick.c_str(), dest->nick.c_str(), parameters[1].c_str());
diff --git a/src/modules/m_topiclock.cpp b/src/modules/m_topiclock.cpp
index 2d539dcab..c7431b4c6 100644
--- a/src/modules/m_topiclock.cpp
+++ b/src/modules/m_topiclock.cpp
@@ -29,7 +29,7 @@ class CommandSVSTOPIC : public Command
CmdResult Handle(const std::vector<std::string> &parameters, User *user)
{
- if (!ServerInstance->ULine(user->server))
+ if (!user->server->IsULine())
{
// Ulines only
return CMD_FAILURE;
diff --git a/src/modules/m_uninvite.cpp b/src/modules/m_uninvite.cpp
index 5e70b4dc7..6eaeb285f 100644
--- a/src/modules/m_uninvite.cpp
+++ b/src/modules/m_uninvite.cpp
@@ -70,11 +70,11 @@ class CommandUninvite : public Command
{
if (!lu->RemoveInvite(c))
{
- user->SendText(":%s 505 %s %s %s :Is not invited to channel %s", user->server.c_str(), user->nick.c_str(), u->nick.c_str(), c->name.c_str(), c->name.c_str());
+ user->SendText(":%s 505 %s %s %s :Is not invited to channel %s", user->server->GetName().c_str(), user->nick.c_str(), u->nick.c_str(), c->name.c_str(), c->name.c_str());
return CMD_FAILURE;
}
- user->SendText(":%s 494 %s %s %s :Uninvited", user->server.c_str(), user->nick.c_str(), c->name.c_str(), u->nick.c_str());
+ user->SendText(":%s 494 %s %s %s :Uninvited", user->server->GetName().c_str(), user->nick.c_str(), c->name.c_str(), u->nick.c_str());
lu->WriteNumeric(493, ":You were uninvited from %s by %s", c->name.c_str(), user->nick.c_str());
std::string msg = "*** " + user->nick + " uninvited " + u->nick + ".";
diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp
index bb0191250..6c7000a77 100644
--- a/src/modules/m_watch.cpp
+++ b/src/modules/m_watch.cpp
@@ -110,7 +110,7 @@ class CommandSVSWatch : public Command
CmdResult Handle (const std::vector<std::string> &parameters, User *user)
{
- if (!ServerInstance->ULine(user->server))
+ if (!user->server->IsULine())
return CMD_FAILURE;
User *u = ServerInstance->FindNick(parameters[0]);
diff --git a/src/users.cpp b/src/users.cpp
index fa4bb7a42..88ae0faf4 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -69,8 +69,8 @@ const char* User::FormatModes(bool showparameters)
return data.c_str();
}
-User::User(const std::string &uid, const std::string& sid, int type)
- : uuid(uid), server(sid), usertype(type)
+User::User(const std::string& uid, Server* srv, int type)
+ : uuid(uid), server(srv), usertype(type)
{
age = ServerInstance->Time();
signon = 0;
@@ -85,7 +85,7 @@ User::User(const std::string &uid, const std::string& sid, int type)
}
LocalUser::LocalUser(int myfd, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* servaddr)
- : User(ServerInstance->UIDGen.GetUID(), ServerInstance->Config->ServerName, USERTYPE_LOCAL), eh(this),
+ : User(ServerInstance->UIDGen.GetUID(), ServerInstance->FakeClient->server, USERTYPE_LOCAL), eh(this),
localuseriter(ServerInstance->Users->local_users.end()),
bytes_in(0), bytes_out(0), cmds_in(0), cmds_out(0), nping(0), CommandFloodPenalty(0),
already_sent(0)
@@ -1291,14 +1291,14 @@ const std::string& FakeUser::GetFullHost()
{
if (!ServerInstance->Config->HideWhoisServer.empty())
return ServerInstance->Config->HideWhoisServer;
- return server;
+ return server->GetName();
}
const std::string& FakeUser::GetFullRealHost()
{
if (!ServerInstance->Config->HideWhoisServer.empty())
return ServerInstance->Config->HideWhoisServer;
- return server;
+ return server->GetName();
}
ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask)