Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use port for http login and allow custom URL #606

Merged
merged 7 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion modules/client_entergame/entergame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,16 @@ function EnterGame.tryHttpLogin(clientVersion)
onCharacterList(nil, characters, account)
end

HTTP.post(G.host .. "/login.php",
local host, path = G.host:match("([^/]+)/([^/].*)")
local url = G.host

if G.port ~= nil and path ~= nil then
url = host .. ':' .. G.port .. '/' .. path
elseif path ~= nil then
url = host .. '/' .. path
end

HTTP.post(url,
json.encode({
email = G.account,
password = G.password,
Expand Down Expand Up @@ -452,6 +461,10 @@ function EnterGame.doLogin()
g_settings.set('client-version', clientVersion)

if clientVersion >= 1281 and G.port ~= 7171 then
if G.port == 0 then
G.port = 80
end

EnterGame.tryHttpLogin(clientVersion)
else
protocolLogin = ProtocolLogin.create()
Expand Down
14 changes: 7 additions & 7 deletions src/framework/net/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,18 @@ void Connection::connect(const std::string_view host, uint16_t port, const std::
m_connectCallback = connectCallback;

const asio::ip::tcp::resolver::query query(host.data(), stdext::unsafe_cast<std::string>(port));
m_resolver.async_resolve(query, [capture0 = asConnection()](auto&& PH1, auto&& PH2) {
capture0->onResolve(std::forward<decltype(PH1)>(PH1),
std::forward<decltype(PH2)>(PH2));
m_resolver.async_resolve(query, [this](auto&& error, auto&& endpointIterator) {
onResolve(std::move(error), std::move(endpointIterator));
});

m_readTimer.cancel();
m_readTimer.expires_from_now(asio::chrono::seconds(static_cast<uint32_t>(READ_TIMEOUT)));
m_readTimer.async_wait([capture0 = asConnection()](auto&& PH1) {
capture0->onTimeout(std::forward<decltype(PH1)>(PH1));
m_readTimer.expires_after(std::chrono::seconds(static_cast<uint32_t>(READ_TIMEOUT)));
m_readTimer.async_wait([this](auto&& error) {
onTimeout(std::move(error));
});
}


void Connection::internal_connect(const asio::ip::basic_resolver<asio::ip::tcp>::iterator& endpointIterator)
{
m_socket.async_connect(*endpointIterator, [capture0 = asConnection()](auto&& PH1) {
Expand Down Expand Up @@ -341,4 +341,4 @@ int Connection::getIp()

g_logger.error("Getting remote ip");
return 0;
}
}
Loading