#pragma once using namespace std; #include #include #include #include "AuthPackets.h" class AuthModule; enum class HandshakeState : uint8_t { IDLE, VERSION_SENT, SCHEME_DECLARED, SCHEME_ACCEPTED, SETTINGS_SENT, AUTH_IN_PROGRESS, AUTH_DATA_EXCHANGED, IDENTITY_ASSIGNED, IDENTITY_CONFIRMED, COMPLETE, FAILED }; class HandshakeManager { private: bool isServer; HandshakeState state; unordered_map modules; AuthModule *activeModule; wstring activeVariation; wstring protocolVersion; public: wstring finalUid; wstring finalUsername; HandshakeManager(bool isServer); ~HandshakeManager(); void registerModule(AuthModule *module); shared_ptr handlePacket(const shared_ptr &packet); shared_ptr createInitialPacket(); bool isComplete() const { return state == HandshakeState::COMPLETE; } bool isFailed() const { return state == HandshakeState::FAILED; } HandshakeState getState() const { return state; } private: shared_ptr handleServer(const shared_ptr &packet); shared_ptr handleClient(const shared_ptr &packet); shared_ptr makePacket(AuthStage stage, vector> fields = {}); shared_ptr fail(); };