mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
Convert ISUPPORT to use a map instead of a string.
This commit is contained in:
parent
295b3e7ba1
commit
5c29c53f65
@ -432,16 +432,6 @@ class CoreExport ServerConfig
|
||||
*/
|
||||
ClassVector Classes;
|
||||
|
||||
/** The 005 tokens of this server (ISUPPORT)
|
||||
* populated/repopulated upon loading or unloading
|
||||
* modules.
|
||||
*/
|
||||
std::string data005;
|
||||
|
||||
/** isupport strings
|
||||
*/
|
||||
std::vector<std::string> isupport;
|
||||
|
||||
/** STATS characters in this list are available
|
||||
* only to operators.
|
||||
*/
|
||||
@ -515,14 +505,6 @@ class CoreExport ServerConfig
|
||||
*/
|
||||
const std::string& GetSID();
|
||||
|
||||
/** Update the 005 vector
|
||||
*/
|
||||
void Update005();
|
||||
|
||||
/** Send the 005 numerics (ISUPPORT) to a user
|
||||
*/
|
||||
void Send005(User* user);
|
||||
|
||||
/** Read the entire configuration into memory
|
||||
* and initialize this class. All other methods
|
||||
* should be used only by the core.
|
||||
|
@ -267,6 +267,27 @@ class serverstats
|
||||
}
|
||||
};
|
||||
|
||||
/** This class manages the generation and transmission of ISUPPORT. */
|
||||
class CoreExport ISupportManager
|
||||
{
|
||||
private:
|
||||
/** The generated lines which are sent to clients. */
|
||||
std::vector<std::string> Lines;
|
||||
|
||||
public:
|
||||
/** (Re)build the ISUPPORT vector. */
|
||||
void Build();
|
||||
|
||||
/** Returns the std::vector of ISUPPORT lines. */
|
||||
const std::vector<std::string>& GetLines()
|
||||
{
|
||||
return this->Lines;
|
||||
}
|
||||
|
||||
/** Send the 005 numerics (ISUPPORT) to a user. */
|
||||
void SendTo(LocalUser* user);
|
||||
};
|
||||
|
||||
DEFINE_HANDLER2(IsNickHandler, bool, const std::string&, size_t);
|
||||
DEFINE_HANDLER2(GenRandomHandler, void, char*, size_t);
|
||||
DEFINE_HANDLER1(IsIdentHandler, bool, const std::string&);
|
||||
@ -371,10 +392,6 @@ class CoreExport InspIRCd
|
||||
*/
|
||||
User* FindUUID(const char *uid);
|
||||
|
||||
/** Build the ISUPPORT string by triggering all modules On005Numeric events
|
||||
*/
|
||||
void BuildISupport();
|
||||
|
||||
/** Time this ircd was booted
|
||||
*/
|
||||
time_t startup_time;
|
||||
@ -472,6 +489,9 @@ class CoreExport InspIRCd
|
||||
*/
|
||||
LocalStringExt OperQuit;
|
||||
|
||||
/** Manages the generation and transmission of ISUPPORT. */
|
||||
ISupportManager ISupport;
|
||||
|
||||
/** Get the current time
|
||||
* Because this only calls time() once every time around the mainloop,
|
||||
* it is much faster than calling time() directly.
|
||||
@ -828,10 +848,6 @@ class CoreExport InspIRCd
|
||||
*/
|
||||
int Run();
|
||||
|
||||
/** Adds an extban char to the 005 token.
|
||||
*/
|
||||
void AddExtBanChar(char c);
|
||||
|
||||
char* GetReadBuffer()
|
||||
{
|
||||
return this->ReadBuffer;
|
||||
|
@ -911,9 +911,9 @@ class CoreExport Module : public classbase, public usecountbase
|
||||
|
||||
/** Called when a 005 numeric is about to be output.
|
||||
* The module should modify the 005 numeric if needed to indicate its features.
|
||||
* @param output The 005 string to be modified if neccessary.
|
||||
* @param output The 005 map to be modified if neccessary.
|
||||
*/
|
||||
virtual void On005Numeric(std::string &output);
|
||||
virtual void On005Numeric(std::map<std::string, std::string>& tokens);
|
||||
|
||||
/** Called when a client is disconnected by KILL.
|
||||
* If a client is killed by a server, e.g. a nickname collision or protocol error,
|
||||
|
@ -44,7 +44,11 @@ CmdResult CommandVersion::Handle (const std::vector<std::string>&, User *user)
|
||||
{
|
||||
std::string version = ServerInstance->GetVersionString((user->IsOper()));
|
||||
user->WriteNumeric(RPL_VERSION, "%s :%s", user->nick.c_str(), version.c_str());
|
||||
ServerInstance->Config->Send005(user);
|
||||
LocalUser *lu = IS_LOCAL(user);
|
||||
if (lu != NULL)
|
||||
{
|
||||
ServerInstance->ISupport.SendTo(lu);
|
||||
}
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -49,41 +49,6 @@ ServerConfig::ServerConfig()
|
||||
c_ipv6_range = 128;
|
||||
}
|
||||
|
||||
void ServerConfig::Update005()
|
||||
{
|
||||
std::stringstream out(data005);
|
||||
std::vector<std::string> data;
|
||||
std::string token;
|
||||
while (out >> token)
|
||||
data.push_back(token);
|
||||
sort(data.begin(), data.end());
|
||||
|
||||
std::string line5;
|
||||
isupport.clear();
|
||||
for(unsigned int i=0; i < data.size(); i++)
|
||||
{
|
||||
token = data[i];
|
||||
line5 = line5 + token + " ";
|
||||
if (i % 13 == 12)
|
||||
{
|
||||
line5.append(":are supported by this server");
|
||||
isupport.push_back(line5);
|
||||
line5.clear();
|
||||
}
|
||||
}
|
||||
if (!line5.empty())
|
||||
{
|
||||
line5.append(":are supported by this server");
|
||||
isupport.push_back(line5);
|
||||
}
|
||||
}
|
||||
|
||||
void ServerConfig::Send005(User* user)
|
||||
{
|
||||
for (std::vector<std::string>::iterator line = ServerInstance->Config->isupport.begin(); line != ServerInstance->Config->isupport.end(); line++)
|
||||
user->WriteNumeric(RPL_ISUPPORT, "%s %s", user->nick.c_str(), line->c_str());
|
||||
}
|
||||
|
||||
template<typename T, typename V>
|
||||
static void range(T& value, V min, V max, V def, const char* msg)
|
||||
{
|
||||
@ -932,7 +897,7 @@ void ConfigReaderThread::Finish()
|
||||
Config->ApplyDisabledCommands(Config->DisabledCommands);
|
||||
User* user = ServerInstance->FindNick(TheUserUID);
|
||||
FOREACH_MOD(I_OnRehash, OnRehash(user));
|
||||
ServerInstance->BuildISupport();
|
||||
ServerInstance->ISupport.Build();
|
||||
|
||||
ServerInstance->Logs->CloseLogs();
|
||||
ServerInstance->Logs->OpenFileLogs();
|
||||
|
@ -485,26 +485,6 @@ std::string InspIRCd::TimeString(time_t curtime)
|
||||
return std::string(ctime(&curtime),24);
|
||||
}
|
||||
|
||||
// You should only pass a single character to this.
|
||||
void InspIRCd::AddExtBanChar(char c)
|
||||
{
|
||||
std::string &tok = Config->data005;
|
||||
std::string::size_type ebpos = tok.find(" EXTBAN=,");
|
||||
|
||||
if (ebpos == std::string::npos)
|
||||
{
|
||||
tok.append(" EXTBAN=,");
|
||||
tok.push_back(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
ebpos += 9;
|
||||
while (isalpha(tok[ebpos]) && tok[ebpos] < c)
|
||||
ebpos++;
|
||||
tok.insert(ebpos, 1, c);
|
||||
}
|
||||
}
|
||||
|
||||
std::string InspIRCd::GenRandomStr(int length, bool printable)
|
||||
{
|
||||
char* buf = new char[length];
|
||||
|
@ -548,7 +548,7 @@ InspIRCd::InspIRCd(int argc, char** argv) :
|
||||
this->Modules->LoadAll();
|
||||
|
||||
/* Just in case no modules were loaded - fix for bug #101 */
|
||||
this->BuildISupport();
|
||||
this->ISupport.Build();
|
||||
Config->ApplyDisabledCommands(Config->DisabledCommands);
|
||||
|
||||
if (!pl.empty())
|
||||
|
@ -126,7 +126,7 @@ bool ModuleManager::Load(const std::string& filename, bool defer)
|
||||
ServerInstance->Logs->Log("MODULE", DEFAULT, "Hook priority dependency loop detected while loading " + filename);
|
||||
}
|
||||
|
||||
ServerInstance->BuildISupport();
|
||||
ServerInstance->ISupport.Build();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ bool ModuleManager::Load(const std::string& name, bool defer)
|
||||
ServerInstance->Logs->Log("MODULE", DEFAULT, "Hook priority dependency loop detected while loading " + name);
|
||||
}
|
||||
|
||||
ServerInstance->BuildISupport();
|
||||
ServerInstance->ISupport.Build();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ ModResult Module::OnUserPreNotice(User*, void*, int, std::string&, char, CUList&
|
||||
ModResult Module::OnUserPreNick(User*, const std::string&) { return MOD_RES_PASSTHRU; }
|
||||
void Module::OnUserPostNick(User*, const std::string&) { }
|
||||
ModResult Module::OnPreMode(User*, User*, Channel*, const std::vector<std::string>&) { return MOD_RES_PASSTHRU; }
|
||||
void Module::On005Numeric(std::string&) { }
|
||||
void Module::On005Numeric(std::map<std::string, std::string>&) { }
|
||||
ModResult Module::OnKill(User*, User*, const std::string&) { return MOD_RES_PASSTHRU; }
|
||||
void Module::OnLoadModule(Module*) { }
|
||||
void Module::OnUnloadModule(Module*) { }
|
||||
@ -397,7 +397,7 @@ void ModuleManager::DoSafeUnload(Module* mod)
|
||||
|
||||
ServerInstance->Logs->Log("MODULE", DEFAULT,"Module %s unloaded",mod->ModuleSourceFile.c_str());
|
||||
this->ModCount--;
|
||||
ServerInstance->BuildISupport();
|
||||
ServerInstance->ISupport.Build();
|
||||
}
|
||||
|
||||
void ModuleManager::UnloadAll()
|
||||
|
@ -471,12 +471,12 @@ class ModuleSSLGnuTLS : public Module
|
||||
return Version("Provides SSL support for clients", VF_VENDOR);
|
||||
}
|
||||
|
||||
void On005Numeric(std::string &output)
|
||||
void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
if (!sslports.empty())
|
||||
output.append(" SSL=" + sslports);
|
||||
tokens["SSL"] = sslports;
|
||||
if (starttls.enabled)
|
||||
output.append(" STARTTLS");
|
||||
tokens["STARTTLS"];
|
||||
}
|
||||
|
||||
void OnHookIO(StreamSocket* user, ListenSocket* lsb)
|
||||
|
@ -267,10 +267,10 @@ class ModuleSSLOpenSSL : public Module
|
||||
fclose(dhpfile);
|
||||
}
|
||||
|
||||
void On005Numeric(std::string &output)
|
||||
void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
if (!sslports.empty())
|
||||
output.append(" SSL=" + sslports);
|
||||
tokens["SSL"] = sslports;
|
||||
}
|
||||
|
||||
~ModuleSSLOpenSSL()
|
||||
|
@ -43,9 +43,9 @@ class ModuleAllowInvite : public Module
|
||||
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
|
||||
}
|
||||
|
||||
virtual void On005Numeric(std::string &output)
|
||||
virtual void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
ServerInstance->AddExtBanChar('A');
|
||||
tokens["EXTBAN"].push_back('A');
|
||||
}
|
||||
|
||||
virtual ModResult OnUserPreInvite(User* user,User* dest,Channel* channel, time_t timeout)
|
||||
|
@ -63,9 +63,9 @@ class ModuleBanException : public Module
|
||||
ServerInstance->Modules->Attach(list, this, sizeof(list)/sizeof(Implementation));
|
||||
}
|
||||
|
||||
void On005Numeric(std::string &output)
|
||||
void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
output.append(" EXCEPTS=e");
|
||||
tokens["EXCEPTS"] = "e";
|
||||
}
|
||||
|
||||
ModResult OnExtBanCheck(User *user, Channel *chan, char type)
|
||||
|
@ -53,9 +53,9 @@ public:
|
||||
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
|
||||
}
|
||||
|
||||
virtual void On005Numeric(std::string &output)
|
||||
virtual void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
ServerInstance->AddExtBanChar('B');
|
||||
tokens["EXTBAN"].push_back('B');
|
||||
}
|
||||
|
||||
virtual void OnRehash(User* user)
|
||||
|
@ -49,9 +49,9 @@ class ModuleBlockColor : public Module
|
||||
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
|
||||
}
|
||||
|
||||
virtual void On005Numeric(std::string &output)
|
||||
virtual void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
ServerInstance->AddExtBanChar('c');
|
||||
tokens["EXTBAN"].push_back('c');
|
||||
}
|
||||
|
||||
virtual ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
|
||||
|
@ -347,9 +347,9 @@ public:
|
||||
return Version("Implementation of callerid, usermode +g, /accept", VF_COMMON | VF_VENDOR);
|
||||
}
|
||||
|
||||
virtual void On005Numeric(std::string& output)
|
||||
virtual void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
output += " CALLERID=g";
|
||||
tokens["CALLERID"] = "g";
|
||||
}
|
||||
|
||||
ModResult PreText(User* user, User* dest, std::string& text)
|
||||
|
@ -66,9 +66,9 @@ class ModuleBadChannelExtban : public Module
|
||||
return MOD_RES_PASSTHRU;
|
||||
}
|
||||
|
||||
void On005Numeric(std::string &output)
|
||||
void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
ServerInstance->AddExtBanChar('j');
|
||||
tokens["EXTBAN"].push_back('j');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -45,9 +45,9 @@ class ModuleGecosBan : public Module
|
||||
return MOD_RES_PASSTHRU;
|
||||
}
|
||||
|
||||
void On005Numeric(std::string &output)
|
||||
void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
ServerInstance->AddExtBanChar('r');
|
||||
tokens["EXTBAN"].push_back('r');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -119,7 +119,13 @@ class ModuleHttpStats : public Module
|
||||
stime = gmtime(&server_uptime);
|
||||
data << "<uptime><days>" << stime->tm_yday << "</days><hours>" << stime->tm_hour << "</hours><mins>" << stime->tm_min << "</mins><secs>" << stime->tm_sec << "</secs><boot_time_t>" << ServerInstance->startup_time << "</boot_time_t></uptime>";
|
||||
|
||||
data << "<isupport>" << Sanitize(ServerInstance->Config->data005) << "</isupport></general><xlines>";
|
||||
data << "<isupport>";
|
||||
const std::vector<std::string>& isupport = ServerInstance->ISupport.GetLines();
|
||||
for (std::vector<std::string>::const_iterator it = isupport.begin(); it != isupport.end(); it++)
|
||||
{
|
||||
data << Sanitize(*it) << std::endl;
|
||||
}
|
||||
data << "</isupport></general><xlines>";
|
||||
std::vector<std::string> xltypes = ServerInstance->XLines->GetAllTypes();
|
||||
for (std::vector<std::string>::iterator it = xltypes.begin(); it != xltypes.end(); ++it)
|
||||
{
|
||||
|
@ -64,9 +64,9 @@ public:
|
||||
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
|
||||
}
|
||||
|
||||
void On005Numeric(std::string &output)
|
||||
void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
output.append(" INVEX=I");
|
||||
tokens["INVEX"] = "I";
|
||||
}
|
||||
|
||||
ModResult OnCheckInvite(User* user, Channel* chan)
|
||||
|
@ -56,9 +56,9 @@ class ModuleQuietBan : public Module
|
||||
return OnUserPreMessage(user, dest, target_type, text, status, exempt_list);
|
||||
}
|
||||
|
||||
virtual void On005Numeric(std::string &output)
|
||||
virtual void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
ServerInstance->AddExtBanChar('m');
|
||||
tokens["EXTBAN"].push_back('m');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -44,9 +44,9 @@ class ModuleNamesX : public Module
|
||||
return Version("Provides the NAMESX (CAP multi-prefix) capability.",VF_VENDOR);
|
||||
}
|
||||
|
||||
void On005Numeric(std::string &output)
|
||||
void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
output.append(" NAMESX");
|
||||
tokens["NAMESX"];
|
||||
}
|
||||
|
||||
ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *user, bool validated, const std::string &original_line)
|
||||
|
@ -247,11 +247,9 @@ class ModuleNationalChars : public Module
|
||||
OnRehash(NULL);
|
||||
}
|
||||
|
||||
virtual void On005Numeric(std::string &output)
|
||||
virtual void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
std::string tmp(casemapping);
|
||||
tmp.insert(0, "CASEMAPPING=");
|
||||
SearchAndReplace(output, std::string("CASEMAPPING=rfc1459"), tmp);
|
||||
tokens["CASEMAPPING"] = casemapping;
|
||||
}
|
||||
|
||||
virtual void OnRehash(User* user)
|
||||
|
@ -77,9 +77,9 @@ class ModuleNoCTCP : public Module
|
||||
return MOD_RES_PASSTHRU;
|
||||
}
|
||||
|
||||
virtual void On005Numeric(std::string &output)
|
||||
virtual void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
ServerInstance->AddExtBanChar('C');
|
||||
tokens["EXTBAN"].push_back('C');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -47,9 +47,9 @@ class ModuleNoKicks : public Module
|
||||
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
|
||||
}
|
||||
|
||||
void On005Numeric(std::string &output)
|
||||
void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
ServerInstance->AddExtBanChar('Q');
|
||||
tokens["EXTBAN"].push_back('Q');
|
||||
}
|
||||
|
||||
ModResult OnUserPreKick(User* source, Membership* memb, const std::string &reason)
|
||||
|
@ -51,9 +51,9 @@ class ModuleNoNickChange : public Module
|
||||
return Version("Provides support for channel mode +N & extban +b N: which prevents nick changes on channel", VF_VENDOR);
|
||||
}
|
||||
|
||||
virtual void On005Numeric(std::string &output)
|
||||
virtual void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
ServerInstance->AddExtBanChar('N');
|
||||
tokens["EXTBAN"].push_back('N');
|
||||
}
|
||||
|
||||
virtual ModResult OnUserPreNick(User* user, const std::string &newnick)
|
||||
|
@ -46,9 +46,9 @@ class ModuleNoNotice : public Module
|
||||
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
|
||||
}
|
||||
|
||||
virtual void On005Numeric(std::string &output)
|
||||
virtual void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
ServerInstance->AddExtBanChar('T');
|
||||
tokens["EXTBAN"].push_back('T');
|
||||
}
|
||||
|
||||
virtual ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
|
||||
|
@ -44,9 +44,9 @@ class ModulePartMsgBan : public Module
|
||||
partmessage.clear();
|
||||
}
|
||||
|
||||
virtual void On005Numeric(std::string &output)
|
||||
virtual void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
ServerInstance->AddExtBanChar('p');
|
||||
tokens["EXTBAN"].push_back('p');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -70,9 +70,9 @@ class ModuleOperChans : public Module
|
||||
return MOD_RES_PASSTHRU;
|
||||
}
|
||||
|
||||
void On005Numeric(std::string &output)
|
||||
void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
ServerInstance->AddExtBanChar('O');
|
||||
tokens["EXTBAN"].push_back('O');
|
||||
}
|
||||
|
||||
Version GetVersion()
|
||||
|
@ -70,9 +70,9 @@ class ModuleOperLog : public Module
|
||||
return MOD_RES_PASSTHRU;
|
||||
}
|
||||
|
||||
virtual void On005Numeric(std::string &output)
|
||||
virtual void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
output.append(" OPERLOG");
|
||||
tokens["OPERLOG"];
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -52,9 +52,9 @@ class ModuleOverride : public Module
|
||||
RequireKey = tag->getBool("requirekey");
|
||||
}
|
||||
|
||||
void On005Numeric(std::string &output)
|
||||
void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
output.append(" OVERRIDE");
|
||||
tokens["OVERRIDE"];
|
||||
}
|
||||
|
||||
bool CanOverride(User* source, const char* token)
|
||||
|
@ -211,9 +211,9 @@ class ModuleRemove : public Module
|
||||
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
|
||||
}
|
||||
|
||||
virtual void On005Numeric(std::string &output)
|
||||
virtual void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
output.append(" REMOVE");
|
||||
tokens["REMOVE"];
|
||||
}
|
||||
|
||||
virtual void OnRehash(User* user)
|
||||
|
@ -82,9 +82,9 @@ class ModuleSecureList : public Module
|
||||
return MOD_RES_PASSTHRU;
|
||||
}
|
||||
|
||||
virtual void On005Numeric(std::string &output)
|
||||
virtual void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
output.append(" SECURELIST");
|
||||
tokens["SECURELIST"];
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -45,9 +45,9 @@ class ModuleServerBan : public Module
|
||||
return MOD_RES_PASSTHRU;
|
||||
}
|
||||
|
||||
void On005Numeric(std::string &output)
|
||||
void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
ServerInstance->AddExtBanChar('s');
|
||||
tokens["EXTBAN"].push_back('s');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -128,10 +128,10 @@ class ModuleServicesAccount : public Module
|
||||
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
|
||||
}
|
||||
|
||||
void On005Numeric(std::string &t)
|
||||
void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
ServerInstance->AddExtBanChar('R');
|
||||
ServerInstance->AddExtBanChar('U');
|
||||
tokens["EXTBAN"].push_back('R');
|
||||
tokens["EXTBAN"].push_back('U');
|
||||
}
|
||||
|
||||
/* <- :twisted.oscnet.org 330 w00t2 w00t2 w00t :is logged in as */
|
||||
|
@ -320,10 +320,10 @@ class ModuleSilence : public Module
|
||||
maxsilence = 32;
|
||||
}
|
||||
|
||||
void On005Numeric(std::string &output)
|
||||
void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
// we don't really have a limit...
|
||||
output = output + " ESILENCE SILENCE=" + ConvToStr(maxsilence);
|
||||
tokens["ESILENCE"];
|
||||
tokens["SILENCE"] = ConvToStr(maxsilence);
|
||||
}
|
||||
|
||||
void OnBuildExemptList(MessageType message_type, Channel* chan, User* sender, char status, CUList &exempt_list, const std::string &text)
|
||||
|
@ -360,12 +360,13 @@ ModResult ModuleSpanningTree::HandleVersion(const std::vector<std::string>& para
|
||||
TreeServer* found = Utils->FindServerMask(parameters[0]);
|
||||
if (found)
|
||||
{
|
||||
std::string Version = found->GetVersion();
|
||||
user->WriteNumeric(351, "%s :%s",user->nick.c_str(),Version.c_str());
|
||||
if (found == Utils->TreeRoot)
|
||||
{
|
||||
ServerInstance->Config->Send005(user);
|
||||
// Pass to default VERSION handler.
|
||||
return MOD_RES_PASSTHRU;
|
||||
}
|
||||
std::string Version = found->GetVersion();
|
||||
user->WriteNumeric(351, "%s :%s",user->nick.c_str(),Version.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -64,8 +64,7 @@ ModResult ModuleSpanningTree::OnPreCommand(std::string &command, std::vector<std
|
||||
}
|
||||
else if ((command == "VERSION") && (parameters.size() > 0))
|
||||
{
|
||||
this->HandleVersion(parameters,user);
|
||||
return MOD_RES_DENY;
|
||||
return this->HandleVersion(parameters,user);
|
||||
}
|
||||
return MOD_RES_PASSTHRU;
|
||||
}
|
||||
|
@ -126,9 +126,9 @@ class ModuleSSLModes : public Module
|
||||
return MOD_RES_PASSTHRU;
|
||||
}
|
||||
|
||||
void On005Numeric(std::string &output)
|
||||
void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
ServerInstance->AddExtBanChar('z');
|
||||
tokens["EXTBAN"].push_back('z');
|
||||
}
|
||||
|
||||
Version GetVersion()
|
||||
|
@ -58,9 +58,9 @@ class ModuleStripColor : public Module
|
||||
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
|
||||
}
|
||||
|
||||
virtual void On005Numeric(std::string &output)
|
||||
virtual void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
ServerInstance->AddExtBanChar('S');
|
||||
tokens["EXTBAN"].push_back('S');
|
||||
}
|
||||
|
||||
virtual ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
|
||||
|
@ -44,9 +44,9 @@ class ModuleUHNames : public Module
|
||||
return Version("Provides the UHNAMES facility.",VF_VENDOR);
|
||||
}
|
||||
|
||||
void On005Numeric(std::string &output)
|
||||
void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
output.append(" UHNAMES");
|
||||
tokens["UHNAMES"];
|
||||
}
|
||||
|
||||
ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *user, bool validated, const std::string &original_line)
|
||||
|
@ -77,9 +77,9 @@ class ModuleUserIP : public Module
|
||||
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
|
||||
}
|
||||
|
||||
virtual void On005Numeric(std::string &output)
|
||||
virtual void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
output = output + " USERIP";
|
||||
tokens["USERIP"];
|
||||
}
|
||||
|
||||
virtual Version GetVersion()
|
||||
|
@ -527,10 +527,9 @@ class Modulewatch : public Module
|
||||
}
|
||||
}
|
||||
|
||||
virtual void On005Numeric(std::string &output)
|
||||
virtual void On005Numeric(std::map<std::string, std::string>& tokens)
|
||||
{
|
||||
// we don't really have a limit...
|
||||
output = output + " WATCH=" + ConvToStr(maxwatch);
|
||||
tokens["WATCH"] = ConvToStr(maxwatch);
|
||||
}
|
||||
|
||||
virtual ~Modulewatch()
|
||||
|
@ -83,18 +83,6 @@ const char InspIRCd::LogHeader[] =
|
||||
"Log started for " VERSION " (" REVISION ", " MODULE_INIT_STR ")"
|
||||
" - compiled on " SYSTEM;
|
||||
|
||||
void InspIRCd::BuildISupport()
|
||||
{
|
||||
// the neatest way to construct the initial 005 numeric, considering the number of configure constants to go in it...
|
||||
std::stringstream v;
|
||||
v << "WALLCHOPS WALLVOICES MODES=" << Config->Limits.MaxModes << " CHANTYPES=# PREFIX=" << this->Modes->BuildPrefixes() << " MAP MAXCHANNELS=" << Config->MaxChans << " MAXBANS=60 VBANLIST NICKLEN=" << Config->Limits.NickMax;
|
||||
v << " CASEMAPPING=rfc1459 STATUSMSG=" << Modes->BuildPrefixes(false) << " CHARSET=ascii TOPICLEN=" << Config->Limits.MaxTopic << " KICKLEN=" << Config->Limits.MaxKick << " MAXTARGETS=" << Config->MaxTargets;
|
||||
v << " AWAYLEN=" << Config->Limits.MaxAway << " CHANMODES=" << this->Modes->GiveModeList(MASK_CHANNEL) << " FNC NETWORK=" << Config->Network << " MAXPARA=32 ELIST=MU" << " CHANNELLEN=" << Config->Limits.ChanMax;
|
||||
Config->data005 = v.str();
|
||||
FOREACH_MOD(I_On005Numeric,On005Numeric(Config->data005));
|
||||
Config->Update005();
|
||||
}
|
||||
|
||||
void InspIRCd::IncrementUID(int pos)
|
||||
{
|
||||
/*
|
||||
@ -184,5 +172,67 @@ std::string InspIRCd::GetUID()
|
||||
return "";
|
||||
}
|
||||
|
||||
void ISupportManager::Build()
|
||||
{
|
||||
/**
|
||||
* This is currently the neatest way we can build the initial ISUPPORT map. In
|
||||
* the future we can use an initializer list here.
|
||||
*/
|
||||
std::map<std::string, std::string> tokens;
|
||||
std::vector<std::string> lines;
|
||||
int token_count = 0;
|
||||
std::string line;
|
||||
|
||||
tokens["AWAYLEN"] = ConvToStr(ServerInstance->Config->Limits.MaxAway);
|
||||
tokens["CASEMAPPING"] = "rfc1459";
|
||||
tokens["CHANMODES"] = ConvToStr(ServerInstance->Modes->GiveModeList(MASK_CHANNEL));
|
||||
tokens["CHANNELLEN"] = ConvToStr(ServerInstance->Config->Limits.ChanMax);
|
||||
tokens["CHANTYPES"] = "#";
|
||||
tokens["CHARSET"] = "ascii";
|
||||
tokens["ELIST"] = "MU";
|
||||
tokens["KICKLEN"] = ConvToStr(ServerInstance->Config->Limits.MaxKick);
|
||||
tokens["MAXBANS"] = "64"; // TODO: make this a config setting.
|
||||
tokens["MAXCHANNELS"] = ConvToStr(ServerInstance->Config->MaxChans);
|
||||
tokens["MAXPARA"] = ConvToStr(MAXPARAMETERS);
|
||||
tokens["MAXTARGETS"] = ConvToStr(ServerInstance->Config->MaxTargets);
|
||||
tokens["MODES"] = ConvToStr(ServerInstance->Config->Limits.MaxModes);
|
||||
tokens["NETWORK"] = ConvToStr(ServerInstance->Config->Network);
|
||||
tokens["NICKLEN"] = ConvToStr(ServerInstance->Config->Limits.NickMax);
|
||||
tokens["PREFIX"] = ServerInstance->Modes->BuildPrefixes();
|
||||
tokens["STATUSMSG"] = ServerInstance->Modes->BuildPrefixes(false);
|
||||
tokens["TOPICLEN"] = ConvToStr(ServerInstance->Config->Limits.MaxTopic);
|
||||
|
||||
tokens["FNC"] = tokens["MAP"] = tokens["VBANLIST"] =
|
||||
tokens["WALLCHOPS"] = tokens["WALLVOICES"];
|
||||
|
||||
FOREACH_MOD(I_On005Numeric, On005Numeric(tokens));
|
||||
|
||||
// EXTBAN is a special case as we need to sort it and prepend a comma.
|
||||
std::map<std::string, std::string>::iterator extban = tokens.find("EXTBAN");
|
||||
if (extban != tokens.end())
|
||||
{
|
||||
sort(extban->second.begin(), extban->second.end());
|
||||
extban->second.insert(0, ",");
|
||||
}
|
||||
|
||||
for (std::map<std::string, std::string>::iterator it = tokens.begin(); it != tokens.end(); it++)
|
||||
{
|
||||
line.append(it->first + (it->second.empty() ? " " : "=" + it->second + " "));
|
||||
token_count++;
|
||||
|
||||
if (token_count % 13 == 12 || it == --tokens.end())
|
||||
{
|
||||
line.append(":are supported by this server");
|
||||
lines.push_back(line);
|
||||
line.clear();
|
||||
}
|
||||
}
|
||||
|
||||
this->Lines = lines;
|
||||
}
|
||||
|
||||
void ISupportManager::SendTo(LocalUser* user)
|
||||
{
|
||||
for (std::vector<std::string>::iterator line = this->Lines.begin(); line != this->Lines.end(); line++)
|
||||
user->WriteNumeric(RPL_ISUPPORT, "%s %s", user->nick.c_str(), line->c_str());
|
||||
}
|
||||
|
@ -771,7 +771,7 @@ void LocalUser::FullConnect()
|
||||
std::string pmlist = ServerInstance->Modes->ParaModeList();
|
||||
this->WriteNumeric(RPL_SERVERVERSION, "%s %s %s %s %s %s", this->nick.c_str(), ServerInstance->Config->ServerName.c_str(), BRANCH, umlist.c_str(), cmlist.c_str(), pmlist.c_str());
|
||||
|
||||
ServerInstance->Config->Send005(this);
|
||||
ServerInstance->ISupport.SendTo(this);
|
||||
this->WriteNumeric(RPL_YOURUUID, "%s %s :your unique ID", this->nick.c_str(), this->uuid.c_str());
|
||||
|
||||
/* Now registered */
|
||||
|
Loading…
x
Reference in New Issue
Block a user