From 07e45de53335528d15ded120850d8e1b53cfc8bc Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 27 Aug 2007 00:29:56 +0000 Subject: Automatic SID generation based on code similar to the STL hash function and using server name and server gecos git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7849 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspircd.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/inspircd.cpp') diff --git a/src/inspircd.cpp b/src/inspircd.cpp index e7d43edff..1d9aca35f 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -538,9 +538,19 @@ InspIRCd::InspIRCd(int argc, char** argv) */ int i; - for(i = 0; i < 3; i++) - current_uid[i] = '0'; + /* Generate SID */ + size_t sid = 0; + for (const char* x = Config->ServerName; *x; ++x) + sid = 5 * sid + *x; + for (const char* y = Config->ServerDesc; *y; ++y) + sid = 5 * sid + *y; + sid = sid % 999; + current_uid[0] = sid / 100 + 48; + current_uid[1] = sid / 10 + 48; + current_uid[2] = sid % 10 + 48; + + /* Initialise UID */ for(i = 3; i < UUID_LENGTH - 1; i++) current_uid[i] = 'A'; -- cgit v1.2.3