From 53d548355b6657e01bd6a296dc87c4abec271fef Mon Sep 17 00:00:00 2001 From: special Date: Thu, 8 Mar 2007 04:03:13 +0000 Subject: Patch by satmd to support using IP addresses with cgiirc git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6634 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_cgiirc.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp index f7dd03d8d..96ac66f14 100644 --- a/src/modules/m_cgiirc.cpp +++ b/src/modules/m_cgiirc.cpp @@ -26,6 +26,7 @@ enum CGItype { PASS, IDENT, PASSFIRST, IDENTFIRST, WEBIRC }; + /** Holds a CGI site's details */ class CGIhost : public classbase @@ -67,8 +68,9 @@ class cmd_webirc : public command_t user->Extend("cgiirc_realhost", new std::string(user->host)); user->Extend("cgiirc_realip", new std::string(user->GetIPString())); if (notify) - ServerInstance->WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from %s", user->nick, user->host, parameters[2], "_"); + ServerInstance->WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from %s", user->nick, user->host, parameters[2], user->host); user->Extend("cgiirc_webirc_hostname", new std::string(parameters[2])); + user->Extend("cgiirc_webirc_ip", new std::string(parameters[3])); return CMD_LOCALONLY; } } @@ -276,15 +278,32 @@ public: virtual void OnUserConnect(userrec* user) { - std::string* webirc_hostname; + std::string *webirc_hostname, *webirc_ip; if(user->GetExt("cgiirc_webirc_hostname", webirc_hostname)) { strlcpy(user->host,webirc_hostname->c_str(),63); strlcpy(user->dhost,webirc_hostname->c_str(),63); - user->InvalidateCache(); delete webirc_hostname; + user->InvalidateCache(); user->Shrink("cgiirc_webirc_hostname"); } + if(user->GetExt("cgiirc_webirc_ip", webirc_ip)) + { + bool valid=false; +#ifdef IPV6 + valid = (inet_pton(AF_INET6, webirc_ip->c_str(), &((sockaddr_in6*)user->ip)->sin6_addr) > 0); + + if(!valid) + valid = (inet_aton(webirc_ip->c_str(), &((sockaddr_in*)user->ip)->sin_addr)); +#else + if (inet_aton(webirc_ip->c_str(), &((sockaddr_in*)user->ip)->sin_addr)) + valid = true; +#endif + + delete webirc_ip; + user->InvalidateCache(); + user->Shrink("cgiirc_webirc_ip"); + } } bool CheckPass(userrec* user) -- cgit v1.2.3