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
This commit is contained in:
special 2008-09-29 08:13:49 +00:00
parent cbef292a6c
commit fee65af28e
3 changed files with 15 additions and 27 deletions

View File

@ -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

View File

@ -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();

View File

@ -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)