+
+ if (action == '-')
+ {
+ user->GetExt("dccallow_list", dl);
+ // check if it contains any entries
+ if (dl)
+ {
+ if (dl->size())
+ {
+ for (dccallowlist::iterator i = dl->begin(); i != dl->end(); ++i)
+ {
+ // search through list
+ if (i->nickname == target->nick)
+ {
+ dl->erase(i);
+ user->WriteServ("995 %s %s :Removed %s from your DCCALLOW list", user->nick, user->nick, target->nick);
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ delete dl;
+ user->Shrink("dccallow_list");
+
+ // remove from userlist
+ for (userlist::iterator j = ul.begin(); j != ul.end(); ++j)
+ {
+ User* u = (User*)(*j);
+ if (u == user)
+ {
+ ul.erase(j);
+ break;
+ }
+ }
+ }
+ }
+ else if (action == '+')
+ {
+ // fetch current DCCALLOW list
+ user->GetExt("dccallow_list", dl);
+ // they don't have one, create it
+ if (!dl)
+ {
+ dl = new dccallowlist;
+ user->Extend("dccallow_list", dl);
+ // add this user to the userlist
+ ul.push_back(user);
+ }
+ for (dccallowlist::const_iterator k = dl->begin(); k != dl->end(); ++k)
+ {
+ if (k->nickname == target->nick)
+ {
+ user->WriteServ("996 %s %s :%s is already on your DCCALLOW list", user->nick, user->nick, target->nick);
+ return CMD_FAILURE;
+ }
+ else if (ServerInstance->MatchText(user->GetFullHost(), k->hostmask))
+ {
+ user->WriteServ("996 %s %s :You cannot add yourself to your own DCCALLOW list!", user->nick, user->nick);
+ return CMD_FAILURE;
+ }
+ }
+
+ std::string mask = std::string(target->nick)+"!"+std::string(target->ident)+"@"+std::string(target->dhost);
+ std::string default_length = Conf->ReadValue("dccallow", "length", 0);
+
+ long length;
+ if (pcnt < 2)
+ {
+ length = ServerInstance->Duration(default_length);
+ }
+ else if (!atoi(parameters[1]))
+ {
+ length = 0;
+ }
+ else
+ {
+ length = ServerInstance->Duration(parameters[1]);
+ }
+
+ if (!ServerInstance->IsValidMask(mask.c_str()))
+ {
+ return CMD_FAILURE;
+ }
+
+ dl->push_back(DCCAllow(target->nick, mask, ServerInstance->Time(), length));
+
+ if (length > 0)
+ {
+ user->WriteServ("993 %s %s :Added %s to DCCALLOW list for %d seconds", user->nick, user->nick, target->nick, length);
+ }
+ else
+ {
+ user->WriteServ("994 %s %s :Added %s to DCCALLOW list for this session", user->nick, user->nick, target->nick);
+ }
+
+ /* route it. */
+ return CMD_SUCCESS;
+ }