- /*
- * fix by brain.
- * as these nicknames are 'RFC impossible', we can be sure nobody is going to be
- * using one as a registered connection. As they are per fd, we can also safely assume
- * that we wont have collisions. Therefore, if the nick exists in the list, its only
- * used by a dead socket, erase the iterator so that the new client may reclaim it.
- * this was probably the cause of 'server ignores me when i hammer it with reconnects'
- * issue in earlier alphas/betas
- */
- if (iter != Instance->clientlist.end())
- {
- userrec* goner = iter->second;
- DELETE(goner);
- Instance->clientlist.erase(iter);
- }
-
- Instance->Log(DEBUG,"AddClient: %d %d %s",socket,port,ipaddr);
-
- New = new userrec(Instance);
- Instance->clientlist[tempnick] = New;
- New->fd = socket;
- strlcpy(New->nick,tempnick.c_str(),NICKMAX-1);
-
- New->server = Instance->FindServerNamePtr(Instance->Config->ServerName);
- /* We don't need range checking here, we KNOW 'unknown\0' will fit into the ident field. */
- strcpy(New->ident, "unknown");
-
- New->registered = REG_NONE;
- New->signon = Instance->Time() + Instance->Config->dns_timeout;
- New->lastping = 1;
-
- Instance->Log(DEBUG,"Setting socket addresses");
- New->SetSockAddr(AF_FAMILY, ipaddr, port);
- Instance->Log(DEBUG,"Socket addresses set.");
-
- /* Smarter than your average bear^H^H^H^Hset of strlcpys. */
- for (const char* temp = New->GetIPString(); *temp && j < 64; temp++, j++)
- New->dhost[j] = New->host[j] = *temp;
- New->dhost[j] = New->host[j] = 0;
-
- // set the registration timeout for this user
- unsigned long class_regtimeout = 90;
- int class_flood = 0;
- long class_threshold = 5;
- long class_sqmax = 262144; // 256kb
- long class_rqmax = 4096; // 4k
-
- for (ClassVector::iterator i = Instance->Config->Classes.begin(); i != Instance->Config->Classes.end(); i++)
- {
- if ((i->type == CC_ALLOW) && (match(ipaddr,i->host.c_str(),true)))
- {
- class_regtimeout = (unsigned long)i->registration_timeout;
- class_flood = i->flood;
- New->pingmax = i->pingtime;
- class_threshold = i->threshold;
- class_sqmax = i->sendqmax;
- class_rqmax = i->recvqmax;
- break;
- }
- }
-
- New->nping = Instance->Time() + New->pingmax + Instance->Config->dns_timeout;
- New->timeout = Instance->Time() + class_regtimeout;
- New->flood = class_flood;
- New->threshold = class_threshold;
- New->sendqmax = class_sqmax;
- New->recvqmax = class_rqmax;
-
- Instance->local_users.push_back(New);
-
- if ((Instance->local_users.size() > Instance->Config->SoftLimit) || (Instance->local_users.size() >= MAXCLIENTS))