Continue name resolution fixing, add unit test

name_lookup() now returns all results given by getnameinfo(). When searching
for a server, finding one matching address in the lookup-results is enough for
a match.

Also, added a test for name_lookup(). The test is minimal on its own, as hardcoded
test cases are not generally valid.
This commit is contained in:
Esa Korhonen
2019-08-15 15:37:46 +03:00
parent 29ec15c8eb
commit e6bf020b9e
7 changed files with 142 additions and 43 deletions

View File

@ -172,12 +172,13 @@ private:
class DNSResolver
{
public:
std::string resolve_server(const std::string& host);
using StringSet = std::unordered_set<std::string>;
StringSet resolve_server(const std::string& host);
private:
struct MapElement
{
std::string address;
StringSet addresses; // A hostname can map to multiple addresses
mxb::TimePoint timestamp;
};