mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 22:01:30 +00:00
Fix bug with command length
This commit is contained in:
parent
5fce042a31
commit
ea15e9bc5f
@ -148,10 +148,10 @@ namespace EQEmuCommand {
|
|||||||
int max_command_length = 0;
|
int max_command_length = 0;
|
||||||
|
|
||||||
for (auto &it: in_function_map) {
|
for (auto &it: in_function_map) {
|
||||||
if (it.first.length() > max_command_length) {
|
|
||||||
std::stringstream command;
|
std::stringstream command;
|
||||||
command << termcolor::colorize << termcolor::yellow << it.first << termcolor::reset;
|
command << termcolor::colorize << termcolor::yellow << it.first << termcolor::reset;
|
||||||
max_command_length = command.str().length() + 5;
|
if (command.str().length() > max_command_length) {
|
||||||
|
max_command_length = command.str().length() + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -243,19 +243,30 @@ bool AccountManagement::UpdateLoginserverUserCredentials(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AccountManagement::CheckExternalLoginserverUserCredentials(const std::string &in_account_username, const std::string &in_account_password)
|
bool AccountManagement::CheckExternalLoginserverUserCredentials(
|
||||||
|
const std::string &in_account_username,
|
||||||
|
const std::string &in_account_password
|
||||||
|
)
|
||||||
{
|
{
|
||||||
auto res = task_runner.Enqueue([&]() -> bool {
|
auto res = task_runner.Enqueue(
|
||||||
|
[&]() -> bool {
|
||||||
bool running = true;
|
bool running = true;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
EQ::Net::DaybreakConnectionManager mgr;
|
EQ::Net::DaybreakConnectionManager mgr;
|
||||||
std::shared_ptr<EQ::Net::DaybreakConnection> c;
|
std::shared_ptr<EQ::Net::DaybreakConnection> c;
|
||||||
|
|
||||||
mgr.OnNewConnection([&](std::shared_ptr<EQ::Net::DaybreakConnection> connection) {
|
mgr.OnNewConnection(
|
||||||
|
[&](std::shared_ptr<EQ::Net::DaybreakConnection> connection) {
|
||||||
c = connection;
|
c = connection;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
mgr.OnConnectionStateChange([&](std::shared_ptr<EQ::Net::DaybreakConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to) {
|
mgr.OnConnectionStateChange(
|
||||||
|
[&](
|
||||||
|
std::shared_ptr<EQ::Net::DaybreakConnection> conn,
|
||||||
|
EQ::Net::DbProtocolStatus from,
|
||||||
|
EQ::Net::DbProtocolStatus to
|
||||||
|
) {
|
||||||
if (EQ::Net::StatusConnected == to) {
|
if (EQ::Net::StatusConnected == to) {
|
||||||
EQ::Net::DynamicPacket p;
|
EQ::Net::DynamicPacket p;
|
||||||
p.PutUInt16(0, 1); //OP_SessionReady
|
p.PutUInt16(0, 1); //OP_SessionReady
|
||||||
@ -265,14 +276,17 @@ bool AccountManagement::CheckExternalLoginserverUserCredentials(const std::strin
|
|||||||
else if (EQ::Net::StatusDisconnected == to) {
|
else if (EQ::Net::StatusDisconnected == to) {
|
||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
mgr.OnPacketRecv([&](std::shared_ptr<EQ::Net::DaybreakConnection> conn, const EQ::Net::Packet &p) {
|
mgr.OnPacketRecv(
|
||||||
|
[&](std::shared_ptr<EQ::Net::DaybreakConnection> conn, const EQ::Net::Packet &p) {
|
||||||
auto opcode = p.GetUInt16(0);
|
auto opcode = p.GetUInt16(0);
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case 0x0017: //OP_ChatMessage
|
case 0x0017: //OP_ChatMessage
|
||||||
{
|
{
|
||||||
size_t buffer_len = in_account_username.length() + in_account_password.length() + 2;
|
size_t buffer_len =
|
||||||
|
in_account_username.length() + in_account_password.length() + 2;
|
||||||
std::unique_ptr<char[]> buffer(new char[buffer_len]);
|
std::unique_ptr<char[]> buffer(new char[buffer_len]);
|
||||||
|
|
||||||
strcpy(&buffer[0], in_account_username.c_str());
|
strcpy(&buffer[0], in_account_username.c_str());
|
||||||
@ -293,8 +307,7 @@ bool AccountManagement::CheckExternalLoginserverUserCredentials(const std::strin
|
|||||||
c->QueuePacket(p);
|
c->QueuePacket(p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x0018:
|
case 0x0018: {
|
||||||
{
|
|
||||||
auto encrypt_size = p.Length() - 12;
|
auto encrypt_size = p.Length() - 12;
|
||||||
if (encrypt_size % 8 > 0) {
|
if (encrypt_size % 8 > 0) {
|
||||||
encrypt_size = (encrypt_size / 8) * 8;
|
encrypt_size = (encrypt_size / 8) * 8;
|
||||||
@ -307,35 +320,35 @@ bool AccountManagement::CheckExternalLoginserverUserCredentials(const std::strin
|
|||||||
EQ::Net::StaticPacket sp(&decrypted[0], encrypt_size);
|
EQ::Net::StaticPacket sp(&decrypted[0], encrypt_size);
|
||||||
auto response_error = sp.GetUInt16(1);
|
auto response_error = sp.GetUInt16(1);
|
||||||
|
|
||||||
if (response_error > 101) {
|
{
|
||||||
ret = false;
|
ret = response_error <= 101;
|
||||||
running = false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ret = true;
|
|
||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
EQ::Net::DNSLookup("login.eqemulator.net", 5999, false, [&](const std::string &addr) {
|
EQ::Net::DNSLookup(
|
||||||
if (addr == "") {
|
"login.eqemulator.net", 5999, false, [&](const std::string &addr) {
|
||||||
|
if (addr.empty()) {
|
||||||
ret = false;
|
ret = false;
|
||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mgr.Connect(addr, 5999);
|
mgr.Connect(addr, 5999);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
auto &loop = EQ::EventLoop::Get();
|
auto &loop = EQ::EventLoop::Get();
|
||||||
while (true == running) {
|
while (running) {
|
||||||
loop.Process();
|
loop.Process();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return res.get();
|
return res.get();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user