diff options
author | Adam <Adam@anope.org> | 2011-04-22 03:16:11 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-05-16 04:06:17 -0400 |
commit | c8c23158a4ff74822d6c7d201dc53d879e3d91e8 (patch) | |
tree | 4bc9ae029691d5e7c03ebc1481683a010b733844 /src/nickserv.cpp | |
parent | 1782ce260c5bc214ec0b2e39257ab1371b68ae9c (diff) |
Moved the core pseudo clients out into their own modules
Diffstat (limited to 'src/nickserv.cpp')
-rw-r--r-- | src/nickserv.cpp | 242 |
1 files changed, 0 insertions, 242 deletions
diff --git a/src/nickserv.cpp b/src/nickserv.cpp index 396c55c53..943b0715b 100644 --- a/src/nickserv.cpp +++ b/src/nickserv.cpp @@ -77,225 +77,6 @@ void NickServRelease::Tick(time_t) */ } -/*************************************************************************/ -/* *INDENT-OFF* */ -void moduleAddNickServCmds() -{ - ModuleManager::LoadModuleList(Config->NickServCoreModules); -} -/* *INDENT-ON* */ -/*************************************************************************/ - -/* Return information on memory use. Assumes pointers are valid. */ - -void get_aliases_stats(long &count, long &mem) -{ - count = mem = 0; - - for (nickalias_map::const_iterator it = NickAliasList.begin(), it_end = NickAliasList.end(); it != it_end; ++it) - { - NickAlias *na = it->second; - - ++count; - mem += sizeof(*na); - if (!na->nick.empty()) - mem += na->nick.length() + 1; - if (!na->last_usermask.empty()) - mem += na->last_usermask.length() + 1; - if (!na->last_realname.empty()) - mem += na->last_realname.length() + 1; - if (!na->last_quit.empty()) - mem += na->last_quit.length() + 1; - } -} - -/*************************************************************************/ - -/* Return information on memory use. Assumes pointers are valid. */ - -void get_core_stats(long &count, long &mem) -{ - count = mem = 0; - unsigned j, end; - - for (nickcore_map::const_iterator it = NickCoreList.begin(), it_end = NickCoreList.end(); it != it_end; ++it) - { - NickCore *nc = it->second; - - ++count; - mem += sizeof(*nc); - - if (!nc->display.empty()) - mem += nc->display.length() + 1; - if (!nc->pass.empty()) - mem += nc->pass.length() + 1; - if (!nc->greet.empty()) - mem += nc->greet.length() + 1; - - mem += sizeof(Anope::string) * nc->access.size(); - - for (j = 0, end = nc->access.size(); j < end; ++j) - mem += nc->GetAccess(j).length() + 1; - - mem += nc->memos.memos.size() * sizeof(Memo); - for (j = 0, end = nc->memos.memos.size(); j < end; ++j) - if (!nc->memos.memos[j]->text.empty()) - mem += nc->memos.memos[j]->text.length() + 1; - - mem += sizeof(NickAlias *) * nc->aliases.size(); - } -} - -/*************************************************************************/ -/*************************************************************************/ - -/* NickServ initialization. */ - -void ns_init() -{ - moduleAddNickServCmds(); -} - -/*************************************************************************/ - -/* Check whether a user is on the access list of the nick they're using If - * not, send warnings as appropriate. If so (and not NI_SECURE), update - * last seen info. - * Return 1 if the user is valid and recognized, 0 otherwise (note - * that this means an NI_SECURE nick will return 0 from here). - * If the user's nick is not registered, 0 is returned. - */ - -int validate_user(User *u) -{ - NickAlias *na = findnick(u->nick); - if (!na) - return 0; - - if (na->HasFlag(NS_FORBIDDEN)) - { - u->SendMessage(NickServ, _("This nickname may not be used. Please choose another one.")); - u->Collide(na); - return 0; - } - - if (na->nc->HasFlag(NI_SUSPENDED)) - { - u->SendMessage(NickServ, _(NICK_X_SUSPENDED), u->nick.c_str()); - u->Collide(na); - return 0; - } - - if (!u->IsIdentified() && !u->fingerprint.empty() && na->nc->FindCert(u->fingerprint)) - { - u->SendMessage(NickServ, _("SSL Fingerprint accepted, you are now identified")); - u->Identify(na); - return 1; - } - - if (!na->nc->HasFlag(NI_SECURE) && u->IsRecognized()) - { - na->last_seen = Anope::CurTime; - Anope::string last_usermask = u->GetIdent() + "@" + u->GetDisplayedHost(); - na->last_usermask = last_usermask; - na->last_realname = u->realname; - - check_memos(u); - - return 1; - } - - if (u->IsRecognized() || !na->nc->HasFlag(NI_KILL_IMMED)) - { - if (na->nc->HasFlag(NI_SECURE)) - u->SendMessage(NickServ, _(NICK_IS_SECURE), Config->UseStrictPrivMsgString.c_str(), Config->s_NickServ.c_str()); - else - u->SendMessage(NickServ, _(NICK_IS_REGISTERED), Config->UseStrictPrivMsgString.c_str(), Config->s_NickServ.c_str()); - } - - if (na->nc->HasFlag(NI_KILLPROTECT) && !u->IsRecognized()) - { - if (na->nc->HasFlag(NI_KILL_IMMED)) - { - u->SendMessage(NickServ, _(FORCENICKCHANGE_NOW)); - u->Collide(na); - } - else if (na->nc->HasFlag(NI_KILL_QUICK)) - { - u->SendMessage(NickServ, _("If you do not change within 20 seconds, I will change your nick.")); - new NickServCollide(u, 20); - } - else - { - u->SendMessage(NickServ, _("If you do not change within one minute, I will change your nick.")); - new NickServCollide(u, 60); - } - } - - return 0; -} - -/*************************************************************************/ - -/* Remove all nicks which have expired. Also update last-seen time for all - * nicks. - */ - -void expire_nicks() -{ - for (nickalias_map::const_iterator it = NickAliasList.begin(), it_end = NickAliasList.end(); it != it_end;) - { - NickAlias *na = it->second; - ++it; - - User *u = finduser(na->nick); - if (u && (na->nc->HasFlag(NI_SECURE) ? u->IsIdentified(true) : u->IsRecognized(true))) - { - Log(LOG_DEBUG_2) << "NickServ: updating last seen time for " << na->nick; - na->last_seen = Anope::CurTime; - } - - bool expire = false; - - if (na->nc->HasFlag(NI_UNCONFIRMED)) - if (Config->NSUnconfirmedExpire && Anope::CurTime - na->time_registered >= Config->NSUnconfirmedExpire) - expire = true; - - if (na->nc->HasFlag(NI_SUSPENDED)) - { - if (Config->NSSuspendExpire && Anope::CurTime - na->last_seen >= Config->NSSuspendExpire) - expire = true; - } - else if (na->HasFlag(NS_FORBIDDEN)) - { - if (Config->NSForbidExpire && Anope::CurTime - na->last_seen >= Config->NSForbidExpire) - expire = true; - } - else if (Config->NSExpire && Anope::CurTime - na->last_seen >= Config->NSExpire) - expire = true; - if (na->HasFlag(NS_NO_EXPIRE)) - expire = false; - - if (expire) - { - EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnPreNickExpire, OnPreNickExpire(na)); - if (MOD_RESULT == EVENT_STOP) - continue; - Anope::string extra; - if (na->HasFlag(NS_FORBIDDEN)) - extra = "forbidden "; - else if (na->nc->HasFlag(NI_SUSPENDED)) - extra = "suspended "; - Log(LOG_NORMAL, "expire") << "Expiring " << extra << "nickname " << na->nick << " (group: " << na->nc->display << ") (e-mail: " << (na->nc->email.empty() ? "none" : na->nc->email) << ")"; - FOREACH_MOD(I_OnNickExpire, OnNickExpire(na)); - delete na; - } - } -} - -/*************************************************************************/ - NickAlias *findnick(const Anope::string &nick) { FOREACH_MOD(I_OnFindNick, OnFindNick(nick)); @@ -320,10 +101,6 @@ NickCore *findcore(const Anope::string &nick) return NULL; } -/*************************************************************************/ -/*********************** NickServ private routines ***********************/ -/*************************************************************************/ - /** Is the user's address on the nickcores access list? * @param u The user * @param nc The nickcore @@ -360,9 +137,7 @@ bool is_on_access(const User *u, const NickCore *nc) void change_core_display(NickCore *nc, const Anope::string &newdisplay) { - /* Log ... */ FOREACH_MOD(I_OnChangeCoreDisplay, OnChangeCoreDisplay(nc, newdisplay)); - Log(LOG_NORMAL, "nick") << Config->s_NickServ << ": changing " << nc->display << " nickname group display to " << newdisplay; /* Remove the core from the list */ NickCoreList.erase(nc->display); @@ -381,20 +156,3 @@ void change_core_display(NickCore *nc) change_core_display(nc, na->nick); } -/*************************************************************************/ -/*********************** NickServ command routines ***********************/ -/*************************************************************************/ - -int do_setmodes(User *u) -{ - /* Walk users current channels */ - for (UChannelList::iterator it = u->chans.begin(), it_end = u->chans.end(); it != it_end; ++it) - { - ChannelContainer *cc = *it; - - Channel *c = cc->chan; - if (c) - chan_set_correct_modes(u, c, 1); - } - return MOD_CONT; -} |