2019-02-25 08:48:22 -05:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2014-04-11 22:21:09 -04:00
|
|
|
|
2015-08-28 19:16:16 -04:00
|
|
|
#ifndef HTTPSERVERCONNECTION_H
|
|
|
|
|
#define HTTPSERVERCONNECTION_H
|
2014-04-11 22:21:09 -04:00
|
|
|
|
2015-06-22 05:11:21 -04:00
|
|
|
#include "remote/apiuser.hpp"
|
2019-02-14 10:10:41 -05:00
|
|
|
#include "base/string.hpp"
|
2014-10-16 06:27:09 -04:00
|
|
|
#include "base/tlsstream.hpp"
|
2019-02-14 10:10:41 -05:00
|
|
|
#include <memory>
|
2019-06-05 04:32:20 -04:00
|
|
|
#include <boost/asio/deadline_timer.hpp>
|
2019-09-09 09:11:38 -04:00
|
|
|
#include <boost/asio/io_context.hpp>
|
|
|
|
|
#include <boost/asio/io_context_strand.hpp>
|
2019-02-14 10:10:41 -05:00
|
|
|
#include <boost/asio/spawn.hpp>
|
2014-04-11 22:21:09 -04:00
|
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
2014-05-03 14:02:22 -04:00
|
|
|
* An API client connection.
|
2014-04-11 22:21:09 -04:00
|
|
|
*
|
2014-05-03 14:02:22 -04:00
|
|
|
* @ingroup remote
|
2014-04-11 22:21:09 -04:00
|
|
|
*/
|
2018-01-04 00:11:04 -05:00
|
|
|
class HttpServerConnection final : public Object
|
2014-04-11 22:21:09 -04:00
|
|
|
{
|
|
|
|
|
public:
|
2015-08-28 19:16:16 -04:00
|
|
|
DECLARE_PTR_TYPEDEFS(HttpServerConnection);
|
2014-05-03 14:02:22 -04:00
|
|
|
|
2019-07-25 08:34:29 -04:00
|
|
|
HttpServerConnection(const String& identity, bool authenticated, const Shared<AsioTlsStream>::Ptr& stream);
|
2014-05-03 14:02:22 -04:00
|
|
|
|
2018-01-03 22:25:35 -05:00
|
|
|
void Start();
|
2019-02-20 08:56:12 -05:00
|
|
|
void Disconnect();
|
2019-04-02 11:37:29 -04:00
|
|
|
void StartStreaming();
|
2014-05-03 14:02:22 -04:00
|
|
|
|
2019-04-03 03:59:45 -04:00
|
|
|
bool Disconnected();
|
|
|
|
|
|
2014-04-11 22:21:09 -04:00
|
|
|
private:
|
2015-06-22 05:11:21 -04:00
|
|
|
ApiUser::Ptr m_ApiUser;
|
2019-07-25 08:34:29 -04:00
|
|
|
Shared<AsioTlsStream>::Ptr m_Stream;
|
2019-02-20 09:27:15 -05:00
|
|
|
double m_Seen;
|
2018-10-09 09:40:16 -04:00
|
|
|
String m_PeerAddress;
|
2019-09-09 09:11:38 -04:00
|
|
|
boost::asio::io_context::strand m_IoStrand;
|
2019-02-20 08:56:12 -05:00
|
|
|
bool m_ShuttingDown;
|
2019-04-02 11:37:29 -04:00
|
|
|
bool m_HasStartedStreaming;
|
2019-06-05 04:32:20 -04:00
|
|
|
boost::asio::deadline_timer m_CheckLivenessTimer;
|
2014-05-03 14:02:22 -04:00
|
|
|
|
2019-07-25 08:34:29 -04:00
|
|
|
HttpServerConnection(const String& identity, bool authenticated, const Shared<AsioTlsStream>::Ptr& stream, boost::asio::io_context& io);
|
2019-06-07 10:30:34 -04:00
|
|
|
|
2019-02-14 10:10:41 -05:00
|
|
|
void ProcessMessages(boost::asio::yield_context yc);
|
2019-02-20 09:27:15 -05:00
|
|
|
void CheckLiveness(boost::asio::yield_context yc);
|
2014-04-11 22:21:09 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-28 19:16:16 -04:00
|
|
|
#endif /* HTTPSERVERCONNECTION_H */
|