ClickHouse/programs/server/MySQLHandlerFactory.h

51 lines
916 B
C++
Raw Normal View History

2019-03-16 02:08:21 +00:00
#pragma once
#include <Poco/Net/TCPServerConnectionFactory.h>
2019-05-26 06:52:29 +00:00
#include <atomic>
2019-03-16 02:08:21 +00:00
#include "IServer.h"
#if !defined(ARCADIA_BUILD)
# include <Common/config.h>
#endif
#if USE_SSL
# include <openssl/rsa.h>
#endif
2019-03-16 02:08:21 +00:00
namespace DB
{
2019-04-29 06:37:39 +00:00
class MySQLHandlerFactory : public Poco::Net::TCPServerConnectionFactory
{
private:
IServer & server;
Poco::Logger * log;
#if USE_SSL
2019-05-26 19:30:23 +00:00
struct RSADeleter
{
2019-05-26 06:52:29 +00:00
void operator()(RSA * ptr) { RSA_free(ptr); }
};
using RSAPtr = std::unique_ptr<RSA, RSADeleter>;
2019-05-26 06:52:29 +00:00
RSAPtr public_key;
RSAPtr private_key;
2019-03-16 02:08:21 +00:00
2019-05-26 06:52:29 +00:00
bool ssl_enabled = true;
#else
bool ssl_enabled = false;
#endif
2019-05-26 06:52:29 +00:00
std::atomic<size_t> last_connection_id = 0;
public:
explicit MySQLHandlerFactory(IServer & server_);
2019-04-29 06:37:39 +00:00
2019-05-26 06:52:29 +00:00
void readRSAKeys();
2019-04-29 06:37:39 +00:00
2019-05-26 06:52:29 +00:00
void generateRSAKeys();
2019-04-29 06:37:39 +00:00
2019-05-26 06:52:29 +00:00
Poco::Net::TCPServerConnection * createConnection(const Poco::Net::StreamSocket & socket) override;
2019-04-29 06:37:39 +00:00
};
2019-03-16 02:08:21 +00:00
}