diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ab5a892b..d2ec76dfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## Latest Changes + * Allow usage of hostname for carla::Client and resolve them to IP address + ## CARLA 0.9.4 * Added recording and playback functionality diff --git a/LibCarla/source/carla/streaming/EndPoint.h b/LibCarla/source/carla/streaming/EndPoint.h index 1003e8e75..f97fcabf6 100644 --- a/LibCarla/source/carla/streaming/EndPoint.h +++ b/LibCarla/source/carla/streaming/EndPoint.h @@ -6,6 +6,7 @@ #pragma once +#include #include #include #include @@ -71,14 +72,18 @@ namespace detail { return boost::asio::ip::make_address("127.0.0.1"); } - static inline auto make_address(const char *address) { - return std::strcmp("localhost", address) == 0 ? - make_localhost_address() : - boost::asio::ip::make_address(address); - } - static inline auto make_address(const std::string &address) { - return make_address(address.c_str()); + boost::asio::io_service io_service; + boost::asio::ip::tcp::resolver resolver(io_service); + boost::asio::ip::tcp::resolver::query query(address, ""); + boost::asio::ip::tcp::resolver::iterator iter = resolver.resolve(query); + boost::asio::ip::tcp::resolver::iterator end; + while (iter != end) + { + boost::asio::ip::tcp::endpoint endpoint = *iter++; + return endpoint.address(); + } + return boost::asio::ip::make_address(address); } template