// // libtgvoip is free and unencumbered public domain software. // For more information, see http://unlicense.org or the UNLICENSE file // you should have received with this source code distribution. // #ifndef TGVOIP_MOCK_REFLECTOR #define TGVOIP_MOCK_REFLECTOR #include #include #include #include #include #include #include #include #include #include #include namespace tgvoip { namespace test { class MockReflector { public: MockReflector(const std::string& bindAddress, std::uint16_t bindPort); ~MockReflector(); void Start(); void Stop(); void SetDropAllPackets(bool drop); static std::array, 2> GeneratePeerTags(); private: struct ClientPair { ClientPair(); sockaddr_in addr0; sockaddr_in addr1; }; std::unordered_map m_clients; // clients are identified by the first half of their peer_tag pthread_t m_thread; int m_sfd; bool m_running = false; bool m_dropAllPackets = false; void RunThread(); }; } // namespace test } // namespace tgvoip #endif // TGVOIP_MOCK_REFLECTOR