BF2MC-Matchmaker
|
Client class for handling browsing requests. More...
#include <client.h>
Public Member Functions | |
Client (int socket, struct sockaddr_in address) | |
Constructs a new Client object. More... | |
~Client () | |
Destroys the Client object. | |
void | Listen () |
Listens for incoming requests from the client. | |
void | Disconnect () |
Disconnects the client. | |
void | onRequest (const std::vector< unsigned char > &request) |
Event handler for incoming requests. More... | |
void | requestServerList (const std::vector< unsigned char > &request) |
Sends a request for the server list. More... | |
void | requestServerInfo (const std::vector< unsigned char > &request) |
Sends a request for server information. More... | |
![]() | |
void | Close () |
Closes the socket. | |
std::string | GetIP () const |
Gets the IP address associated with the socket. More... | |
void | GetIpArray (uint8_t *ip) const |
Gets the IP address associated with the socket as an array of bytes. More... | |
uint16_t | GetPort () const |
Gets the port number associated with the socket. More... | |
std::string | GetAddress () const |
Gets the full address (IP:Port) associated with the socket. More... | |
std::string | GetSocketType () const |
Gets the socket type. More... | |
std::chrono::system_clock::time_point | GetLastRecievedTime () const |
Gets the time when the socket last received data. More... | |
void | Send (const std::string &msg) const |
Sends a message over the socket. More... | |
void | Send (const std::vector< unsigned char > &msg) const |
Sends a message over the socket. More... | |
void | UDPSend (const std::string &msg) const |
Sends a UDP message over the socket. More... | |
void | UDPSend (const std::vector< unsigned char > &msg) const |
Sends a UDP message over the socket. More... | |
void | UpdateLastRecievedTime () |
Updates the last received time to the current system time. | |
virtual void | WTF_WHY_AM_I_HERE_1337 () |
Empty virtual function required for static_cast in C++. More... | |
Static Public Member Functions | |
static void | Test () |
Testing function to encrypt/decrypt a package. | |
static void | Crack () |
Cracking function to find the secret key from a package. | |
static void | Heartbeat () |
Heartbeat function to manage client connections. More... | |
Private Member Functions | |
void | _BufferToRequests (const std::vector< unsigned char > &buffer, std::vector< std::vector< unsigned char >> &requests) |
Converts a buffer to a list of requests. More... | |
void | _insertClientInfo (std::vector< unsigned char > &response) |
Inserts client information into the response. More... | |
void | _insertGameServerFlagIpPort (std::vector< unsigned char > &response, const Battlefield::GameServer &game_server) |
Inserts game server flag, IP, and port into the response. More... | |
void | _Encrypt (std::vector< unsigned char > &response) |
Encrypts the response. More... | |
void | _LogTransaction (const std::string &direction, const std::string &response) const |
Logs a transaction. More... | |
void | _FilterServers (const std::string &filter, Battlefield::GameServers &game_servers) |
Filters game servers based on the provided filter criteria. More... | |
bool | _FilterServerGameVersion (const std::string &filter, const Battlefield::GameServer &game_server) |
Checks if a game server matches the filter criteria based on game version. More... | |
bool | _FilterServerRegion (const std::string &filter, const Battlefield::GameServer &game_server) |
Checks if a game server matches the filter criteria based on region. More... | |
bool | _FilterServerNumPlayers (const std::string &filter, const Battlefield::GameServer &game_server) |
Checks if a game server matches the filter criteria based on number of players. More... | |
bool | _FilterServerGameType (const std::string &filter, const Battlefield::GameServer &game_server) |
Checks if a game server matches the filter criteria based on game type. More... | |
bool | _FilterServerMapName (const std::string &filter, const Battlefield::GameServer &game_server) |
Checks if a game server matches the filter criteria based on map name. More... | |
bool | _FilterServerStatsTracking (const std::string &filter, const Battlefield::GameServer &game_server) |
Checks if a game server matches the filter criteria based on stats tracking. More... | |
bool | _FilterServerReconfigurable (const std::string &filter, const Battlefield::GameServer &game_server) |
Checks if a game server matches the filter criteria based on reconfigurability. More... | |
bool | _FilterServerClan (const std::string &filter, const Battlefield::GameServer &game_server) |
Checks if a game server matches the filter criteria based on clan. More... | |
bool | _FilterServerTeamplay (const std::string &filter, const Battlefield::GameServer &game_server) |
Checks if a game server matches the filter criteria based on teamplay. More... | |
Private Attributes | |
std::vector< unsigned char > | _client_challenge |
Challenge data sent to the client. More... | |
Additional Inherited Members | |
![]() | |
int | _socket |
struct sockaddr_in | _address |
std::chrono::system_clock::time_point | _recieved_time |
std::mutex | _mutex |
Client class for handling browsing requests.
Definition at line 14 of file browsing/client.h.
Browsing::Client::Client | ( | int | socket, |
struct sockaddr_in | address | ||
) |
Constructs a new Client object.
socket | The socket associated with the client. |
address | The address information of the client. |
Definition at line 30 of file browsing/client.cpp.
|
private |
Converts a buffer to a list of requests.
buffer | The buffer containing the requests. | |
[out] | requests | The vector to store the parsed requests. |
Definition at line 530 of file browsing/client.cpp.
|
private |
Encrypts the response.
response | The response to encrypt. |
Definition at line 606 of file browsing/client.cpp.
|
private |
Checks if a game server matches the filter criteria based on clan.
filter | The filter string. |
game_server | The game server to check. |
Definition at line 888 of file browsing/client.cpp.
|
private |
Checks if a game server matches the filter criteria based on game type.
filter | The filter string. |
game_server | The game server to check. |
Definition at line 766 of file browsing/client.cpp.
|
private |
Checks if a game server matches the filter criteria based on game version.
filter | The filter string. |
game_server | The game server to check. |
Definition at line 692 of file browsing/client.cpp.
|
private |
Checks if a game server matches the filter criteria based on map name.
filter | The filter string. |
game_server | The game server to check. |
Definition at line 784 of file browsing/client.cpp.
|
private |
Checks if a game server matches the filter criteria based on number of players.
filter | The filter string. |
game_server | The game server to check. |
Definition at line 738 of file browsing/client.cpp.
|
private |
Checks if a game server matches the filter criteria based on reconfigurability.
filter | The filter string. |
game_server | The game server to check. |
Definition at line 820 of file browsing/client.cpp.
|
private |
Checks if a game server matches the filter criteria based on region.
filter | The filter string. |
game_server | The game server to check. |
Definition at line 710 of file browsing/client.cpp.
|
private |
Filters game servers based on the provided filter criteria.
filter | The filter string. |
game_servers | The list of game servers to filter. |
Definition at line 664 of file browsing/client.cpp.
|
private |
Checks if a game server matches the filter criteria based on stats tracking.
filter | The filter string. |
game_server | The game server to check. |
Definition at line 802 of file browsing/client.cpp.
|
private |
Checks if a game server matches the filter criteria based on teamplay.
filter | The filter string. |
game_server | The game server to check. |
Definition at line 847 of file browsing/client.cpp.
|
private |
Inserts client information into the response.
response | The response to modify. |
Definition at line 553 of file browsing/client.cpp.
|
private |
Inserts game server flag, IP, and port into the response.
response | The response to modify. |
game_server | The game server to get the information from. |
Definition at line 565 of file browsing/client.cpp.
|
private |
Logs a transaction.
direction | The direction of the transaction ("<--" or "-->"). |
response | The response message to log. |
Definition at line 648 of file browsing/client.cpp.
|
static |
Heartbeat function to manage client connections.
This function periodically checks for client connections and closes connections that have not sent any data in the last minute.
Definition at line 921 of file browsing/client.cpp.
void Browsing::Client::onRequest | ( | const std::vector< unsigned char > & | request | ) |
Event handler for incoming requests.
request | The incoming request. |
Definition at line 94 of file browsing/client.cpp.
void Browsing::Client::requestServerInfo | ( | const std::vector< unsigned char > & | request | ) |
Sends a request for server information.
request | The request data. |
Definition at line 466 of file browsing/client.cpp.
void Browsing::Client::requestServerList | ( | const std::vector< unsigned char > & | request | ) |
Sends a request for the server list.
request | The request data. |
Definition at line 190 of file browsing/client.cpp.
|
private |
Challenge data sent to the client.
When a client connects to the browsing server, it receives a challenge to validate its connection.
Definition at line 23 of file browsing/client.h.