/** * Someone's connecting, accept the connection and wait for identification... * It's always the other fellow that starts sending if he made the connection. */ void ConnectionManager::accept(const Socket& sock, bool secure) throw() { uint32_t now = GET_TICK(); if(now > floodCounter) { floodCounter = now + FLOOD_ADD; } else { if(false && now + FLOOD_TRIGGER < floodCounter) { Socket s; try { s.accept(sock); } catch(const SocketException&) { // ... } dcdebug("Connection flood detected!\n"); return; } else { floodCounter += FLOOD_ADD; } } UserConnection* uc = getConnection(false, secure); uc->setFlag(UserConnection::FLAG_INCOMING); uc->setState(UserConnection::STATE_SUPNICK); uc->setLastActivity(GET_TICK()); try { uc->accept(sock); } catch(const Exception&) { putConnection(uc); delete uc; } }
/** * Someone's connecting, accept the connection and wait for identification... * It's always the other fellow that starts sending if he made the connection. */ void ConnectionManager::on(ServerSocketListener::IncomingConnection) throw() { UserConnection* uc = NULL; u_int32_t now = GET_TICK(); if(now > floodCounter) { floodCounter = now + FLOOD_ADD; } else { if(now + FLOOD_TRIGGER < floodCounter) { Socket s; try { s.accept(socket); } catch(const SocketException&) { // ... } dcdebug("Connection flood detected!\n"); return; } else { floodCounter += 2000; } } try { uc = getConnection(); uc->setFlag(UserConnection::FLAG_INCOMING); uc->setState(UserConnection::STATE_NICK); uc->setLastActivity(GET_TICK()); uc->accept(socket); } catch(const SocketException& e) { dcdebug("ConnectionManager::OnIncomingConnection caught: %s\n", e.getError().c_str()); if(uc) putConnection(uc); } }