summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/inspircd.h18
-rw-r--r--include/testsuite.h1
-rw-r--r--include/uid.h32
3 files changed, 34 insertions, 17 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index b0fadb336..929674eb3 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -294,8 +294,6 @@ DEFINE_HANDLER2(IsChannelHandler, bool, const std::string&, size_t);
DEFINE_HANDLER1(RehashHandler, void, const std::string&);
DEFINE_HANDLER3(OnCheckExemptionHandler, ModResult, User*, Channel*, const std::string&);
-class TestSuite;
-
/** The main class of the irc server.
* This class contains instances of all the other classes in this software.
* Amongst other things, it contains a ModeParser, a DNS object, a CommandParser
@@ -305,10 +303,6 @@ class TestSuite;
class CoreExport InspIRCd
{
private:
- /** Holds the current UID. Used to generate the next one.
- */
- char current_uid[UUID_LENGTH];
-
/** Set up the signal handlers
*/
void SetSignals();
@@ -323,10 +317,6 @@ class CoreExport InspIRCd
*/
void DoSocketTimeouts(time_t TIME);
- /** Increments the current UID by one.
- */
- void IncrementUID(int pos);
-
/** Perform background user events such as PING checks
*/
void DoBackgroundUserStuff();
@@ -348,6 +338,8 @@ class CoreExport InspIRCd
public:
+ UIDGenerator UIDGen;
+
/** Global cull list, will be processed on next iteration
*/
CullList GlobalCulls;
@@ -373,10 +365,6 @@ class CoreExport InspIRCd
*/
FakeUser* FakeClient;
- /** Returns the next available UID for this server.
- */
- std::string GetUID();
-
static const char LogHeader[];
/** Find a user in the UUID hash
@@ -828,8 +816,6 @@ class CoreExport InspIRCd
{
return this->ReadBuffer;
}
-
- friend class TestSuite;
};
ENTRYPOINT;
diff --git a/include/testsuite.h b/include/testsuite.h
index 43064b063..7f0b2236a 100644
--- a/include/testsuite.h
+++ b/include/testsuite.h
@@ -20,7 +20,6 @@
class TestSuite
{
- bool RealGenerateUIDTests();
public:
TestSuite();
~TestSuite();
diff --git a/include/uid.h b/include/uid.h
index 3783e7ada..8be003628 100644
--- a/include/uid.h
+++ b/include/uid.h
@@ -25,3 +25,35 @@
*/
#define UUID_LENGTH 10
+class TestSuite;
+
+class CoreExport UIDGenerator
+{
+ friend class TestSuite;
+
+ /** Holds the current UID. Used to generate the next one.
+ */
+ char current_uid[UUID_LENGTH];
+
+ /** Increments the current UID by one.
+ */
+ void IncrementUID(unsigned int pos);
+
+ public:
+ /** Initializes this UID generator with the given SID
+ * @param sid SID that conforms to InspIRCd::IsSID()
+ */
+ void init(const std::string& sid);
+
+ /** Returns the next available UID for this server.
+ */
+ std::string GetUID();
+
+ /** Generates a pseudorandom SID based on a servername and a description
+ * Guaranteed to return the same if invoked with the same parameters
+ * @param servername The server name to use as seed
+ * @param serverdesc The server description to use as seed
+ * @return A valid SID
+ */
+ static std::string GenerateSID(const std::string& servername, const std::string& serverdesc);
+};