From 56d1361882edb0f8c769110c57810de2b09fa3c9 Mon Sep 17 00:00:00 2001 From: Soumyadipta Das Date: Wed, 4 Sep 2019 11:15:27 +0530 Subject: [PATCH] 1) SSL is optional with #define TWISTEDCPP_NEED_SSL. Disabled by default. 2) Fixed compile error for Boost > v1.70 --- include/twisted/detail/sockets.hpp | 12 ++++++++++++ include/twisted/reactor.hpp | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/include/twisted/detail/sockets.hpp b/include/twisted/detail/sockets.hpp index 87c8bec..517f7de 100644 --- a/include/twisted/detail/sockets.hpp +++ b/include/twisted/detail/sockets.hpp @@ -3,9 +3,12 @@ #include #include +#ifdef TWISTEDCPP_NEED_SSL #include +#endif #include #include +#include namespace twisted { @@ -72,9 +75,16 @@ class tcp_socket : public socket_base { virtual void close() { _socket.close(); } +#if BOOST_VERSION >= 107000 + virtual boost::asio::io_context& get_io_service() { + return ((boost::asio::io_context&)_socket.get_executor().context()); + } + +#else virtual boost::asio::io_service& get_io_service() { return _socket.get_io_service(); } +#endif boost::asio::ip::tcp::socket& lowest_layer() { return _socket; } @@ -84,6 +94,7 @@ class tcp_socket : public socket_base { boost::asio::ip::tcp::socket _socket; }; +#ifdef TWISTEDCPP_NEED_SSL class ssl_socket : public socket_base { public: ssl_socket(boost::asio::io_service& io_service, @@ -143,6 +154,7 @@ class ssl_socket : public socket_base { private: boost::asio::ssl::stream _socket; }; +#endif } // namespace detail } // namespace twisted diff --git a/include/twisted/reactor.hpp b/include/twisted/reactor.hpp index 9898086..3ecf862 100644 --- a/include/twisted/reactor.hpp +++ b/include/twisted/reactor.hpp @@ -2,7 +2,9 @@ #define TWISTEDCPP_REACTOR_HPP #include "detail/sockets.hpp" +#ifdef TWISTEDCPP_NEED_SSL #include "ssl_options.hpp" +#endif #include #include @@ -64,6 +66,7 @@ class reactor { * href="http://www.boost.org/doc/libs/1_57_0/doc/html/boost_asio/reference/ssl__context.html">boost::asio * ssl context - sets the ssl/tls options */ +#ifdef TWISTEDCPP_NEED_SSL template void listen_ssl(int port, ssl_options&& ssl_opts, Args&&... args) { std::shared_ptr ssl_opts_ptr // move capture @@ -74,6 +77,7 @@ class reactor { ssl_impl(acceptor, yield, ssl_opts_ptr, std::forward(args)...); }); } +#endif private: template @@ -87,6 +91,7 @@ class reactor { run_loop(acceptor, yield, socket_factory, std::forward(args)...); } +#ifdef TWISTEDCPP_NEED_SSL template void ssl_impl(boost::asio::ip::tcp::acceptor& acceptor, boost::asio::yield_context yield, @@ -98,6 +103,7 @@ class reactor { run_loop(acceptor, yield, socket_factory, std::forward(args)...); } +#endif template void run_loop(boost::asio::ip::tcp::acceptor& acceptor,