inspircd/src/users.cpp

1 line
49 KiB
C++
Raw Normal View History

/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include "configreader.h" #include "channels.h" #include "users.h" #include <stdarg.h> #include "socketengine.h" #include "wildcard.h" #include "xline.h" #include "commands/cmd_whowas.h" static unsigned long already_sent[MAX_DESCRIPTORS] = {0}; /* XXX: Used for speeding up WriteCommon operations */ unsigned long uniq_id = 0; bool InitTypes(ServerConfig* conf, const char* tag) { if (conf->opertypes.size()) { for (opertype_t::iterator n = conf->opertypes.begin(); n != conf->opertypes.end(); n++) { if (n->second) delete[] n->second; } } conf->opertypes.clear(); return true; } bool InitClasses(ServerConfig* conf, const char* tag) { if (conf->operclass.size()) { for (operclass_t::iterator n = conf->operclass.begin(); n != conf->operclass.end(); n++) { if (n->second) delete[] n->second; } } conf->operclass.clear(); return true; } bool DoType(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types) { const char* TypeName = values[0].GetString(); const char* Classes = values[1].GetString(); conf->opertypes[TypeName] = strnewdup(Classes); return true; } bool DoClass(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types) { const char* ClassName = values[0].GetString(); const char* CommandList = values[1].GetString(); conf->operclass[ClassName] = strnewdup(CommandList); return true; } bool DoneClassesAndTypes(ServerConfig* conf, const char* tag) { return true; } std::string userrec::ProcessNoticeMasks(const char *sm) { bool adding = true, oldadding = false; const char *c = sm; std::string output; while (c && *c) { switch (*c) { case '+': adding = true; break; case '-': adding = false; break; case '*': for (unsigned char d = 'A'; d <= 'z'; d++) { if (ServerInstance->SNO->IsEnabled(d)) { if ((!IsNoticeMaskSet(d) && adding) || (IsNoticeMaskSet(d) && !adding)) { if ((oldadding != adding) || (!output.length())) output += (adding ? '+' : '-'); this->SetNoticeMask(d, adding); output += d; } } oldadding = adding; } break; default: if ((*c >= 'A') && (*c <= 'z') && (ServerInstance->SNO->IsEnabled(*c))) { if ((!IsNoticeMaskSet(*c) && adding) || (IsNoticeMaskSet(*c) && !adding)) { if ((oldadding != adding) || (!output.length())) output += (adding ? '+' : '-'); this->SetNoticeMask(*c, adding); output += *c; } } oldadding = adding; break; } *c++; } return output; } void userrec::StartDNSLookup() { try { bool cached; const char* ip = this->GetIPString(); /* Special case for 4in6 (Have i mentioned i HATE 4in6?) */ if (!strncmp(ip, "0::ffff:", 8)) res_reverse = new UserResolver(this->ServerInstance, this, ip + 8, DNS_QUERY_PTR4, cached); else res_reverse = new UserResolver(this->ServerInstance, this, ip, this->GetProtocolFamily() == AF_INET ? DNS_QUERY_PTR4 : DNS_QUERY_PTR6, cached); this->ServerInstance->AddResolver(res_reverse, cached); } catch (CoreException& e) { ServerInstance->Log(DEBUG,"Error in resolver: %s",e.GetReason()); } } UserResolver::UserResolver(InspIRCd* Instance, userrec* user, std::string to_resolve, QueryType qt, bool &cache) : Resolver(Instance, to_resolve, qt, cache), bound_user(user) { this->fwd = (qt == DNS_QUERY_A || qt == DNS_QUERY_AAAA); this->bound_fd = user->GetFd(); } void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl, bool cached) { if ((!this->fwd) && (ServerInstance->SE->GetRef(this->bound_fd) == this->bound_user)) {