Boost logo

Boost :

Subject: [boost] Unexpected behavior in reverse lookup (asio resolver)
From: LC (myLC_at_[hidden])
Date: 2018-09-18 13:36:17


When performing a reverse lookup of an address:

*r->async_resolve( boost::asio::ip::tcp::resolver::endpoint_type( adr, 80 )
...*

the address itself is returned (as string), when the name of the host cannot
be found. I would expect an error/exception, telling me this instead.

Consider the following (custom class which does both):
*Resolver::resolve< ResolverClass >( &rc, "www.yahoo.com", 1 );
Resolver::resolve< ResolverClass >( &rc, "8.8.8.8", 2 );
Resolver::resolve< ResolverClass >( &rc, "none.exist.end", 3 );
Resolver::resolve< ResolverClass >( &rc, "2.18.77.109", 4 );
Resolver::resolve< ResolverClass >( &rc, "198.252.206.16", 5 );
Resolver::resolve< ResolverClass >( &rc, "234.255.173.123", 6 );*

And the result:
*1: hostname: www.yahoo.com, address: 87.248.98.7, error:
1: hostname: www.yahoo.com, address: 87.248.98.8, error:
2: hostname: google-public-dns-a.google.com, address: 8.8.8.8, error:
3: hostname: , address: 0.0.0.0, error: Host not found (authoritative)
4: hostname: a2-18-77-109.deploy.static.akamaitechnologies.com, address:
2.18.77.109, error:
5: hostname: stackoverflow.com, address: 198.252.206.16, error:
6: hostname: 234.255.173.123, address: 234.255.173.123, error:*

2 is looking up of "8.8.8.8", which of course can be found and returns the
google.com entry.
Likewise, 4 and 5 can be found and return the correct result.
*Nr. 6, however, is a non-existent ip-address. As you can see, instead of an
error, the address itself is returned when calling
"endpoint_iterator->host_name();".*
This is unexpected and (I think) undocumented. It can be easily detected by
testing if host_name returns an address, but this would require another
(test) conversion; as a result you'd end up with forth&back conversions.

Wouldn't it be better, if the reverse lookup returned an error/exception, if
the name of the host cannot be found? This would be more consistent with the
"Host not found (authoritative)" error in example 3.

--
Sent from: http://boost.2283326.n4.nabble.com/Boost-Dev-f2600599.html

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk