mirror of
https://github.com/EQEmu/Server.git
synced 2026-09-02 20:56:37 +00:00
Legacy connection wip
This commit is contained in:
+60
-27
@@ -40,13 +40,14 @@ extern uint32 numzones;
|
||||
extern uint32 numplayers;
|
||||
extern volatile bool RunLoops;
|
||||
|
||||
LoginServer::LoginServer(const char* iAddress, uint16 iPort, const char* Account, const char* Password)
|
||||
LoginServer::LoginServer(const char* iAddress, uint16 iPort, const char* Account, const char* Password, bool legacy)
|
||||
{
|
||||
strn0cpy(LoginServerAddress,iAddress,256);
|
||||
LoginServerPort = iPort;
|
||||
strn0cpy(LoginAccount,Account,31);
|
||||
strn0cpy(LoginPassword,Password,31);
|
||||
CanAccountUpdate = false;
|
||||
IsLegacy = legacy;
|
||||
Connect();
|
||||
}
|
||||
|
||||
@@ -176,32 +177,65 @@ bool LoginServer::Connect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
client.reset(new EQ::Net::ServertalkClient(LoginServerAddress, LoginServerPort, false, "World", ""));
|
||||
client->OnConnect([this](EQ::Net::ServertalkClient *client) {
|
||||
if (client) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Connected to Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
if (minilogin)
|
||||
SendInfo();
|
||||
else
|
||||
SendNewInfo();
|
||||
SendStatus();
|
||||
zoneserver_list.SendLSZones();
|
||||
|
||||
statusupdate_timer.reset(new EQ::Timer(LoginServer_StatusUpdateInterval, true, [this](EQ::Timer *t) {
|
||||
if (IsLegacy) {
|
||||
legacy_client.reset(new EQ::Net::ServertalkLegacyClient(LoginServerAddress, LoginServerPort, false));
|
||||
legacy_client->OnConnect([this](EQ::Net::ServertalkLegacyClient *client) {
|
||||
if (client) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Connected to Legacy Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
if (minilogin)
|
||||
SendInfo();
|
||||
else
|
||||
SendNewInfo();
|
||||
SendStatus();
|
||||
}));
|
||||
}
|
||||
else {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Could not connect to Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
}
|
||||
});
|
||||
zoneserver_list.SendLSZones();
|
||||
|
||||
client->OnMessage(ServerOP_UsertoWorldReq, std::bind(&LoginServer::ProcessUsertoWorldReq, this, std::placeholders::_1, std::placeholders::_2));
|
||||
client->OnMessage(ServerOP_LSClientAuth, std::bind(&LoginServer::ProcessLSClientAuth, this, std::placeholders::_1, std::placeholders::_2));
|
||||
client->OnMessage(ServerOP_LSFatalError, std::bind(&LoginServer::ProcessLSFatalError, this, std::placeholders::_1, std::placeholders::_2));
|
||||
client->OnMessage(ServerOP_SystemwideMessage, std::bind(&LoginServer::ProcessSystemwideMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
client->OnMessage(ServerOP_LSRemoteAddr, std::bind(&LoginServer::ProcessLSRemoteAddr, this, std::placeholders::_1, std::placeholders::_2));
|
||||
client->OnMessage(ServerOP_LSAccountUpdate, std::bind(&LoginServer::ProcessLSAccountUpdate, this, std::placeholders::_1, std::placeholders::_2));
|
||||
statusupdate_timer.reset(new EQ::Timer(LoginServer_StatusUpdateInterval, true, [this](EQ::Timer *t) {
|
||||
SendStatus();
|
||||
}));
|
||||
}
|
||||
else {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Could not connect to Legacy Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
}
|
||||
});
|
||||
|
||||
legacy_client->OnMessage(ServerOP_UsertoWorldReq, std::bind(&LoginServer::ProcessUsertoWorldReq, this, std::placeholders::_1, std::placeholders::_2));
|
||||
legacy_client->OnMessage(ServerOP_LSClientAuth, std::bind(&LoginServer::ProcessLSClientAuth, this, std::placeholders::_1, std::placeholders::_2));
|
||||
legacy_client->OnMessage(ServerOP_LSFatalError, std::bind(&LoginServer::ProcessLSFatalError, this, std::placeholders::_1, std::placeholders::_2));
|
||||
legacy_client->OnMessage(ServerOP_SystemwideMessage, std::bind(&LoginServer::ProcessSystemwideMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
legacy_client->OnMessage(ServerOP_LSRemoteAddr, std::bind(&LoginServer::ProcessLSRemoteAddr, this, std::placeholders::_1, std::placeholders::_2));
|
||||
legacy_client->OnMessage(ServerOP_LSAccountUpdate, std::bind(&LoginServer::ProcessLSAccountUpdate, this, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
}
|
||||
else {
|
||||
client.reset(new EQ::Net::ServertalkClient(LoginServerAddress, LoginServerPort, false, "World", ""));
|
||||
client->OnConnect([this](EQ::Net::ServertalkClient *client) {
|
||||
if (client) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Connected to Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
if (minilogin)
|
||||
SendInfo();
|
||||
else
|
||||
SendNewInfo();
|
||||
SendStatus();
|
||||
zoneserver_list.SendLSZones();
|
||||
|
||||
statusupdate_timer.reset(new EQ::Timer(LoginServer_StatusUpdateInterval, true, [this](EQ::Timer *t) {
|
||||
SendStatus();
|
||||
}));
|
||||
}
|
||||
else {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Could not connect to Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
}
|
||||
});
|
||||
|
||||
client->OnMessage(ServerOP_UsertoWorldReq, std::bind(&LoginServer::ProcessUsertoWorldReq, this, std::placeholders::_1, std::placeholders::_2));
|
||||
client->OnMessage(ServerOP_LSClientAuth, std::bind(&LoginServer::ProcessLSClientAuth, this, std::placeholders::_1, std::placeholders::_2));
|
||||
client->OnMessage(ServerOP_LSFatalError, std::bind(&LoginServer::ProcessLSFatalError, this, std::placeholders::_1, std::placeholders::_2));
|
||||
client->OnMessage(ServerOP_SystemwideMessage, std::bind(&LoginServer::ProcessSystemwideMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
client->OnMessage(ServerOP_LSRemoteAddr, std::bind(&LoginServer::ProcessLSRemoteAddr, this, std::placeholders::_1, std::placeholders::_2));
|
||||
client->OnMessage(ServerOP_LSAccountUpdate, std::bind(&LoginServer::ProcessLSAccountUpdate, this, std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
void LoginServer::SendInfo() {
|
||||
const WorldConfig *Config=WorldConfig::get();
|
||||
@@ -223,7 +257,6 @@ void LoginServer::SendInfo() {
|
||||
}
|
||||
|
||||
void LoginServer::SendNewInfo() {
|
||||
uint16 port;
|
||||
const WorldConfig *Config=WorldConfig::get();
|
||||
|
||||
auto pack = new ServerPacket;
|
||||
@@ -243,7 +276,7 @@ void LoginServer::SendNewInfo() {
|
||||
if (Config->LocalAddress.length())
|
||||
strcpy(lsi->local_address, Config->LocalAddress.c_str());
|
||||
else {
|
||||
WorldConfig::SetLocalAddress(client->Handle()->LocalIP());
|
||||
WorldConfig::SetLocalAddress(IsLegacy ? legacy_client->Handle()->LocalIP() : client->Handle()->LocalIP());
|
||||
}
|
||||
SendPacket(pack);
|
||||
delete pack;
|
||||
|
||||
@@ -25,12 +25,13 @@
|
||||
#include "../common/eq_packet_structs.h"
|
||||
#include "../common/mutex.h"
|
||||
#include "../common/net/servertalk_client_connection.h"
|
||||
#include "../common/net/servertalk_legacy_client_connection.h"
|
||||
#include "../common/event/timer.h"
|
||||
#include <memory>
|
||||
|
||||
class LoginServer{
|
||||
public:
|
||||
LoginServer(const char*, uint16, const char*, const char*);
|
||||
LoginServer(const char*, uint16, const char*, const char*, bool legacy);
|
||||
~LoginServer();
|
||||
|
||||
bool Connect();
|
||||
@@ -39,9 +40,9 @@ public:
|
||||
void SendNewInfo();
|
||||
void SendStatus();
|
||||
|
||||
void SendPacket(ServerPacket* pack) { client->SendPacket(pack); }
|
||||
void SendPacket(ServerPacket* pack) { if (IsLegacy) legacy_client->SendPacket(pack); else client->SendPacket(pack); }
|
||||
void SendAccountUpdate(ServerPacket* pack);
|
||||
bool Connected() { return client->Connected(); }
|
||||
bool Connected() { return IsLegacy ? legacy_client->Connected() : client->Connected(); }
|
||||
bool MiniLogin() { return minilogin; }
|
||||
bool CanUpdate() { return CanAccountUpdate; }
|
||||
|
||||
@@ -55,6 +56,7 @@ private:
|
||||
|
||||
bool minilogin;
|
||||
std::unique_ptr<EQ::Net::ServertalkClient> client;
|
||||
std::unique_ptr<EQ::Net::ServertalkLegacyClient> legacy_client;
|
||||
std::unique_ptr<EQ::Timer> statusupdate_timer;
|
||||
char LoginServerAddress[256];
|
||||
uint32 LoginServerIP;
|
||||
@@ -62,5 +64,6 @@ private:
|
||||
char LoginAccount[32];
|
||||
char LoginPassword[32];
|
||||
bool CanAccountUpdate;
|
||||
bool IsLegacy;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -49,9 +49,9 @@ LoginServerList::LoginServerList() {
|
||||
LoginServerList::~LoginServerList() {
|
||||
}
|
||||
|
||||
void LoginServerList::Add(const char* iAddress, uint16 iPort, const char* Account, const char* Password)
|
||||
void LoginServerList::Add(const char* iAddress, uint16 iPort, const char* Account, const char* Password, bool Legacy)
|
||||
{
|
||||
auto loginserver = new LoginServer(iAddress, iPort, Account, Password);
|
||||
auto loginserver = new LoginServer(iAddress, iPort, Account, Password, Legacy);
|
||||
list.Insert(loginserver);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
LoginServerList();
|
||||
~LoginServerList();
|
||||
|
||||
void Add(const char*, uint16, const char*, const char*);
|
||||
void Add(const char*, uint16, const char*, const char*, bool);
|
||||
|
||||
bool SendInfo();
|
||||
bool SendNewInfo();
|
||||
|
||||
+3
-2
@@ -158,7 +158,7 @@ int main(int argc, char** argv) {
|
||||
// add login server config to list
|
||||
if (Config->LoginCount == 0) {
|
||||
if (Config->LoginHost.length()) {
|
||||
loginserverlist.Add(Config->LoginHost.c_str(), Config->LoginPort, Config->LoginAccount.c_str(), Config->LoginPassword.c_str());
|
||||
loginserverlist.Add(Config->LoginHost.c_str(), Config->LoginPort, Config->LoginAccount.c_str(), Config->LoginPassword.c_str(), Config->LoginLegacy);
|
||||
Log.Out(Logs::General, Logs::World_Server, "Added loginserver %s:%i", Config->LoginHost.c_str(), Config->LoginPort);
|
||||
}
|
||||
} else {
|
||||
@@ -166,7 +166,8 @@ int main(int argc, char** argv) {
|
||||
LinkedListIterator<LoginConfig*> iterator(loginlist);
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
loginserverlist.Add(iterator.GetData()->LoginHost.c_str(), iterator.GetData()->LoginPort, iterator.GetData()->LoginAccount.c_str(), iterator.GetData()->LoginPassword.c_str());
|
||||
loginserverlist.Add(iterator.GetData()->LoginHost.c_str(), iterator.GetData()->LoginPort, iterator.GetData()->LoginAccount.c_str(), iterator.GetData()->LoginPassword.c_str(),
|
||||
iterator.GetData()->LoginLegacy);
|
||||
Log.Out(Logs::General, Logs::World_Server, "Added loginserver %s:%i", iterator.GetData()->LoginHost.c_str(), iterator.GetData()->LoginPort);
|
||||
iterator.Advance();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user