summaryrefslogtreecommitdiff
path: root/include
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 /include
parent2f181fef775da4a686a892c06af843dddfb7950a (diff)
Introduce Server class
- Replaces std::string server in User - Replaces InspIRCd::ULine() and SilentULine()
Diffstat (limited to 'include')
-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
6 files changed, 81 insertions, 19 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();