2021-03-23 15:01:13 +00:00
|
|
|
#include "StorageMongoDBSocketFactory.h"
|
|
|
|
|
2021-05-28 15:25:24 +00:00
|
|
|
#if !defined(ARCADIA_BUILD)
|
|
|
|
# include <Common/config.h>
|
|
|
|
#endif
|
|
|
|
|
2021-03-23 15:01:13 +00:00
|
|
|
#include <Poco/Net/IPAddress.h>
|
|
|
|
#include <Poco/Net/SocketAddress.h>
|
|
|
|
|
2021-05-24 12:11:03 +00:00
|
|
|
#if USE_SSL
|
|
|
|
# include <Poco/Net/SecureStreamSocket.h>
|
|
|
|
#endif
|
2021-03-23 15:01:13 +00:00
|
|
|
|
2021-07-28 08:54:36 +00:00
|
|
|
#ifdef __clang__
|
|
|
|
# pragma clang diagnostic ignored "-Wunused-parameter"
|
|
|
|
#else
|
|
|
|
# pragma GCC diagnostic ignored "-Wunused-parameter"
|
|
|
|
#endif
|
2021-03-23 15:01:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
Poco::Net::StreamSocket StorageMongoDBSocketFactory::createSocket(const std::string & host, int port, Poco::Timespan connectTimeout, bool secure)
|
|
|
|
{
|
2021-05-24 12:11:03 +00:00
|
|
|
#if USE_SSL
|
2021-03-23 15:01:13 +00:00
|
|
|
return secure ? createSecureSocket(host, port) : createPlainSocket(host, port);
|
2021-05-24 12:11:03 +00:00
|
|
|
#else
|
|
|
|
return createPlainSocket(host, port);
|
|
|
|
#endif
|
2021-03-23 15:01:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Poco::Net::StreamSocket StorageMongoDBSocketFactory::createPlainSocket(const std::string & host, int port)
|
|
|
|
{
|
|
|
|
Poco::Net::SocketAddress address(host, port);
|
|
|
|
Poco::Net::StreamSocket socket(address);
|
|
|
|
|
|
|
|
return socket;
|
|
|
|
}
|
|
|
|
|
2021-05-24 12:11:03 +00:00
|
|
|
#if USE_SSL
|
2021-03-23 15:01:13 +00:00
|
|
|
Poco::Net::StreamSocket StorageMongoDBSocketFactory::createSecureSocket(const std::string & host, int port)
|
|
|
|
{
|
|
|
|
Poco::Net::SocketAddress address(host, port);
|
|
|
|
Poco::Net::SecureStreamSocket socket(address, host);
|
|
|
|
|
|
|
|
return socket;
|
|
|
|
}
|
2021-05-24 12:11:03 +00:00
|
|
|
#endif
|
2021-03-23 15:01:13 +00:00
|
|
|
|
|
|
|
}
|