diff options
-rw-r--r-- | data/modules.example.conf | 2 | ||||
-rw-r--r-- | modules/extra/hs_request.cpp | 57 |
2 files changed, 33 insertions, 26 deletions
diff --git a/data/modules.example.conf b/data/modules.example.conf index b26f12e66..4a492bfda 100644 --- a/data/modules.example.conf +++ b/data/modules.example.conf @@ -115,7 +115,7 @@ db_plain */ module { name = "hs_request" } command { service = "HostServ"; name = "REQUEST"; command = "hostserv/request"; } -command { service = "HostServ"; name = "ACTIVATE"; command = "hostserv/active"; } +command { service = "HostServ"; name = "ACTIVATE"; command = "hostserv/activate"; } command { service = "HostServ"; name = "REJECT"; command = "hostserv/reject"; } command { service = "HostServ"; name = "WAITING"; command = "hostserv/waiting"; } hs_request diff --git a/modules/extra/hs_request.cpp b/modules/extra/hs_request.cpp index 74fe04dab..0070a481c 100644 --- a/modules/extra/hs_request.cpp +++ b/modules/extra/hs_request.cpp @@ -55,44 +55,51 @@ class CommandHSRequest : public Command User *u = source.u; Anope::string rawhostmask = params[0]; - Anope::string hostmask; + + Anope::string user, host; + size_t a = rawhostmask.find('@'); - Anope::string vIdent = myStrGetToken(rawhostmask, '@', 0); /* Get the first substring, @ as delimiter */ - if (!vIdent.empty()) + if (a == Anope::string::npos) + host = rawhostmask; + else { - rawhostmask = myStrGetTokenRemainder(rawhostmask, '@', 1); /* get the remaining string */ - if (rawhostmask.empty()) - { - this->SendSyntax(source); - return; - } - if (vIdent.length() > Config->UserLen) + user = rawhostmask.substr(0, a); + host = rawhostmask.substr(a + 1); + } + + if (host.empty()) + { + this->OnSyntaxError(source, ""); + return; + } + + if (!user.empty()) + { + if (user.length() > Config->UserLen) { source.Reply(HOST_SET_IDENTTOOLONG, Config->UserLen); return; } - else - for (Anope::string::iterator s = vIdent.begin(), s_end = vIdent.end(); s != s_end; ++s) - if (!isvalidchar(*s)) - { - source.Reply(HOST_SET_IDENT_ERROR); - return; - } - if (!ircd->vident) + else if (!ircd->vident) { source.Reply(HOST_NO_VIDENT); return; } + for (Anope::string::iterator s = user.begin(), s_end = user.end(); s != s_end; ++s) + if (!isvalidchar(*s)) + { + source.Reply(HOST_SET_IDENT_ERROR); + return; + } } - if (rawhostmask.length() < Config->HostLen) - hostmask = rawhostmask; - else + + if (host.length() > Config->HostLen) { source.Reply(HOST_SET_TOOLONG, Config->HostLen); return; } - if (!isValidHost(hostmask, 3)) + if (!isValidHost(host, 3)) { source.Reply(HOST_SET_ERROR); return; @@ -104,11 +111,11 @@ class CommandHSRequest : public Command u->lastmemosend = Anope::CurTime; return; } - my_add_host_request(u->nick, vIdent, hostmask, u->nick, Anope::CurTime); + my_add_host_request(u->nick, user, host, u->nick, Anope::CurTime); source.Reply(_("Your vHost has been requested")); - req_send_memos(source, vIdent, hostmask); - Log(LOG_COMMAND, u, this, NULL) << "to request new vhost " << (!vIdent.empty() ? vIdent + "@" : "") << hostmask; + req_send_memos(source, user, host); + Log(LOG_COMMAND, u, this, NULL) << "to request new vhost " << (!user.empty() ? user + "@" : "") << host; return; } |