+ dynamic_reference<DNS::Manager> DNS;
+
+ static void RecheckClass(LocalUser* user)
+ {
+ user->MyClass = NULL;
+ user->SetClass();
+ user->CheckClass();
+ }
+
+ static void ChangeIP(LocalUser* user, const std::string& newip)
+ {
+ ServerInstance->Users->RemoveCloneCounts(user);
+ user->SetClientIP(newip.c_str());
+ ServerInstance->Users->AddLocalClone(user);
+ ServerInstance->Users->AddGlobalClone(user);
+ }
+
+ void HandleIdentOrPass(LocalUser* user, const std::string& newip, bool was_pass)
+ {
+ cmd.realhost.set(user, user->host);
+ cmd.realip.set(user, user->GetIPString());
+ ChangeIP(user, newip);
+ user->host = user->dhost = user->GetIPString();
+ user->InvalidateCache();
+ RecheckClass(user);
+
+ // Don't create the resolver if the core couldn't put the user in a connect class or when dns is disabled
+ if (user->quitting || !DNS || user->MyClass->nouserdns)
+ return;
+
+ CGIResolver* r = new CGIResolver(*this->DNS, this, cmd.notify, newip, user, (was_pass ? "PASS" : "IDENT"), waiting);
+ try
+ {
+ waiting.set(user, waiting.get(user) + 1);
+ this->DNS->Process(r);
+ }
+ catch (DNS::Exception &ex)
+ {
+ int count = waiting.get(user);
+ if (count)
+ waiting.set(user, count - 1);
+ delete r;
+ if (cmd.notify)
+ ServerInstance->SNO->WriteToSnoMask('a', "Connecting user %s detected as using CGI:IRC (%s), but I could not resolve their hostname; %s", user->nick.c_str(), user->host.c_str(), ex.GetReason());
+ }
+ }
+