summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-05-13 05:27:39 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-05-13 05:27:39 +0000
commit6dd331262aa8f989657891e27b8891ee6a00016c (patch)
treea414c7cacbdc046ee6529c63f000c26d973fe35c
parentd4ee4c5aa4312cde76fe50e34ef8ca1685d521f0 (diff)
Create subclass of User for FakeClient, to allow for use as command source
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11375 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/fakeuser.h31
-rw-r--r--include/inspircd.h3
-rw-r--r--include/users.h4
-rw-r--r--src/inspircd.cpp3
-rw-r--r--src/users.cpp4
5 files changed, 38 insertions, 7 deletions
diff --git a/include/fakeuser.h b/include/fakeuser.h
new file mode 100644
index 000000000..5d62b7060
--- /dev/null
+++ b/include/fakeuser.h
@@ -0,0 +1,31 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
+ *
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#ifndef __FAKEUSER_H__
+#define __FAKEUSER_H__
+
+#include "users.h"
+
+class CoreExport FakeUser : public User
+{
+ public:
+ FakeUser(InspIRCd* Instance) : User(Instance, "!")
+ {
+ SetFd(FD_MAGIC_NUMBER);
+ }
+
+ virtual const std::string GetFullHost() { return server; }
+ virtual const std::string GetFullRealHost() { return server; }
+};
+
+#endif
diff --git a/include/inspircd.h b/include/inspircd.h
index 0511058a4..6b13a5ed8 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -97,6 +97,7 @@ typedef std::multimap< std::string, KeyValList > ConfigDataHash;
#include "inspstring.h"
#include "protocol.h"
#include "threadengine.h"
+#include "fakeuser.h"
#ifndef PATH_MAX
#warning Potentially broken system, PATH_MAX undefined
@@ -407,7 +408,7 @@ class CoreExport InspIRCd : public classbase
* hash and set its descriptor to FD_MAGIC_NUMBER so the data
* falls into the abyss :p
*/
- User* FakeClient;
+ FakeUser* FakeClient;
/** Returns the next available UID for this server.
*/
diff --git a/include/users.h b/include/users.h
index 4871ca411..207d782b0 100644
--- a/include/users.h
+++ b/include/users.h
@@ -679,7 +679,7 @@ class CoreExport User : public EventHandler
* on the server, in nick!ident&at;host form.
* @return The full masked host of the user
*/
- virtual const std::string& GetFullHost();
+ virtual const std::string GetFullHost();
/** Returns the full real host of the user
* This member function returns the hostname of the user as seen by other users
@@ -687,7 +687,7 @@ class CoreExport User : public EventHandler
* e.g. through a module, then this method will ignore it and return the true hostname.
* @return The full real host of the user
*/
- virtual const std::string& GetFullRealHost();
+ virtual const std::string GetFullRealHost();
/** This clears any cached results that are used for GetFullRealHost() etc.
* The results of these calls are cached as generating them can be generally expensive.
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index f3662cb31..b8eced5f4 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -609,8 +609,7 @@ InspIRCd::InspIRCd(int argc, char** argv)
}
/* set up fake client again this time with the correct uid */
- this->FakeClient = new User(this, "#INVALID");
- this->FakeClient->SetFd(FD_MAGIC_NUMBER);
+ this->FakeClient = new FakeUser(this);
// Get XLine to do it's thing.
this->XLines->CheckELines();
diff --git a/src/users.cpp b/src/users.cpp
index 15e1ab72b..9574dd415 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -330,7 +330,7 @@ void User::CloseSocket()
}
}
-const std::string& User::GetFullHost()
+const std::string User::GetFullHost()
{
if (!this->cached_fullhost.empty())
return this->cached_fullhost;
@@ -379,7 +379,7 @@ int User::ReadData(void* buffer, size_t size)
}
-const std::string& User::GetFullRealHost()
+const std::string User::GetFullRealHost()
{
if (!this->cached_fullrealhost.empty())
return this->cached_fullrealhost;