feat: add websocket server
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user