Commit 5abc3bc8 authored by Ivan Vilata-i-Balaguer's avatar Ivan Vilata-i-Balaguer
Browse files

Avoid DoH exchange if given host is already a network address.

parent e8ee198a
......@@ -644,6 +644,18 @@ Client::State::resolve_tcp_doh( const std::string& host
auto portn_o = parse::number<unsigned short>(portsv);
if (!portn_o) return or_throw<TcpLookup>(yield, asio::error::invalid_argument);
// Build and return lookup if `host` is already a network address.
{
sys::error_code e;
auto addr = asio::ip::make_address_v4(host, e);
if (!e) return TcpLookup::create(TcpLookup::endpoint_type{move(addr), *portn_o}, host, port);
}
{
sys::error_code e;
auto addr = asio::ip::make_address_v6(host, e);
if (!e) return TcpLookup::create(TcpLookup::endpoint_type{move(addr), *portn_o}, host, port);
}
auto rq_o = doh::build_request(host, ep);
if (!rq_o) return or_throw<TcpLookup>(yield, asio::error::invalid_argument);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment