Ejemplo n.º 1
0
void Battlenet::Session::CheckIpCallback(PreparedQueryResult result)
{
    if (result)
    {
        bool banned = false;
        do
        {
            Field* fields = result->Fetch();
            if (fields[0].GetUInt64() != 0)
                banned = true;

            if (!fields[1].GetString().empty())
                _ipCountry = fields[1].GetString();

        } while (result->NextRow());

        if (banned)
        {
            TC_LOG_DEBUG("session", "%s tries to log in using banned IP!", GetClientInfo().c_str());
            CloseSocket();
            return;
        }
    }

    AsyncHandshake();
}
Ejemplo n.º 2
0
   void
   TCPConnection::ProcessOperationQueue_(int recurse_level)
   {
      if (recurse_level > 10)
      {
         throw std::logic_error(Formatter::FormatAsAnsi("Recurse level {0} was reached in TCPConnection::ProcessOperationQueue_ for session {1}", recurse_level, session_id_));
      }

      // Pick out the next item to process...
         std::shared_ptr<IOOperation> operation = operation_queue_.Front();

      if (!operation)
      {
         // We're no longer sending...
         return;
      }

      switch (operation->GetType())
      {
      case IOOperation::BCTHandshake:
        {
           AsyncHandshake();
           break;
        }
      case IOOperation::BCTWrite:
         {
               std::shared_ptr<ByteBuffer> pBuf = operation->GetBuffer();
            AsyncWrite(pBuf);
            break;
         }
      case IOOperation::BCTRead:
         {
            AsyncRead(operation->GetString());               
            break;
         }
      case IOOperation::BCTShutdownSend:
         {
            Shutdown(boost::asio::ip::tcp::socket::shutdown_send);
            operation_queue_.Pop(IOOperation::BCTShutdownSend);
            ProcessOperationQueue_(recurse_level + 1);
            break;
         }
      case IOOperation::BCTDisconnect:
         {
            Disconnect();
            operation_queue_.Pop(IOOperation::BCTDisconnect);
            ProcessOperationQueue_(recurse_level + 1);
            break;
         }

      }
   }