mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-18 11:21:29 +00:00
[Loginserver] Add some resiliency to LS requests (#1663)
This commit is contained in:
parent
9af7122b1d
commit
05782433b8
@ -280,6 +280,8 @@ bool AccountManagement::UpdateLoginserverWorldAdminAccountPasswordById(
|
||||
return updated_account;
|
||||
}
|
||||
|
||||
constexpr int REQUEST_TIMEOUT_MS = 1500;
|
||||
|
||||
/**
|
||||
* @param in_account_username
|
||||
* @param in_account_password
|
||||
@ -386,8 +388,16 @@ uint32 AccountManagement::CheckExternalLoginserverUserCredentials(
|
||||
}
|
||||
);
|
||||
|
||||
std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
|
||||
|
||||
auto &loop = EQ::EventLoop::Get();
|
||||
while (running) {
|
||||
std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
|
||||
if (std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count() > REQUEST_TIMEOUT_MS) {
|
||||
LogInfo("[CheckExternalLoginserverUserCredentials] Deadline exceeded [{}]", REQUEST_TIMEOUT_MS);
|
||||
running = false;
|
||||
}
|
||||
|
||||
loop.Process();
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/string_util.h"
|
||||
#include "encryption.h"
|
||||
#include "account_management.h"
|
||||
|
||||
extern LoginServer server;
|
||||
|
||||
@ -375,61 +376,20 @@ void Client::AttemptLoginAccountCreation(
|
||||
return;
|
||||
}
|
||||
|
||||
if (server.options.GetEQEmuLoginServerAddress().length() == 0) {
|
||||
DoFailedLogin();
|
||||
uint32 account_id = AccountManagement::CheckExternalLoginserverUserCredentials(
|
||||
user,
|
||||
pass
|
||||
);
|
||||
|
||||
if (account_id > 0) {
|
||||
LogInfo("[AttemptLoginAccountCreation] Found and creating eqemu account [{}]", account_id);
|
||||
CreateEQEmuAccount(user, pass, account_id);
|
||||
return;
|
||||
}
|
||||
|
||||
auto addr_components = SplitString(server.options.GetEQEmuLoginServerAddress(), ':');
|
||||
if (addr_components.size() != 2) {
|
||||
DoFailedLogin();
|
||||
return;
|
||||
}
|
||||
|
||||
m_stored_user = user;
|
||||
m_stored_pass = pass;
|
||||
|
||||
auto address = addr_components[0];
|
||||
auto port = std::stoi(addr_components[1]);
|
||||
EQ::Net::DNSLookup(
|
||||
address, port, false, [=](const std::string &addr) {
|
||||
if (addr.empty()) {
|
||||
DoFailedLogin();
|
||||
return;
|
||||
}
|
||||
|
||||
m_login_connection_manager.reset(new EQ::Net::DaybreakConnectionManager());
|
||||
m_login_connection_manager->OnNewConnection(
|
||||
std::bind(
|
||||
&Client::LoginOnNewConnection,
|
||||
this,
|
||||
std::placeholders::_1
|
||||
)
|
||||
);
|
||||
m_login_connection_manager->OnConnectionStateChange(
|
||||
std::bind(
|
||||
&Client::LoginOnStatusChange,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
std::placeholders::_3
|
||||
)
|
||||
);
|
||||
m_login_connection_manager->OnPacketRecv(
|
||||
std::bind(
|
||||
&Client::LoginOnPacketRecv,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
)
|
||||
);
|
||||
|
||||
m_login_connection_manager->Connect(addr, port);
|
||||
}
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (server.options.CanAutoCreateAccounts() && loginserver == "local") {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user