Prepare auth data
This commit is contained in:
@ -11,6 +11,7 @@
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/string.hpp>
|
||||
#include <utils/smbios.hpp>
|
||||
#include <utils/byte_buffer.hpp>
|
||||
#include <utils/info_string.hpp>
|
||||
#include <utils/cryptography.hpp>
|
||||
|
||||
@ -94,6 +95,14 @@ namespace auth
|
||||
return !is_first;
|
||||
}
|
||||
|
||||
std::string serialize_connect_data(const std::vector<char>& data)
|
||||
{
|
||||
utils::byte_buffer buffer{};
|
||||
buffer.write_vector(data);
|
||||
|
||||
return buffer.move_buffer();
|
||||
}
|
||||
|
||||
int send_connect_data_stub(const game::netsrc_t sock, game::netadr_t* adr, const char* data, int len)
|
||||
{
|
||||
std::string buffer{};
|
||||
@ -101,8 +110,12 @@ namespace auth
|
||||
const auto is_connect_sequence = len >= 7 && strncmp("connect", data, 7) == 0;
|
||||
if (is_connect_sequence)
|
||||
{
|
||||
buffer.append("connect ");
|
||||
buffer.append(data, len);
|
||||
std::vector<char> connect_data{};
|
||||
connect_data.assign(data, data + len);
|
||||
|
||||
buffer.append("connect");
|
||||
buffer.push_back(' ');
|
||||
buffer.append(serialize_connect_data(connect_data));
|
||||
|
||||
data = buffer.data();
|
||||
len = static_cast<int>(buffer.size());
|
||||
@ -113,10 +126,10 @@ namespace auth
|
||||
|
||||
void handle_connect_packet(const game::netadr_t& target, const network::data_view& data)
|
||||
{
|
||||
const std::string text(data.begin(), data.end());
|
||||
command::params_sv params(text);
|
||||
utils::byte_buffer buffer(data);
|
||||
|
||||
MessageBoxA(0, "Connecting", 0, 0);
|
||||
const auto text = buffer.read_vector<char>();
|
||||
command::params_sv params(std::string(text.data(), text.size()));
|
||||
|
||||
game::SV_DirectConnect(target);
|
||||
}
|
||||
|
@ -35,7 +35,18 @@ namespace network
|
||||
|
||||
const std::basic_string_view data(message->data + offset, message->cursize - offset);
|
||||
|
||||
handler->second(*address, data);
|
||||
try
|
||||
{
|
||||
handler->second(*address, data);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
printf("Error: %s\n", e.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ namespace party
|
||||
}
|
||||
|
||||
void connect_to_lobby(const game::netadr_t& addr, const std::string& mapname, const std::string& gamemode,
|
||||
const std::string& pub_id)
|
||||
const std::string& pub_id)
|
||||
{
|
||||
workshop::load_usermap_mod_if_needed(pub_id);
|
||||
|
||||
@ -55,7 +55,8 @@ namespace party
|
||||
}
|
||||
|
||||
void connect_to_lobby_with_mode(const game::netadr_t& addr, const game::eModes mode, const std::string& mapname,
|
||||
const std::string& gametype, const std::string& pub_id, const bool was_retried = false)
|
||||
const std::string& gametype, const std::string& pub_id,
|
||||
const bool was_retried = false)
|
||||
{
|
||||
if (game::Com_SessionMode_IsMode(mode))
|
||||
{
|
||||
@ -144,6 +145,13 @@ namespace party
|
||||
|
||||
is_connecting_to_dedi = info.get("dedicated") == "1";
|
||||
|
||||
if (atoi(info.get("protocol").data()) != PROTOCOL)
|
||||
{
|
||||
const auto str = "Invalid protocol.";
|
||||
printf("%s\n", str);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto gamename = info.get("gamename");
|
||||
if (gamename != "T7"s)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#define PROTOCOL 1
|
||||
#define PROTOCOL 2
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace game
|
||||
|
Reference in New Issue
Block a user