#include "LuprexSockets.hpp" #define UI UI_ST THIRD_PARTY_INCLUDES_START #include #include #include #include #include #include #include #include THIRD_PARTY_INCLUDES_END #undef UI enum EChanState { CHAN_INACTIVE, CHAN_PLAINTEXT, CHAN_SSL_CONNECTING, CHAN_SSL_ACCEPTING, CHAN_SSL_READWRITE, }; // A communication socket. class FLpxChannel { int ChannelID; FSocket* Socket; SSL* SSLState; BIO* RecvBIO; BIO* SendBIO; // If recent_error is set, that means that a recent IO operation generated // an error. As a special case, EOF on read is considered an error, we use // the string "EOF" for this case. std::string RecentError; // OpenSSL has a rule: if you try to SSL_write and it returns // SSL_ERROR_WANT_READ, then you have to retry the write with the same // number of bytes. In this event, we record how many bytes we // attempted to write, which will enable us to retry. int RetryWriteNBytes; // True if the channel needs to be advanced. bool NeedAdvance; EChanState State; uint32_t NBytes; const char* Bytes; }; // A port-listening socket. class FLpxListener { int BoundPort; FSocket* Socket; }; class FLpxSocketsI : public FLpxSockets { public: // We don't own the wrapper, we just have a pointer to it. // We require a guarantee that it outlives us. EngineWrapper* Luprex; TArray Channels; TArray Listeners; SSL_CTX* ServerCTX; SSL_CTX* ClientSecureCTX; SSL_CTX* ClientInsecureCTX; FLpxSocketsI(EngineWrapper* w); virtual ~FLpxSocketsI() override; virtual void Update() override; }; FLpxSocketsI::FLpxSocketsI(EngineWrapper *w) { Luprex = w; ServerCTX = nullptr; ClientSecureCTX = nullptr; ClientInsecureCTX = nullptr; } FLpxSocketsI::~FLpxSocketsI() { } void FLpxSocketsI::Update() { } FLpxSockets* FLpxSockets::Create(EngineWrapper* w) { return new FLpxSocketsI(w); }