diff options
author | Adam <Adam@anope.org> | 2015-06-29 09:37:09 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2015-06-29 09:37:09 -0400 |
commit | 510a746f8d7cd373bfae4efc98a1ef9b13f2b4e9 (patch) | |
tree | 17bd41d46168c7deff41f1088b16b798c5944e22 | |
parent | 8eb46772e6e9244575851ceaa86b39e57a1db060 (diff) |
Add ns_identify:maxlogins to limit the max number of concurrent logins per account
-rw-r--r-- | data/nickserv.example.conf | 10 | ||||
-rw-r--r-- | docs/Changes.conf | 4 | ||||
-rw-r--r-- | modules/commands/ns_identify.cpp | 23 |
3 files changed, 30 insertions, 7 deletions
diff --git a/data/nickserv.example.conf b/data/nickserv.example.conf index e8d02bed6..cda8bc49e 100644 --- a/data/nickserv.example.conf +++ b/data/nickserv.example.conf @@ -381,7 +381,15 @@ command { service = "NickServ"; name = "UNGROUP"; command = "nickserv/ungroup"; * * Used for identifying to accounts. */ -module { name = "ns_identify" } +module +{ + name = "ns_identify" + + /* + * If set, limits the number of concurrent users that can be logged in as a given account at once. + */ + maxlogins = 10 +} command { service = "NickServ"; name = "ID"; command = "nickserv/identify"; hide = true; } command { service = "NickServ"; name = "IDENTIFY"; command = "nickserv/identify"; } diff --git a/docs/Changes.conf b/docs/Changes.conf index 3b90d38e8..5e813b3e4 100644 --- a/docs/Changes.conf +++ b/docs/Changes.conf @@ -1,3 +1,7 @@ +Anope Version 2.0.3-git +------------------- +Add ns_identify:maxlogins to limit the max number of concurrent logins per account + Anope Version 2.0.2 ------------------- Add an operserv/oper/modify privilege, required to use oper add and oper del diff --git a/modules/commands/ns_identify.cpp b/modules/commands/ns_identify.cpp index ce564321c..4aa361a0a 100644 --- a/modules/commands/ns_identify.cpp +++ b/modules/commands/ns_identify.cpp @@ -77,16 +77,27 @@ class CommandNSIdentify : public Command NickAlias *na = NickAlias::Find(nick); if (na && na->nc->HasExt("NS_SUSPENDED")) + { source.Reply(NICK_X_SUSPENDED, na->nick.c_str()); - else if (u->Account() && na && u->Account() == na->nc) + return; + } + + if (u->Account() && na && u->Account() == na->nc) + { source.Reply(_("You are already identified.")); - else + return; + } + + unsigned int maxlogins = Config->GetModule(this->owner)->Get<unsigned int>("maxlogins"); + if (na && maxlogins && na->nc->users.size() >= maxlogins) { - NSIdentifyRequest *req = new NSIdentifyRequest(owner, source, this, na ? na->nc->display : nick, pass); - FOREACH_MOD(OnCheckAuthentication, (u, req)); - req->Dispatch(); + source.Reply(_("Account \2%s\2 has exceeeded the maximum number of simultaneous logins (%u)."), na->nc->display.c_str(), maxlogins); + return; } - return; + + NSIdentifyRequest *req = new NSIdentifyRequest(owner, source, this, na ? na->nc->display : nick, pass); + FOREACH_MOD(OnCheckAuthentication, (u, req)); + req->Dispatch(); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override |