Skip to content

allow loopback server and client to work without an interface address #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Release/src/http/client/http_client_asio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,8 @@ class asio_context final : public request_context, public std::enable_shared_fro

m_context->m_timer.start();

tcp::resolver::query query(utility::conversions::to_utf8string(proxy_host), to_string(proxy_port));
// Allow client to work on loopback address overriding default asio address_configured flag
tcp::resolver::query query(utility::conversions::to_utf8string(proxy_host), to_string(proxy_port), boost::asio::ip::resolver_query_base::flags());

auto client = std::static_pointer_cast<asio_client>(m_context->m_http_client);
client->m_resolver.async_resolve(query,
Expand Down Expand Up @@ -869,7 +870,8 @@ class asio_context final : public request_context, public std::enable_shared_fro
auto tcp_host = proxy_type == http_proxy_type::http ? proxy_host : host;
auto tcp_port = proxy_type == http_proxy_type::http ? proxy_port : port;

tcp::resolver::query query(tcp_host, to_string(tcp_port));
// Allow client to work on loopback address overriding default asio address_configured flag
tcp::resolver::query query(tcp_host, to_string(tcp_port), boost::asio::ip::resolver_query_base::flags());
auto client = std::static_pointer_cast<asio_client>(ctx->m_http_client);
client->m_resolver.async_resolve(query,
boost::bind(&asio_context::handle_resolve,
Expand Down
7 changes: 5 additions & 2 deletions Release/src/http/listener/http_server_asio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,12 @@ void hostport_listener::start()
auto& service = crossplat::threadpool::shared_instance().service();
tcp::resolver resolver(service);
// #446: boost resolver does not recognize "+" as a host wildchar

// Merge release 1.14 change #1145
// Allow server to work on loopback address overriding default asio address_configured flag
tcp::resolver::query query = ( "+" == m_host)?
tcp::resolver::query(m_port):
tcp::resolver::query(m_host, m_port);
tcp::resolver::query(m_port, boost::asio::ip::resolver_query_base::flags()):
tcp::resolver::query(m_host, m_port, boost::asio::ip::resolver_query_base::flags());

tcp::endpoint endpoint = *resolver.resolve(query);

Expand Down