- ServerInstance->Modules->SetPriority(this, I_OnUserConnect, PRIORITY_FIRST);
- Module* umodes = ServerInstance->Modules->Find("m_conn_umodes.so");
- ServerInstance->Modules->SetPriority(this, I_OnUserConnect, PRIORITY_BEFORE, &umodes);
+ 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());
+ }
+ }
+
+public:
+ ModuleCgiIRC()
+ : cmd(this)
+ , waiting("cgiirc-delay", this)
+ , DNS(this, "DNS")
+ {
+ }
+
+ void init() CXX11_OVERRIDE
+ {
+ OnRehash(NULL);
+ ServiceProvider* providerlist[] = { &cmd, &cmd.realhost, &cmd.realip, &cmd.webirc_hostname, &cmd.webirc_ip, &waiting };
+ ServerInstance->Modules->AddServices(providerlist, sizeof(providerlist)/sizeof(ServiceProvider*));