diff --git a/src/wesnothd_connection.cpp b/src/wesnothd_connection.cpp index 854091979bc5..a962484d5d7e 100644 --- a/src/wesnothd_connection.cpp +++ b/src/wesnothd_connection.cpp @@ -80,12 +80,16 @@ wesnothd_connection::wesnothd_connection(const std::string& host, const std::str , bytes_read_(0) { MPTEST_LOG; -#if BOOST_VERSION >= 106600 - resolver_.async_resolve(host, service, -#else - resolver_.async_resolve(boost::asio::ip::tcp::resolver::query(host, service), -#endif - std::bind(&wesnothd_connection::handle_resolve, this, std::placeholders::_1, std::placeholders::_2)); + + error_code ec; + auto result = resolver_.resolve(host, service, boost::asio::ip::resolver_query_base::numeric_host, ec); + if(!ec) { // if numeric resolve succeeds then we got raw ip address so TLS host name validation would never pass + use_tls_ = false; + boost::asio::post(io_context_, [this, ec, result](){ handle_resolve(ec, { result } ); } ); + } else { + resolver_.async_resolve(host, service, + std::bind(&wesnothd_connection::handle_resolve, this, std::placeholders::_1, std::placeholders::_2)); + } // Starts the worker thread. Do this *after* the above async_resolve call or it will just exit immediately! worker_thread_ = std::thread([this]() {