Show
Ignore:
Timestamp:
11/19/08 13:23:17 (17 years ago)
Author:
yumileroy
Message:

[svn] * Remove debugging code from WorldSocket?.cpp.
* Small cleanup fix in configure.ac.

Original author: derex_tri
Date: 2008-10-06 04:14:44-05:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/WorldSocket.cpp

    r6 r16  
    1919#include "Common.h" 
    2020#include "WorldSocket.h"  
     21 
    2122#include <ace/Message_Block.h> 
    2223#include <ace/OS_NS_string.h> 
     
    6869#endif 
    6970 
    70 // used when testing to alow login without password and encryption 
    71 // #define _NETCODE_FAKE_AUTH 
    72  
    7371WorldSocket::WorldSocket (void) : 
    7472WorldHandler (), 
     
    159157        { 
    160158          for (uint32 j = 0; j < 16 && p < pct.size (); j++) 
    161             sWorldLog.Log ("%.2X ", const_cast<WorldPacket&>(pct)[p++]); 
     159            sWorldLog.Log ("%.2X ", const_cast<WorldPacket&> (pct)[p++]); 
    162160 
    163161          sWorldLog.Log ("\n"); 
     
    312310  if (send_len == 0) 
    313311    return this->cancel_wakeup_output (Guard); 
    314    
    315 // TODO SO_NOSIGPIPE on platforms that support it 
     312 
     313  // TODO SO_NOSIGPIPE on platforms that support it 
    316314#ifdef MSG_NOSIGNAL 
    317315  ssize_t n = this->peer ().send (m_OutBuffer->rd_ptr (), send_len, MSG_NOSIGNAL); 
     
    319317  ssize_t n = this->peer ().send (m_OutBuffer->rd_ptr (), send_len); 
    320318#endif // MSG_NOSIGNAL 
    321            
     319 
    322320  if (n == 0) 
    323321    return -1; 
     
    426424  ACE_NEW_RETURN (m_RecvWPct, WorldPacket ((uint16) header.cmd, header.size), -1); 
    427425 
    428   if(header.size > 0) 
    429   { 
    430      m_RecvWPct->resize (header.size);   
    431      m_RecvPct.base ((char*) m_RecvWPct->contents (), m_RecvWPct->size ()); 
    432   } 
     426  if (header.size > 0) 
     427    { 
     428      m_RecvWPct->resize (header.size); 
     429      m_RecvPct.base ((char*) m_RecvWPct->contents (), m_RecvWPct->size ()); 
     430    } 
    433431  else 
    434   { 
    435      ACE_ASSERT(m_RecvPct.space() == 0); 
    436   } 
     432    { 
     433      ACE_ASSERT (m_RecvPct.space () == 0); 
     434    } 
    437435 
    438436 
     
    599597{ 
    600598  ACE_ASSERT (new_pct); 
    601    
     599 
    602600  // manage memory ;) 
    603601  ACE_Auto_Ptr<WorldPacket> aptr (new_pct); 
     
    713711             account.c_str (), 
    714712             clientSeed); 
    715  
    716 #if defined _NETCODE_FAKE_AUTH 
    717   bool dontchechtheacc = false; 
    718   uint8 digest_fake[sizeof (digest)]; 
    719   memset ((void*) digest_fake, '\0', sizeof (digest_fake)); 
    720   if (memcmp ((void*) digest, (void*) digest_fake, sizeof (digest_fake)) == 0) 
    721     { 
    722       dontchechtheacc = true; 
    723     } 
    724 #endif //_NETCODE_FAKE_AUTH 
    725713 
    726714  // Get the account information from the realmd database 
     
    786774  const char* vold = fields[6].GetString (); 
    787775 
    788   DEBUG_LOG ("WorldSocket::HandleAuthSession: (s,v) check s: %s v_old: %s v_new: %s", 
     776  DEBUG_LOG ("WorldSocket::HandleAuthSession: " 
     777             "(s,v) check s: %s v_old: %s v_new: %s", 
    789778             sStr, 
    790779             vold, 
     
    798787                          safe_account.c_str ()); 
    799788 
    800 #if defined _NETCODE_FAKE_AUTH 
    801   if (!dontchechtheacc) 
    802     { 
    803 #endif 
    804       if (!vold || strcmp (vStr, vold)) 
    805         { 
    806           packet.Initialize (SMSG_AUTH_RESPONSE, 1); 
    807           packet << uint8 (AUTH_UNKNOWN_ACCOUNT); 
    808           SendPacket (packet); 
    809           delete result; 
    810           OPENSSL_free ((void*) sStr); 
    811           OPENSSL_free ((void*) vStr); 
    812  
    813           sLog.outError ("WorldSocket::HandleAuthSession: User not logged."); 
    814           return -1; 
    815         } 
    816 #if defined _NETCODE_FAKE_AUTH 
    817     } 
    818 #endif 
     789  if (!vold || strcmp (vStr, vold)) 
     790    { 
     791      packet.Initialize (SMSG_AUTH_RESPONSE, 1); 
     792      packet << uint8 (AUTH_UNKNOWN_ACCOUNT); 
     793      SendPacket (packet); 
     794      delete result; 
     795      OPENSSL_free ((void*) sStr); 
     796      OPENSSL_free ((void*) vStr); 
     797 
     798      sLog.outBasic ("WorldSocket::HandleAuthSession: User not logged."); 
     799      return -1; 
     800    } 
    819801 
    820802  OPENSSL_free ((void*) sStr); 
     
    831813 
    832814          delete result; 
    833           sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (Account IP differs)."); 
     815          sLog.outBasic ("WorldSocket::HandleAuthSession: Sent Auth Response (Account IP differs)."); 
    834816          return -1; 
    835817        } 
     
    848830  delete result; 
    849831 
    850 #if defined _NETCODE_FAKE_AUTH 
    851   if (!dontchechtheacc) 
    852     { 
    853 #endif 
    854       // Re-check account ban (same check as in realmd)  
    855       QueryResult *banresult = 
    856               loginDatabase.PQuery ("SELECT " 
    857                                     "bandate, " 
    858                                     "unbandate " 
    859                                     "FROM account_banned " 
    860                                     "WHERE id = '%u' " 
    861                                     "AND active = 1", 
    862                                     id); 
    863  
    864       if (banresult) // if account banned 
    865         { 
    866           packet.Initialize (SMSG_AUTH_RESPONSE, 1); 
    867           packet << uint8 (AUTH_BANNED); 
    868           SendPacket (packet); 
    869  
    870           delete banresult; 
    871  
    872           sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (Account banned)."); 
    873           return -1; 
    874         } 
    875  
    876       // Check locked state for server 
    877       AccountTypes allowedAccountType = sWorld.GetPlayerSecurityLimit (); 
    878  
    879       if (allowedAccountType > SEC_PLAYER && security < allowedAccountType) 
    880         { 
    881           WorldPacket Packet (SMSG_AUTH_RESPONSE, 1); 
    882           Packet << uint8 (AUTH_UNAVAILABLE); 
    883  
    884           SendPacket (packet); 
    885  
    886           sLog.outBasic ("WorldSocket::HandleAuthSession: User tryes to login but his security level is not enough"); 
    887           return -1; 
    888         } 
    889  
    890       // Check that Key and account name are the same on client and server 
    891       Sha1Hash sha; 
    892  
    893       uint32 t = 0; 
    894       uint32 seed = m_Seed; 
    895  
    896       sha.UpdateData (account); 
    897       sha.UpdateData ((uint8 *) & t, 4); 
    898       sha.UpdateData ((uint8 *) & clientSeed, 4); 
    899       sha.UpdateData ((uint8 *) & seed, 4); 
    900       sha.UpdateBigNumbers (&K, NULL); 
    901       sha.Finalize (); 
    902  
    903       if (memcmp (sha.GetDigest (), digest, 20)) 
    904         { 
    905           packet.Initialize (SMSG_AUTH_RESPONSE, 1); 
    906           packet << uint8 (AUTH_FAILED); 
    907  
    908           SendPacket (packet); 
    909  
    910           sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (authentification failed)."); 
    911           return -1; 
    912         } 
    913 #if defined _NETCODE_FAKE_AUTH 
    914     } 
    915 #endif 
     832  // Re-check account ban (same check as in realmd)  
     833  QueryResult *banresult = 
     834          loginDatabase.PQuery ("SELECT " 
     835                                "bandate, " 
     836                                "unbandate " 
     837                                "FROM account_banned " 
     838                                "WHERE id = '%u' " 
     839                                "AND active = 1", 
     840                                id); 
     841 
     842  if (banresult) // if account banned 
     843    { 
     844      packet.Initialize (SMSG_AUTH_RESPONSE, 1); 
     845      packet << uint8 (AUTH_BANNED); 
     846      SendPacket (packet); 
     847 
     848      delete banresult; 
     849 
     850      sLog.outBasic ("WorldSocket::HandleAuthSession: Sent Auth Response (Account banned)."); 
     851      return -1; 
     852    } 
     853 
     854  // Check locked state for server 
     855  AccountTypes allowedAccountType = sWorld.GetPlayerSecurityLimit (); 
     856 
     857  if (allowedAccountType > SEC_PLAYER && security < allowedAccountType) 
     858    { 
     859      WorldPacket Packet (SMSG_AUTH_RESPONSE, 1); 
     860      Packet << uint8 (AUTH_UNAVAILABLE); 
     861 
     862      SendPacket (packet); 
     863 
     864      sLog.outBasic ("WorldSocket::HandleAuthSession: User tryes to login but his security level is not enough"); 
     865      return -1; 
     866    } 
     867 
     868  // Check that Key and account name are the same on client and server 
     869  Sha1Hash sha; 
     870 
     871  uint32 t = 0; 
     872  uint32 seed = m_Seed; 
     873 
     874  sha.UpdateData (account); 
     875  sha.UpdateData ((uint8 *) & t, 4); 
     876  sha.UpdateData ((uint8 *) & clientSeed, 4); 
     877  sha.UpdateData ((uint8 *) & seed, 4); 
     878  sha.UpdateBigNumbers (&K, NULL); 
     879  sha.Finalize (); 
     880 
     881  if (memcmp (sha.GetDigest (), digest, 20)) 
     882    { 
     883      packet.Initialize (SMSG_AUTH_RESPONSE, 1); 
     884      packet << uint8 (AUTH_FAILED); 
     885 
     886      SendPacket (packet); 
     887 
     888      sLog.outBasic ("WorldSocket::HandleAuthSession: Sent Auth Response (authentification failed)."); 
     889      return -1; 
     890    } 
    916891 
    917892  std::string address = this->GetRemoteAddress (); 
     
    935910  ACE_NEW_RETURN (m_Session, WorldSession (id, this, security, tbc, mutetime, locale), -1); 
    936911 
    937 #if defined _NETCODE_FAKE_AUTH 
    938   if (!dontchechtheacc) 
    939     { 
    940 #endif 
    941       this->m_Crypt.SetKey (&K); 
    942       this->m_Crypt.Init (); 
    943 #if defined _NETCODE_FAKE_AUTH 
    944     } 
    945 #endif 
     912  m_Crypt.SetKey (&K); 
     913  m_Crypt.Init (); 
    946914 
    947915  // In case needed sometime the second arg is in microseconds 1 000 000 = 1 sec 
     
    10441012  header.cmd = ACE_SWAP_WORD (header.cmd) 
    10451013#endif 
    1046            
    1047   header.size = (uint16) pct.size () + 2; 
     1014 
     1015          header.size = (uint16) pct.size () + 2; 
    10481016  header.size = ACE_HTONS (header.size); 
    10491017