X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fusers.cpp;h=b3546a134c9890f6380b71e10d634a301f46e05a;hb=c8f515121fbdf3e4de693712ef2311cece45477d;hp=aa5031b2b1632bdda7c885f0ad3b3d1935d6da83;hpb=d865b434865907bfad0a187dd403d4ca8144e469;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/users.cpp b/src/users.cpp index aa5031b2b..b3546a134 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -63,7 +63,7 @@ std::string User::GetModeLetters(bool includeparams) const return ret; } -User::User(const std::string& uid, Server* srv, int type) +User::User(const std::string& uid, Server* srv, UserType type) : age(ServerInstance->Time()) , signon(0) , uuid(uid) @@ -189,12 +189,7 @@ bool LocalUser::HasPermission(const std::string &command) return false; } - if (oper->AllowedOperCommands.find(command) != oper->AllowedOperCommands.end()) - return true; - else if (oper->AllowedOperCommands.find("*") != oper->AllowedOperCommands.end()) - return true; - - return false; + return oper->AllowedOperCommands.Contains(command); } bool User::HasPrivPermission(const std::string &privstr, bool noisy) @@ -211,14 +206,8 @@ bool LocalUser::HasPrivPermission(const std::string &privstr, bool noisy) return false; } - if (oper->AllowedPrivs.find(privstr) != oper->AllowedPrivs.end()) - { + if (oper->AllowedPrivs.Contains(privstr)) return true; - } - else if (oper->AllowedPrivs.find("*") != oper->AllowedPrivs.end()) - { - return true; - } if (noisy) this->WriteNotice("Oper type " + oper->name + " does not have access to priv " + privstr); @@ -375,8 +364,8 @@ void User::Oper(OperInfo* info) void OperInfo::init() { - AllowedOperCommands.clear(); - AllowedPrivs.clear(); + AllowedOperCommands.Clear(); + AllowedPrivs.Clear(); AllowedUserModes.reset(); AllowedChanModes.reset(); AllowedUserModes['o' - 'A'] = true; // Call me paranoid if you want. @@ -384,19 +373,9 @@ void OperInfo::init() for(std::vector >::iterator iter = class_blocks.begin(); iter != class_blocks.end(); ++iter) { ConfigTag* tag = *iter; - std::string mycmd, mypriv; - /* Process commands */ - irc::spacesepstream CommandList(tag->getString("commands")); - while (CommandList.GetToken(mycmd)) - { - AllowedOperCommands.insert(mycmd); - } - irc::spacesepstream PrivList(tag->getString("privs")); - while (PrivList.GetToken(mypriv)) - { - AllowedPrivs.insert(mypriv); - } + AllowedOperCommands.AddList(tag->getString("commands")); + AllowedPrivs.AddList(tag->getString("privs")); std::string modes = tag->getString("usermodes"); for (std::string::const_iterator c = modes.begin(); c != modes.end(); ++c) @@ -709,7 +688,7 @@ const std::string& User::GetRealHost() const irc::sockets::cidr_mask User::GetCIDRMask() { - int range = 0; + unsigned char range = 0; switch (client_sa.sa.sa_family) { case AF_INET6: @@ -730,8 +709,7 @@ bool User::SetClientIP(const std::string& address, bool recheck_eline) void User::SetClientIP(const irc::sockets::sockaddrs& sa, bool recheck_eline) { - cachedip.clear(); - cached_hostip.clear(); + this->InvalidateCache(); memcpy(&client_sa, &sa, sizeof(irc::sockets::sockaddrs)); } @@ -1185,15 +1163,15 @@ void User::PurgeEmptyChannels() const std::string& FakeUser::GetFullHost() { - if (!ServerInstance->Config->HideWhoisServer.empty()) - return ServerInstance->Config->HideWhoisServer; + if (!ServerInstance->Config->HideServer.empty()) + return ServerInstance->Config->HideServer; return server->GetName(); } const std::string& FakeUser::GetFullRealHost() { - if (!ServerInstance->Config->HideWhoisServer.empty()) - return ServerInstance->Config->HideWhoisServer; + if (!ServerInstance->Config->HideServer.empty()) + return ServerInstance->Config->HideServer; return server->GetName(); } @@ -1210,7 +1188,32 @@ ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask, cons Update(&parent); name = "unnamed"; type = t; - config = tag; + host = mask; + + // Connect classes can inherit from each other but this is problematic for modules which can't use + // ConnectClass::Update so we build a hybrid tag containing all of the values set on this class as + // well as the parent class. + ConfigItems* items = NULL; + config = ConfigTag::create(tag->tag, tag->src_name, tag->src_line, items); + + const ConfigItems& parentkeys = parent.config->getItems(); + for (ConfigItems::const_iterator piter = parentkeys.begin(); piter != parentkeys.end(); ++piter) + { + // The class name and parent name are not inherited + if (piter->first == "name" || piter->first == "parent") + continue; + + // Store the item in the config tag. If this item also + // exists in the child it will be overwritten. + (*items)[piter->first] = piter->second; + } + + const ConfigItems& childkeys = tag->getItems(); + for (ConfigItems::const_iterator citer = childkeys.begin(); citer != childkeys.end(); ++citer) + { + // This will overwrite the parent value if present. + (*items)[citer->first] = citer->second; + } } void ConnectClass::Update(const ConnectClass* src)