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