MXS-2546 Add DNS-resolving to topology detection

When matching hostnames between MaxScale server configuration and the
SHOW SLAVE STATUS-output, use DNS-resolution if a simple string comparison
doesn't find an answer. Results of the resolution are saved to avoid
repeating the operation for the same address.
This commit is contained in:
Esa Korhonen
2019-06-06 11:20:34 +03:00
parent 5df1f2561c
commit d4b712ae84
6 changed files with 140 additions and 7 deletions

View File

@ -109,6 +109,16 @@ inline bool operator!=(const Host& l, const Host& r)
return !(l == r);
}
/**
* Perform DNS resolution on a hostname or text-form IP address.
*
* @param host Hostname to convert.
* @param addr_out Output buffer. The output is in IPv6-form as returned by "inet_ntop(AF_INET6, ...)".
* @param error_out Error output
* @return True if successful
*/
bool name_lookup(const std::string& host, std::string* addr_out, std::string* error_out = nullptr);
/**
* Perform reverse DNS on an IP address. This may involve network communication so can be slow.
*
@ -116,5 +126,5 @@ inline bool operator!=(const Host& l, const Host& r)
* @param output Where to write the output. If operation fails, original IP is written.
* @return True on success
*/
bool reverse_dns(const std::string& ip, std::string* output);
bool reverse_name_lookup(const std::string& ip, std::string* output);
}