]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add <server:id> - this is optional, as stated in the example conf,
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 27 Aug 2007 19:56:38 +0000 (19:56 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 27 Aug 2007 19:56:38 +0000 (19:56 +0000)
and should only be set if you are getting collisions. The comment also points out that ids where either of the last two letters are numeric are reserved for services use (e.g. 0ZZ or 5CQ)

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7917 e03df62e-2008-0410-955e-edbf42e46eb7

docs/inspircd.conf.example
include/configreader.h
src/configreader.cpp
src/inspircd.cpp
src/server.cpp

index e1b33565b99a732479f9301c4380c559f3a74d4f..edd3e5598786546a6be9f80288fcac08823282a9 100644 (file)
 #     <server name="server.name"                                      #
 #      description="Server Description"                               #
 #      networkemail="Email address shown on g/k/z/q lines"            #
+#      id="serverid"                                                  #
 #      network="MyNetwork">                                           #
 #                                                                     #
+#  The server ID is optional, and if omitted or set to 0, is auto-    #
+#  matically calculated from the server name and description. This is #
+#  similar in behaviour to the server id on ircu and charybdis ircds. #
+#  You should only need to set this manually if there is a collision  #
+#  between two server IDs on the network. The server ID must be       #
+#  between 1 and 999, if it is not, it will be wrapped to this range. #
+#  There is a range of server IDs which are suffixed by two letters   #
+#  rather than two numbers, e.g. 1AA, 2FF, 3ZZ, which are reserved    #
+#  for use by non-inspircd servers such as services and stats servers.#
+#                                                                     #
 
 <server name="penguin.omega.org.za"
         description="Waddle World"
+       id="0"
        network="Omega">
 
 
index 4a9720862d7cd38321e5620ec90695416fc038c8..b1eb9b263f21d9fd1faa93e5630145ab954fc871 100644 (file)
@@ -603,6 +603,13 @@ class CoreExport ServerConfig : public Extensible
         */
        unsigned int OperMaxChans;
 
+       /** TS6-like server ID.
+        * NOTE: 000...999 are usable for InspIRCd servers. This
+        * makes code simpler. 0AA, 1BB etc with letters are reserved
+        * for services use.
+        */
+       int sid;
+
        /** Construct a new ServerConfig
         */
        ServerConfig(InspIRCd* Instance);
index ec15db3a1d1fa3ab35c68290eb7f2ae63215a21a..c5f37a1e4d2e073ca31f32ef6e310db0b85e2447 100644 (file)
@@ -367,6 +367,18 @@ bool ValidateInvite(ServerConfig* conf, const char* tag, const char* value, Valu
        return true;
 }
 
+bool ValidateSID(ServerConfig* conf, const char* tag, const char* value, ValueItem &data)
+{
+       int sid = data.GetInteger();
+       if ((sid > 999) || (sid < 0))
+       {
+               sid = sid % 1000;
+               data.Set(sid);
+               conf->GetInstance()->Log(DEFAULT,"WARNING: Server ID is less than 0 or greater than 999. Set to %d", sid);
+       }
+       return true;
+}
+
 bool ValidateWhoWas(ServerConfig* conf, const char* tag, const char* value, ValueItem &data)
 {
        conf->WhoWasMaxKeep = conf->GetInstance()->Duration(data.GetString());
@@ -634,6 +646,7 @@ void ServerConfig::Read(bool bail, userrec* user)
                {"server",      "name",         "",                     new ValueContainerChar (this->ServerName),              DT_CHARPTR, ValidateServerName},
                {"server",      "description",  "Configure Me",         new ValueContainerChar (this->ServerDesc),              DT_CHARPTR, NoValidation},
                {"server",      "network",      "Network",              new ValueContainerChar (this->Network),                 DT_CHARPTR, NoValidation},
+               {"server",      "id",           "0",                    new ValueContainerInt  (&this->sid),                    DT_INTEGER, ValidateSID},
                {"admin",       "name",         "",                     new ValueContainerChar (this->AdminName),               DT_CHARPTR, NoValidation},
                {"admin",       "email",        "Mis@configu.red",      new ValueContainerChar (this->AdminEmail),              DT_CHARPTR, NoValidation},
                {"admin",       "nick",         "Misconfigured",        new ValueContainerChar (this->AdminNick),               DT_CHARPTR, NoValidation},
index 9543ef8566996689bc77b3d5ab83ccc24a957df9..1618266c04b239f2f193bcbe3d5ae6eccd9ea54c 100644 (file)
@@ -544,11 +544,20 @@ InspIRCd::InspIRCd(int argc, char** argv)
 
        /* 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;
+       if (Config->sid)
+       {
+               sid = Config->sid;
+       }
+       else
+       {
+               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;
+
+               Config->sid = sid;
+       }
        current_uid[0] = sid / 100 + 48;
        current_uid[1] = ((sid / 10) % 10) + 48;
        current_uid[2] = sid % 10 + 48;
index 041b9f5ddd839ddf7901deb3ca86b9f13ba2f2e7..ea2ec49284b0d8be96315a87b9754b98898a6e54 100644 (file)
@@ -69,15 +69,13 @@ void InspIRCd::RehashServer()
 std::string InspIRCd::GetVersionString()
 {
        char versiondata[MAXBUF];
-       char dnsengine[] = "singlethread-object";
-
        if (*Config->CustomVersion)
        {
                snprintf(versiondata,MAXBUF,"%s %s :%s",VERSION,Config->ServerName,Config->CustomVersion);
        }
        else
        {
-               snprintf(versiondata,MAXBUF,"%s %s :%s [FLAGS=%s,%s,%s]",VERSION,Config->ServerName,SYSTEM,REVISION,SE->GetName().c_str(),dnsengine);
+               snprintf(versiondata,MAXBUF,"%s %s :%s [FLAGS=%s,%s,%d]",VERSION,Config->ServerName,SYSTEM,REVISION,SE->GetName().c_str(),Config->sid);
        }
        return versiondata;
 }