From fee65af28e1db5cc431bda2dc643952b88461a74 Mon Sep 17 00:00:00 2001 From: special Date: Mon, 29 Sep 2008 08:13:49 +0000 Subject: [PATCH] Replace the IP (in addition to hostname) for CGIIRC clients; fixes glines and zlines on IPs affecting cgiirc users. Thanks to Saz|Laptop git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10607 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/users.h | 3 ++- src/modules/m_cgiirc.cpp | 33 ++++++++++----------------------- src/users.cpp | 6 +++--- 3 files changed, 15 insertions(+), 27 deletions(-) diff --git a/include/users.h b/include/users.h index fdfa4606b..5f066cdd4 100644 --- a/include/users.h +++ b/include/users.h @@ -708,9 +708,10 @@ class CoreExport User : public EventHandler User(InspIRCd* Instance, const std::string &uid = ""); /** Check if the user matches a G or K line, and disconnect them if they do. + * @param doZline True if ZLines should be checked (if IP has changed since initial connect) * Returns true if the user matched a ban, false else. */ - bool CheckLines(); + bool CheckLines(bool doZline = false); /** Returns the full displayed host of the user * This member function returns the hostname of the user as seen by other users diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp index 73cc95f54..3cb4da3e1 100644 --- a/src/modules/m_cgiirc.cpp +++ b/src/modules/m_cgiirc.cpp @@ -112,9 +112,11 @@ class CGIResolver : public Resolver them->host.assign(result,0, 64); them->dhost.assign(result, 0, 64); + if (querytype) + them->SetSockAddr(them->GetProtocolFamily(), result.c_str(), them->GetPort()); them->ident.assign("~cgiirc", 0, 8); them->InvalidateCache(); - them->CheckLines(); + them->CheckLines(true); } } @@ -268,24 +270,24 @@ public: if(iter->type == PASS) { CheckPass(user); // We do nothing if it fails so... - user->CheckLines(); + user->CheckLines(true); } else if(iter->type == PASSFIRST && !CheckPass(user)) { // If the password lookup failed, try the ident CheckIdent(user); // If this fails too, do nothing - user->CheckLines(); + user->CheckLines(true); } else if(iter->type == IDENT) { CheckIdent(user); // Nothing on failure. - user->CheckLines(); + user->CheckLines(true); } else if(iter->type == IDENTFIRST && !CheckIdent(user)) { // If the ident lookup fails, try the password. CheckPass(user); - user->CheckLines(); + user->CheckLines(true); } else if(iter->type == WEBIRC) { @@ -310,25 +312,15 @@ public: } if(user->GetExt("cgiirc_webirc_ip", webirc_ip)) { - bool valid=false; ServerInstance->Users->RemoveCloneCounts(user); -#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 - + user->SetSockAddr(user->GetProtocolFamily(), webirc_ip->c_str(), user->GetPort()); delete webirc_ip; user->InvalidateCache(); user->Shrink("cgiirc_webirc_ip"); ServerInstance->Users->AddLocalClone(user); ServerInstance->Users->AddGlobalClone(user); user->CheckClass(); - user->CheckLines(); + user->CheckLines(true); } } @@ -410,12 +402,7 @@ public: user->Extend("cgiirc_realhost", new std::string(user->host)); user->Extend("cgiirc_realip", new std::string(user->GetIPString())); ServerInstance->Users->RemoveCloneCounts(user); -#ifdef IPV6 - if (user->GetProtocolFamily() == AF_INET6) - inet_pton(AF_INET6, newip, &((sockaddr_in6*)user->ip)->sin6_addr); - else -#endif - inet_aton(newip, &((sockaddr_in*)user->ip)->sin_addr); + user->SetSockAddr(user->GetProtocolFamily(), newip, user->GetPort()); ServerInstance->Users->AddLocalClone(user); ServerInstance->Users->AddGlobalClone(user); user->CheckClass(); diff --git a/src/users.cpp b/src/users.cpp index 9f9d34fa4..33b8cdc7c 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -842,10 +842,10 @@ void User::CheckClass() this->nping = ServerInstance->Time() + a->GetPingTime() + ServerInstance->Config->dns_timeout; } -bool User::CheckLines() +bool User::CheckLines(bool doZline) { - const char* check[] = { "G" , "K", NULL }; - + const char* check[] = { "G" , "K", (doZline) ? "Z" : NULL, NULL }; + if (!this->exempt) { for (int n = 0; check[n]; ++n) -- 2.39.5