+ LocalUser* user = IS_LOCAL(static_cast<User*>(container));
+ if (!user)
+ return;
+
+ // Remove the old list and create a new one.
+ unset(user);
+ dccallowlist* list = new dccallowlist();
+
+ irc::spacesepstream ts(value);
+ while (!ts.StreamEnd())
+ {
+ // Check we have space for another entry.
+ if (list->size() >= maxentries)
+ {
+ ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Oversized DCC allow list received for %s: %s",
+ user->uuid.c_str(), value.c_str());
+ delete list;
+ return;
+ }
+
+ // Extract the fields.
+ DCCAllow dccallow;
+ if (!ts.GetToken(dccallow.nickname) ||
+ !ts.GetToken(dccallow.hostmask) ||
+ !ts.GetNumericToken(dccallow.set_on) ||
+ !ts.GetNumericToken(dccallow.length))
+ {
+ ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Malformed DCC allow list received for %s: %s",
+ user->uuid.c_str(), value.c_str());
+ delete list;
+ return;
+ }
+
+ // Store the DCC allow entry.
+ list->push_back(dccallow);
+ }
+
+ // The value was well formed.
+ set(user, list);
+ }
+
+ std::string ToInternal(const Extensible* container, void* item) const CXX11_OVERRIDE
+ {
+ dccallowlist* list = static_cast<dccallowlist*>(item);
+ std::string buf;
+ for (dccallowlist::const_iterator iter = list->begin(); iter != list->end(); ++iter)
+ {
+ if (iter != list->begin())
+ buf.push_back(' ');
+
+ buf.append(iter->nickname);
+ buf.push_back(' ');
+ buf.append(iter->hostmask);
+ buf.push_back(' ');
+ buf.append(ConvToStr(iter->set_on));
+ buf.push_back(' ');
+ buf.append(ConvToStr(iter->length));
+ }
+ return buf;
+ }
+};
+
+class CommandDccallow : public Command
+{
+ public:
+ DCCAllowExt& ext;
+ unsigned long defaultlength;
+ CommandDccallow(Module* parent, DCCAllowExt& Ext)
+ : Command(parent, "DCCALLOW", 0)
+ , ext(Ext)
+ {
+ syntax = "[(+|-)<nick> [<time>]]|[LIST|HELP]";
+ /* XXX we need to fix this so it can work with translation stuff (i.e. move +- into a separate param */
+ }
+
+ CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
+ {
+ /* syntax: DCCALLOW [(+|-)<nick> [<time>]]|[LIST|HELP] */
+ if (!parameters.size())