+ // There is no need to check for gateways if one is already being used.
+ if (cmd.realhost.get(user))
+ return MOD_RES_PASSTHRU;
+
+ for (std::vector<IdentHost>::const_iterator iter = hosts.begin(); iter != hosts.end(); ++iter)
+ {
+ // If we don't match the host then skip to the next host.
+ if (!iter->Matches(user))
+ continue;
+
+ // We have matched an <cgihost> block! Try to parse the encoded IPv4 address
+ // out of the ident.
+ irc::sockets::sockaddrs address(user->client_sa);
+ if (!ParseIdent(user, address))
+ return MOD_RES_PASSTHRU;
+
+ // Store the hostname and IP of the gateway for later use.
+ cmd.realhost.set(user, user->GetRealHost());
+ cmd.realip.set(user, user->GetIPString());
+
+ const std::string& newident = iter->GetIdent();
+ cmd.WriteLog("Connecting user %s is using an ident gateway; changing their IP from %s to %s and their ident from %s to %s.",
+ user->uuid.c_str(), user->GetIPString().c_str(), address.addr().c_str(), user->ident.c_str(), newident.c_str());
+
+ user->ChangeIdent(newident);
+ user->SetClientIP(address);
+ break;
+ }
+ return MOD_RES_PASSTHRU;
+ }
+
+ void OnWebIRCAuth(LocalUser* user, const WebIRC::FlagMap* flags) CXX11_OVERRIDE
+ {
+ // We are only interested in connection flags. If none have been
+ // given then we have nothing to do.
+ if (!flags)
+ return;
+
+ WebIRC::FlagMap::const_iterator cport = flags->find("remote-port");
+ if (cport != flags->end())