1 | #pragma once |
---|---|
2 | |
3 | #include <Common/config.h> |
4 | #include <Poco/Net/TCPServerConnectionFactory.h> |
5 | #include <atomic> |
6 | #include "IServer.h" |
7 | #if USE_SSL |
8 | #include <openssl/rsa.h> |
9 | #endif |
10 | |
11 | namespace DB |
12 | { |
13 | |
14 | class MySQLHandlerFactory : public Poco::Net::TCPServerConnectionFactory |
15 | { |
16 | private: |
17 | IServer & server; |
18 | Poco::Logger * log; |
19 | |
20 | #if USE_SSL |
21 | struct RSADeleter |
22 | { |
23 | void operator()(RSA * ptr) { RSA_free(ptr); } |
24 | }; |
25 | using RSAPtr = std::unique_ptr<RSA, RSADeleter>; |
26 | |
27 | RSAPtr public_key; |
28 | RSAPtr private_key; |
29 | |
30 | bool ssl_enabled = true; |
31 | #else |
32 | bool ssl_enabled = false; |
33 | #endif |
34 | |
35 | std::atomic<size_t> last_connection_id = 0; |
36 | public: |
37 | explicit MySQLHandlerFactory(IServer & server_); |
38 | |
39 | void readRSAKeys(); |
40 | |
41 | void generateRSAKeys(); |
42 | |
43 | Poco::Net::TCPServerConnection * createConnection(const Poco::Net::StreamSocket & socket) override; |
44 | }; |
45 | |
46 | } |
47 |