Bypass resolver
If we are given an ip address to the http client, there's no reason to
call the dns resolver. Implement a procedure to "skip" resolution if
the http client is an ip address.
Tested:
Using an ipv4 address from a system not running OpenBMC dbus (in this
case an Ubuntu system) now can resolve an IP address. Redfish works
with later patches.
Change-Id: I094ec7b3015e1e31cb83f0e1c25f6c1fb6685219
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/http/http_client.hpp b/http/http_client.hpp
index 81922c0..f1a5e1e 100644
--- a/http/http_client.hpp
+++ b/http/http_client.hpp
@@ -172,10 +172,32 @@
{
state = ConnState::resolveInProgress;
BMCWEB_LOG_DEBUG("Trying to resolve: {}, id: {}", host, connId);
+ boost::urls::host_type hostType = host.host_type();
+ if (hostType == boost::urls::host_type::name)
+ {
+ resolver.async_resolve(
+ host.encoded_host_address(), host.port(),
+ std::bind_front(&ConnectionInfo::afterResolve, this,
+ shared_from_this()));
- resolver.async_resolve(host.encoded_host_address(), host.port(),
- std::bind_front(&ConnectionInfo::afterResolve,
- this, shared_from_this()));
+ return;
+ }
+ // If we already have an ip address, no need to resolve
+ Resolver::results_type ip;
+ boost::system::error_code ec;
+ boost::asio::ip::address addr =
+ boost::asio::ip::make_address(host.host_address(), ec);
+
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR(
+ "Failed to parse already-parsed ip address. This should not happen {}",
+ host.host_address());
+ return;
+ }
+ boost::asio::ip::tcp::endpoint end(addr, host.port_number());
+ ip.push_back(std::move(end));
+ afterResolve(shared_from_this(), boost::system::error_code(), ip);
}
void afterResolve(const std::shared_ptr<ConnectionInfo>& /*self*/,