summaryrefslogtreecommitdiff
path: root/modules/extra/hs_request.cpp
diff options
context:
space:
mode:
authorlethality <lethality@anope.org>2011-07-17 21:58:27 +0100
committerlethality <lethality@anope.org>2011-07-17 21:58:27 +0100
commit39ca53cfcf33c1a2034b987feab313ee7a94725e (patch)
tree2edcd66f30651bb72912f8e1c5cf3487a7858c4c /modules/extra/hs_request.cpp
parent46f2f3bd8f5b0d010144d515a744afb292027b0c (diff)
Fixed hs_request and corrected a typo(?) in hs activate
Diffstat (limited to 'modules/extra/hs_request.cpp')
-rw-r--r--modules/extra/hs_request.cpp57
1 files changed, 32 insertions, 25 deletions
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;
}