#pragma once #include #include #include "acceptor.hpp" /*! * \file */ /*! * \brief The ListenSettings struct */ struct ListenSettings { bool enable_ipv4; ///< Should we listen on ipv4 std::string ipv4_inaddr; ///< Listen on this ipv4 address bool enable_ipv6; ///< Should we listen on ipv6 std::string ipv6_inaddr; ///< Listen on this ipv6 address uint16_t port; ///< Listen on this port. bool use_ssl; ///< Should we use ssl std::string cert; ///< The cert to use in pem format. std::string key; ///< The corresponding key in pem format. std::string dhparam; ///< The diffie helman parameters. }; /*! * \brief The Server class */ class Server { Server(boost::asio::io_service& io_service, ListenSettings const& listen_settings); ListenSettings const& listen_settings; Acceptor v4_acceptor; Acceptor v6_acceptor; public: /*! * \brief Server * \param io_service The io_service this server will use for all its connections. * \param listen_settings The parameters used for determining on what endpoints to listen. * \param accept_handler The function to call when connections are established. */ Server(boost::asio::io_service& io_service, ListenSettings const& listen_settings, AcceptHandler accept_handler); /*! * \brief Server * \param io_service The io_service this server will use for all its connections. * \param listen_settings The parameters used for determining on what endpoints to listen. * \param ctx The SSL context. * \param accept_handler The function to call when SSL connections are established. */ Server(boost::asio::io_service& io_service, ListenSettings const& listen_settings, std::shared_ptr ctx, SSLAcceptHandler accept_handler); void close(); };