this->bound_fd = user->GetFd();
}
-void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl, bool cached)
+void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl, bool cached, int resultnum)
{
+ /* We are only interested in the first matching result */
+ if (resultnum)
+ return;
+
if ((!this->fwd) && (ServerInstance->SE->GetRef(this->bound_fd) == this->bound_user))
{
this->bound_user->stored_host = result;
return;
}
+ /*
+ * Check connect class settings and initialise settings into userrec.
+ * This will be done again after DNS resolution. -- w00t
+ */
New->CheckClass();
- New->pingmax = i->GetPingTime();
- New->nping = Instance->Time() + i->GetPingTime() + Instance->Config->dns_timeout;
- New->timeout = Instance->Time() + i->GetRegTimeout();
- New->flood = i->GetFlood();
- New->threshold = i->GetThreshold();
- New->sendqmax = i->GetSendqMax();
- New->recvqmax = i->GetRecvqMax();
-
Instance->local_users.push_back(New);
if ((Instance->local_users.size() > Instance->Config->SoftLimit) || (Instance->local_users.size() >= MAXCLIENTS))
/*
* Check class restrictions
*/
-void userrec::CheckClass()
+void userrec::CheckClass(const std::string &explicit_class)
{
- ConnectClass* a = this->GetClass();
+ ConnectClass* a = this->GetClass(explicit_class);
if ((!a) || (a->GetType() == CC_DENY))
{
ServerInstance->WriteOpers("*** WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s", a->GetMaxGlobal(), this->GetIPString());
return;
}
+
+ this->pingmax = a->GetPingTime();
+ this->nping = ServerInstance->Time() + a->GetPingTime() + ServerInstance->Config->dns_timeout;
+ this->timeout = ServerInstance->Time() + a->GetRegTimeout();
+ this->flood = a->GetFlood();
+ this->threshold = a->GetThreshold();
+ this->sendqmax = a->GetSendqMax();
+ this->recvqmax = a->GetRecvqMax();
+ this->MaxChans = a->GetMaxChans();
}
void userrec::FullConnect()
}
}
+unsigned int userrec::GetMaxChans()
+{
+ return this->MaxChans;
+}
/* looks up a users password for their connection class (<ALLOW>/<DENY> tags)
* NOTE: If the <ALLOW> or <DENY> tag specifies an ip, and this user resolves,
* then their ip will be taken as 'priority' anyway, so for example,
* <connect allow="127.0.0.1"> will match joe!bloggs@localhost
*/
-ConnectClass* userrec::GetClass()
+ConnectClass* userrec::GetClass(const std::string &explicit_name)
{
- for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
+ if (!explicit_name.empty())
+ {
+ for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
+ {
+ if (explicit_name == i->GetName())
+ return &(*i);
+ }
+ }
+ else
{
- if (((match(this->GetIPString(),i->GetHost().c_str(),true)) || (match(this->host,i->GetHost().c_str()))))
+ for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
{
- if (i->GetPort())
+ if (((match(this->GetIPString(),i->GetHost().c_str(),true)) || (match(this->host,i->GetHost().c_str()))))
{
- if (this->GetPort() == i->GetPort())
- return &(*i);
+ if (i->GetPort())
+ {
+ if (this->GetPort() == i->GetPort())
+ return &(*i);
+ else
+ continue;
+ }
else
- continue;
+ return &(*i);
}
- else
- return &(*i);
}
}
return NULL;