diff options
Diffstat (limited to 'src/server/authserver')
| -rwxr-xr-x | src/server/authserver/Server/AuthSocket.cpp | 37 | ||||
| -rwxr-xr-x | src/server/authserver/Server/RealmSocket.cpp | 14 | ||||
| -rwxr-xr-x | src/server/authserver/Server/RealmSocket.h | 7 | 
3 files changed, 35 insertions, 23 deletions
diff --git a/src/server/authserver/Server/AuthSocket.cpp b/src/server/authserver/Server/AuthSocket.cpp index 1f85cb6bc5b..6d295a0bbee 100755 --- a/src/server/authserver/Server/AuthSocket.cpp +++ b/src/server/authserver/Server/AuthSocket.cpp @@ -209,7 +209,7 @@ AuthSocket::~AuthSocket(void) {}  // Accept the connection and set the s random value for SRP6  void AuthSocket::OnAccept(void)  { -    sLog->outBasic("Accepting connection from '%s'", socket().get_remote_address().c_str()); +    sLog->outBasic("'%s:%d' Accepting connection", socket().getRemoteAddress().c_str(), socket().getRemotePort());  }  void AuthSocket::OnClose(void) @@ -247,7 +247,7 @@ void AuthSocket::OnRead()          // Report unknown packets in the error log          if (i == AUTH_TOTAL_COMMANDS)          { -            sLog->outError("[Auth] got unknown packet from '%s'", socket().get_remote_address().c_str()); +            sLog->outError("[Auth] got unknown packet from '%s'", socket().getRemoteAddress().c_str());              socket().shutdown();              return;          } @@ -350,14 +350,14 @@ bool AuthSocket::_HandleLogonChallenge()      // Verify that this IP is not in the ip_banned table      LoginDatabase.Execute(LoginDatabase.GetPreparedStatement(LOGIN_DEL_EXPIRED_IP_BANS)); -    const std::string& ip_address = socket().get_remote_address(); +    const std::string& ip_address = socket().getRemoteAddress();      PreparedStatement *stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_BANNED);      stmt->setString(0, ip_address);      PreparedQueryResult result = LoginDatabase.Query(stmt);      if (result)      {          pkt << (uint8)WOW_FAIL_BANNED; -        sLog->outBasic("[AuthChallenge] Banned ip %s tried to login!", ip_address.c_str()); +        sLog->outBasic("'%s:%d' [AuthChallenge] Banned ip tries to login!",socket().getRemoteAddress().c_str(), socket().getRemotePort());      }      else      { @@ -404,12 +404,12 @@ bool AuthSocket::_HandleLogonChallenge()                      if ((*banresult)[0].GetUInt64() == (*banresult)[1].GetUInt64())                      {                          pkt << (uint8)WOW_FAIL_BANNED; -                        sLog->outBasic("[AuthChallenge] Banned account %s tried to login!", _login.c_str()); +                        sLog->outBasic("'%s:%d' [AuthChallenge] Banned account %s tried to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());                      }                      else                      {                          pkt << (uint8)WOW_FAIL_SUSPENDED; -                        sLog->outBasic("[AuthChallenge] Temporarily banned account %s tried to login!", _login.c_str()); +                        sLog->outBasic("'%s:%d' [AuthChallenge] Temporarily banned account %s tried to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());                      }                  }                  else @@ -480,7 +480,9 @@ bool AuthSocket::_HandleLogonChallenge()                      for (int i = 0; i < 4; ++i)                          _localizationName[i] = ch->country[4-i-1]; -                    sLog->outBasic("[AuthChallenge] account %s is using '%c%c%c%c' locale (%u)", _login.c_str (), ch->country[3], ch->country[2], ch->country[1], ch->country[0], GetLocaleByName(_localizationName)); +                    sLog->outBasic("'%s:%d' [AuthChallenge] account %s is using '%c%c%c%c' locale (%u)", socket().getRemoteAddress().c_str(), socket().getRemotePort(), +                            _login.c_str (), ch->country[3], ch->country[2], ch->country[1], ch->country[0], GetLocaleByName(_localizationName) +                        );                  }              }          } @@ -590,7 +592,7 @@ bool AuthSocket::_HandleLogonProof()      // Check if SRP6 results match (password is correct), else send an error      if (!memcmp(M.AsByteArray(), lp.M1, 20))      { -        sLog->outBasic("User '%s' successfully authenticated", _login.c_str()); +        sLog->outBasic("'%s:%d' User '%s' successfully authenticated", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());          // Update the sessionkey, last_ip, last login time and reset number of failed logins in the account table for this account          // No SQL injection (escaped user name) and IP address as received by socket @@ -598,7 +600,7 @@ bool AuthSocket::_HandleLogonProof()          PreparedStatement *stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LOGONPROOF);          stmt->setString(0, K_hex); -        stmt->setString(1, socket().get_remote_address().c_str()); +        stmt->setString(1, socket().getRemoteAddress().c_str());          stmt->setUInt32(2, GetLocaleByName(_localizationName));          stmt->setString(3, _login);          LoginDatabase.Execute(stmt); @@ -638,7 +640,7 @@ bool AuthSocket::_HandleLogonProof()          char data[4] = { AUTH_LOGON_PROOF, WOW_FAIL_UNKNOWN_ACCOUNT, 3, 0 };          socket().send(data, sizeof(data)); -        sLog->outBasic("[AuthChallenge] account %s tried to login with wrong password!", _login.c_str()); +        sLog->outBasic("'%s:%d' [AuthChallenge] account %s tried to login with invalid password!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());          uint32 MaxWrongPassCount = ConfigMgr::GetIntDefault("WrongPass.MaxCount", 0);          if (MaxWrongPassCount > 0) @@ -668,17 +670,18 @@ bool AuthSocket::_HandleLogonProof()                          stmt->setUInt32(1, WrongPassBanTime);                          LoginDatabase.Execute(stmt); -                        sLog->outBasic("[AuthChallenge] account %s got banned for '%u' seconds because it failed to authenticate '%u' times", -                            _login.c_str(), WrongPassBanTime, failed_logins); +                        sLog->outBasic("'%s:%d' [AuthChallenge] account %s got banned for '%u' seconds because it failed to authenticate '%u' times", +                            socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str(), WrongPassBanTime, failed_logins);                      }                      else                      {                          stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_IP_AUTO_BANNED); -                        stmt->setString(0, socket().get_remote_address()); +                        stmt->setString(0, socket().getRemoteAddress());                          stmt->setUInt32(1, WrongPassBanTime);                          LoginDatabase.Execute(stmt); -                        sLog->outBasic("[AuthChallenge] IP %s got banned for '%u' seconds because account %s failed to authenticate '%u' times", socket().get_remote_address().c_str(), WrongPassBanTime, _login.c_str(), failed_logins); +                        sLog->outBasic("'%s:%d' [AuthChallenge] IP %s got banned for '%u' seconds because account %s failed to authenticate '%u' times", +                            socket().getRemoteAddress().c_str(), socket().getRemotePort(), socket().getRemoteAddress().c_str(), WrongPassBanTime, _login.c_str(), failed_logins);                      }                  }              } @@ -730,7 +733,7 @@ bool AuthSocket::_HandleReconnectChallenge()      // Stop if the account is not found      if (!result)      { -        sLog->outError("[ERROR] user %s tried to login and we cannot find his session key in the database.", _login.c_str()); +        sLog->outError("'%s:%d' [ERROR] user %s tried to login and we cannot find his session key in the database.", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());          socket().shutdown();          return false;      } @@ -790,7 +793,7 @@ bool AuthSocket::_HandleReconnectProof()      }      else      { -        sLog->outError("[ERROR] user %s tried to login, but session invalid.", _login.c_str()); +        sLog->outError("'%s:%d' [ERROR] user %s tried to login, but session is invalid.", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());          socket().shutdown();          return false;      } @@ -812,7 +815,7 @@ bool AuthSocket::_HandleRealmList()      PreparedQueryResult result = LoginDatabase.Query(stmt);      if (!result)      { -        sLog->outError("[ERROR] user %s tried to login and we cannot find him in the database.", _login.c_str()); +        sLog->outError("'%s:%d' [ERROR] user %s tried to login but we cannot find him in the database.", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());          socket().shutdown();          return false;      } diff --git a/src/server/authserver/Server/RealmSocket.cpp b/src/server/authserver/Server/RealmSocket.cpp index a796daae17d..72c36fc6646 100755 --- a/src/server/authserver/Server/RealmSocket.cpp +++ b/src/server/authserver/Server/RealmSocket.cpp @@ -31,7 +31,7 @@ RealmSocket::Session::Session(void) {}  RealmSocket::Session::~Session(void) { } -RealmSocket::RealmSocket(void) : input_buffer_(4096), session_(NULL), remote_address_() +RealmSocket::RealmSocket(void) : input_buffer_(4096), session_(NULL), _remoteAddress()  {      reference_counting_policy().value(ACE_Event_Handler::Reference_Counting_Policy::ENABLED); @@ -63,7 +63,8 @@ int RealmSocket::open(void * arg)          return -1;      } -    remote_address_ = addr.get_host_addr(); +    _remoteAddress = addr.get_host_addr(); +    _remotePort = addr.get_port_number();      // Register with ACE Reactor      if (Base::open(arg) == -1) @@ -89,9 +90,14 @@ int RealmSocket::close(int)      return 0;  } -const std::string& RealmSocket::get_remote_address(void) const +const std::string& RealmSocket::getRemoteAddress(void) const  { -    return remote_address_; +    return _remoteAddress; +} + +const uint16 RealmSocket::getRemotePort(void) const +{ +    return _remotePort;  }  size_t RealmSocket::recv_len(void) const diff --git a/src/server/authserver/Server/RealmSocket.h b/src/server/authserver/Server/RealmSocket.h index c532f016dcb..9682b5e4559 100755 --- a/src/server/authserver/Server/RealmSocket.h +++ b/src/server/authserver/Server/RealmSocket.h @@ -52,7 +52,9 @@ public:      bool send(const char *buf, size_t len); -    const std::string& get_remote_address(void) const; +    const std::string& getRemoteAddress(void) const; + +    const uint16 getRemotePort(void) const;      virtual int open(void *); @@ -70,7 +72,8 @@ private:      ACE_Message_Block input_buffer_;      Session* session_; -    std::string remote_address_; +    std::string _remoteAddress; +    uint16 _remotePort;  };  #endif /* __REALMSOCKET_H__ */  | 
