#pragma once #include #include #include #include #include #include #include #include #include #include "ssl.h" #include /* TO-DO: use random port, test availability */ #define PROXY_PORT 58421 #define PROXY_THREAD_COUNT 256 typedef unsigned __int64 SOCKET; class Proxy { public: Proxy(); ~Proxy(); bool init(); void shutdown(); CallbackEvent OnClientRequest; CallbackEvent OnServerResponse; void addWhitelistDomain(const std::string& domain); private: void loop(); void handleClient(SOCKET clientSocket); bool initSSL(); void cleanupSSL(); SOCKET _listenSocket = 0; std::thread _workerThread; std::atomic _running = false; std::vector _poolThreads; std::queue _clientQueue; std::mutex _queueMutex; std::condition_variable _queueCond; CertManager _certManager; SSL_CTX* _clientCtx = nullptr; std::vector _whitelistDomains; };