Skip to content

Commit

Permalink
Add ns_identify:maxlogins to limit the max number of concurrent login…
Browse files Browse the repository at this point in the history
…s per account
  • Loading branch information
Adam- committed Jun 29, 2015
1 parent 8eb4677 commit 510a746
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
10 changes: 9 additions & 1 deletion data/nickserv.example.conf
Expand Up @@ -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"; }

Expand Down
4 changes: 4 additions & 0 deletions 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
Expand Down
23 changes: 17 additions & 6 deletions modules/commands/ns_identify.cpp
Expand Up @@ -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
Expand Down

0 comments on commit 510a746

Please sign in to comment.