X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_customtitle.cpp;h=5d088e9a6f8ca93abbf8ba194b15b94ae1534c06;hb=623ba6ae49f8e1e0958f921fa178af8a95797c1c;hp=efe4b32470b4ee4ca47d98840bf2ce4d3a0e9f26;hpb=d31e6e1f3e9a52e23134525b26912f0ebd4f27c0;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_customtitle.cpp b/src/modules/m_customtitle.cpp index efe4b3247..5d088e9a6 100644 --- a/src/modules/m_customtitle.cpp +++ b/src/modules/m_customtitle.cpp @@ -35,27 +35,10 @@ class CommandTitle : public Command syntax = " "; } - bool OneOfMatches(const char* host, const char* ip, const char* hostlist) - { - std::stringstream hl(hostlist); - std::string xhost; - while (hl >> xhost) - { - if (InspIRCd::Match(host, xhost, ascii_case_insensitive_map) || InspIRCd::MatchCIDR(ip, xhost, ascii_case_insensitive_map)) - { - return true; - } - } - return false; - } - CmdResult Handle(const std::vector ¶meters, User* user) { - char TheHost[MAXBUF]; - char TheIP[MAXBUF]; - - snprintf(TheHost,MAXBUF,"%s@%s",user->ident.c_str(), user->host.c_str()); - snprintf(TheIP, MAXBUF,"%s@%s",user->ident.c_str(), user->GetIPString()); + const std::string userHost = user->ident + "@" + user->host; + const std::string userIP = user->ident + "@" + user->GetIPString(); ConfigTagList tags = ServerInstance->Config->ConfTags("title"); for (ConfigIter i = tags.first; i != tags.second; ++i) @@ -67,7 +50,8 @@ class CommandTitle : public Command std::string title = i->second->getString("title"); std::string vhost = i->second->getString("vhost"); - if (Name == parameters[0] && !ServerInstance->PassCompare(user, pass, parameters[1], hash) && OneOfMatches(TheHost,TheIP,host.c_str()) && !title.empty()) + if (Name == parameters[0] && !ServerInstance->PassCompare(user, pass, parameters[1], hash) && + InspIRCd::MatchMask(host, userHost, userIP) && !title.empty()) { ctitle.set(user, title); @@ -76,13 +60,13 @@ class CommandTitle : public Command if (!vhost.empty()) user->ChangeDisplayedHost(vhost.c_str()); - user->WriteServ("NOTICE %s :Custom title set to '%s'",user->nick.c_str(), title.c_str()); + user->WriteNotice("Custom title set to '" + title + "'"); return CMD_SUCCESS; } } - user->WriteServ("NOTICE %s :Invalid title credentials",user->nick.c_str()); + user->WriteNotice("Invalid title credentials"); return CMD_SUCCESS; } @@ -95,13 +79,17 @@ class ModuleCustomTitle : public Module public: ModuleCustomTitle() : cmd(this) { - ServerInstance->AddCommand(&cmd); - ServerInstance->Extensions.Register(&cmd.ctitle); + } + + void init() CXX11_OVERRIDE + { + ServerInstance->Modules->AddService(cmd); + ServerInstance->Modules->AddService(cmd.ctitle); ServerInstance->Modules->Attach(I_OnWhoisLine, this); } // :kenny.chatspike.net 320 Brain Azhrarn :is getting paid to play games. - ModResult OnWhoisLine(User* user, User* dest, int &numeric, std::string &text) + ModResult OnWhoisLine(User* user, User* dest, int &numeric, std::string &text) CXX11_OVERRIDE { /* We use this and not OnWhois because this triggers for remote, too */ if (numeric == 312) @@ -117,11 +105,7 @@ class ModuleCustomTitle : public Module return MOD_RES_PASSTHRU; } - ~ModuleCustomTitle() - { - } - - Version GetVersion() + Version GetVersion() CXX11_OVERRIDE { return Version("Custom Title for users", VF_OPTCOMMON | VF_VENDOR); }