feat: add websocket server

This commit is contained in:
2026-06-19 08:33:04 -03:00
parent 612b9429a2
commit 47e0ea18e8
2 changed files with 183 additions and 0 deletions
+57
View File
@@ -9,6 +9,20 @@
#include <mutex>
#define WS_ADDR "0.0.0.0"
#define WS_PORT 4444
class TinyMITMProxy;
namespace ix
{
class WebSocket;
class WebSocketServer;
struct WebSocketMessage;
class ConnectionState;
} // namespace ix
namespace seallib
{
class Logger;
@@ -31,6 +45,35 @@ struct SpooferConfig
std::unordered_set<std::string> unlockedCharacters;
};
namespace WSMessages
{
enum Action : int
{
INIT_CONFIG = 0,
SYNC_STATE = 1,
SYNC_TOGGLES = 2
};
struct Toggles
{
bool spoofItems = false;
bool spoofPerks = false;
bool spoofCatalog = false;
bool spoofDLCs = false;
};
struct Init
{
Action action = INIT_CONFIG;
SpooferConfig profile;
Toggles toggles;
};
struct Request
{
Action action;
SpooferConfig profile{};
Toggles toggles{};
};
} // namespace WSMessages
class Spoofer
{
public:
@@ -45,6 +88,15 @@ class Spoofer
*/
void loadConfig();
void saveConfig();
/*
websocket server stuff
*/
void initServer();
void stopServer();
void wsMessageCallback(std::shared_ptr<ix::ConnectionState> connectionState, ix::WebSocket& webSocket,
const std::unique_ptr<ix::WebSocketMessage>& msg);
/*
proxy handlers
*/
@@ -77,6 +129,11 @@ class Spoofer
std::unordered_set<std::string> _dlcListSteam;
std::unordered_set<std::string> _unlockedCharacters;
/*
internal variables
*/
ix::WebSocketServer* _wsServer = nullptr;
seallib::Logger* _log = nullptr;
std::mutex _mutex;
};