SID generation should(?) now work again as well. NOTE: no error checking on SID from config yet, we may wish to do that sometime..

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8620 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
w00t 2008-01-03 13:17:51 +00:00
parent ce5bee9a3e
commit edb126e57f
2 changed files with 13 additions and 16 deletions

View File

@ -478,13 +478,7 @@ bool ValidateInvite(ServerConfig* conf, const char*, const char*, ValueItem &dat
bool ValidateSID(ServerConfig* conf, const char*, const char*, 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);
}
// std::string sid = data.GetString();
return true;
}
@ -801,7 +795,7 @@ void ServerConfig::Read(bool bail, User* user, int pass)
{"server", "name", "", new ValueContainerChar (this->ServerName), DT_HOSTNAME, ValidateServerName},
{"server", "description", "Configure Me", new ValueContainerChar (this->ServerDesc), DT_CHARPTR, NoValidation},
{"server", "network", "Network", new ValueContainerChar (this->Network), DT_NOSPACES, NoValidation},
{"server", "id", "0", new ValueContainerInt (&this->sid), DT_NOSPACES, ValidateSID},
{"server", "id", "", new ValueContainerChar (this->sid), DT_CHARPTR, 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},
@ -2095,11 +2089,7 @@ InspIRCd* ServerConfig::GetInstance()
std::string ServerConfig::GetSID()
{
std::string OurSID;
OurSID += (char)((sid / 100) + 48);
OurSID += (char)((sid / 10) % 10 + 48);
OurSID += (char)(sid % 10 + 48);
return OurSID;
return sid;
}
ValueItem::ValueItem(int value)

View File

@ -483,12 +483,15 @@ InspIRCd::InspIRCd(int argc, char** argv)
* -- w00t
*/
/* Generate SID */
if (Config->sid)
printf("\nSID is %s\n\n", Config->sid);
if (*Config->sid)
{
// already defined, don't bother
}
printf("\nAlready defined!\n\n");
}
else
{
printf("\nGenerating..\n\n");
// Generate one
size_t sid = 0;
@ -498,10 +501,14 @@ InspIRCd::InspIRCd(int argc, char** argv)
sid = 5 * sid + *y;
sid = sid % 999;
printf("\nGenerated %u\n\n", sid);
printf("\n0 %c\n\n", (sid / 100 + 48));
printf("\n1 %c\n\n", (((sid / 10) % 10) + 48));
printf("\n2 %c\n\n", (sid % 10 + 48));
Config->sid[0] = (char)(sid / 100 + 48);
Config->sid[1] = (char)(((sid / 10) % 10) + 48);
Config->sid[2] = (char)(sid % 10 + 48);
//Config->sid = sprintf("%u", sid);
}
this->InitialiseUID();