Streamline worldserver authorization handlers, cleanup and refactoring

This commit is contained in:
Akkadius
2019-07-08 20:25:37 -05:00
parent c2917a9004
commit d8f34651de
9 changed files with 766 additions and 392 deletions
+59 -11
View File
@@ -25,6 +25,7 @@
#include "../common/net/servertalk_server_connection.h"
#include "../common/servertalk.h"
#include "../common/packet_dump.h"
#include "database.h"
#include <string>
#include <memory>
@@ -51,10 +52,18 @@ public:
*/
std::shared_ptr<EQ::Net::ServertalkServerConnection> GetConnection() { return connection; }
void SetConnection(std::shared_ptr<EQ::Net::ServertalkServerConnection> c) { connection = c; }
unsigned int GetRuntimeID() const { return runtime_id; }
void SetRuntimeID(unsigned int id) { runtime_id = id; }
std::string GetLongName() const { return long_name; }
std::string GetShortName() const { return short_name; }
/**
* @return
*/
unsigned int GetServerId() const { return server_id; }
WorldServer * SetServerId(unsigned int id) { server_id = id; return this; }
/**
* @return
*/
std::string GetServerLongName() const { return long_name; }
std::string GetServerShortName() const { return short_name; }
/**
* Gets whether the server is authorized to show up on the server list or not
@@ -62,14 +71,16 @@ public:
*/
bool IsAuthorized() const { return is_server_authorized; }
std::string GetLocalIP() const { return local_ip; }
std::string GetRemoteIP() const { return remote_ip; }
std::string GetRemoteIP() const { return remote_ip_address; }
/**
* Gets what kind of server this server is (legends, preferred, normal)
*
* @return
*/
unsigned int GetServerListID() const { return server_list_id; }
unsigned int GetServerListID() const { return server_list_type_id; }
WorldServer * SetServerListTypeId(unsigned int in_server_list_id);
int GetStatus() const { return server_status; }
unsigned int GetZonesBooted() const { return zones_booted; }
unsigned int GetPlayersOnline() const { return players_online; }
@@ -88,6 +99,8 @@ public:
*/
void Handle_LSStatus(ServerLSStatus_Struct *server_login_status);
bool HandleNewLoginserverInfoValidation(ServerNewLSInfo_Struct *new_world_server_info_packet);
/**
* Informs world that there is a client incoming with the following data.
*
@@ -99,6 +112,40 @@ public:
*/
void SendClientAuth(std::string ip, std::string account, std::string key, unsigned int account_id, const std::string &loginserver_name);
WorldServer * SetZonesBooted(unsigned int in_zones_booted);
WorldServer * SetPlayersOnline(unsigned int in_players_online);
WorldServer * SetServerStatus(int in_server_status);
WorldServer * SetServerProcessType(unsigned int in_server_process_type);
WorldServer * SetLongName(const std::string &in_long_name);
WorldServer * SetShortName(const std::string &in_short_name);
WorldServer * SetAccountName(const std::string &in_account_name);
WorldServer * SetAccountPassword(const std::string &in_account_password);
WorldServer * SetRemoteIp(const std::string &in_remote_ip);
WorldServer * SetLocalIp(const std::string &in_local_ip);
WorldServer * SetProtocol(const std::string &in_protocol);
WorldServer * SetVersion(const std::string &in_version);
WorldServer * SetServerDescription(const std::string &in_server_description);
WorldServer * SetIsServerAuthorized(bool in_is_server_authorized);
WorldServer * SetIsServerLoggedIn(bool in_is_server_logged_in);
WorldServer * SetIsServerTrusted(bool in_is_server_trusted);
bool IsServerAuthorized() const;
bool IsServerLoggedIn() const;
bool IsServerTrusted() const;
const std::string &GetAccountName() const;
const std::string &GetAccountPassword() const;
const std::string &GetLocalIp() const;
const std::string &GetProtocol() const;
const std::string &GetRemoteIp() const;
const std::string &GetServerDescription() const;
const std::string &GetVersion() const;
int GetServerStatus() const;
unsigned int GetServerListTypeId() const;
unsigned int GetServerProcessType() const;
bool HandleNewLoginserverRegisteredOnly(Database::DbWorldRegistration &world_registration);
bool HandleNewLoginserverInfoUnregisteredAllowed(Database::DbWorldRegistration &world_registration);
private:
/**
@@ -117,21 +164,22 @@ private:
unsigned int zones_booted;
unsigned int players_online;
int server_status;
unsigned int runtime_id;
unsigned int server_list_id;
unsigned int server_type;
std::string desc;
unsigned int server_id;
unsigned int server_list_type_id;
unsigned int server_process_type;
std::string server_description;
std::string long_name;
std::string short_name;
std::string account_name;
std::string account_password;
std::string remote_ip;
std::string remote_ip_address;
std::string local_ip;
std::string protocol;
std::string version;
bool is_server_authorized;
bool is_server_logged_in;
bool is_server_trusted;
};
#endif