This commit is contained in:
proller 2017-09-29 18:01:06 +03:00 committed by alexey-milovidov
parent ebb4a6a0ed
commit 2467530583
3 changed files with 8 additions and 5 deletions

View File

@ -95,7 +95,8 @@ void Connection::disconnect()
{
//LOG_TRACE(log_wrapper.get(), "Disconnecting");
socket->close();
if (socket)
socket->close();
socket = nullptr;
in = nullptr;
out = nullptr;

View File

@ -6,6 +6,7 @@
#define DBMS_DEFAULT_HOST "localhost"
#define DBMS_DEFAULT_PORT 9000
#define DBMS_DEFAULT_SECURE_PORT 9443
#define DBMS_DEFAULT_PORT_STR #DBMS_DEFAULT_PORT
#define DBMS_DEFAULT_HTTP_PORT 8123
#define DBMS_DEFAULT_CONNECT_TIMEOUT_SEC 10

View File

@ -375,8 +375,12 @@ private:
void connect()
{
Protocol::Encryption::Enum encryption = config().getBool("secure", false)
? Protocol::Encryption::Enable
: Protocol::Encryption::Disable;
String host = config().getString("host", "localhost");
UInt16 port = config().getInt("port", DBMS_DEFAULT_PORT);
UInt16 port = config().getInt("port", config().getInt(encryption ? "tcps_port" : "tcp_port", encryption ? DBMS_DEFAULT_SECURE_PORT : DBMS_DEFAULT_PORT));
String default_database = config().getString("database", "");
String user = config().getString("user", "");
String password = config().getString("password", "");
@ -385,9 +389,6 @@ private:
? Protocol::Compression::Enable
: Protocol::Compression::Disable;
Protocol::Encryption::Enum encryption = config().getBool("secure", true)
? Protocol::Encryption::Enable
: Protocol::Encryption::Disable;
if (is_interactive)
std::cout << "Connecting to "
<< (!default_database.empty() ? "database " + default_database + " at " : "")