14{
15 std::vector<std::string> output;
16
18
19 struct addrinfo* result;
20 auto s = getaddrinfo(hostname.c_str(), nullptr, nullptr, &result);
21
22 if (s != 0) {
24 return output;
25 }
26
27 for (auto rp = result; rp != nullptr; rp = rp->ai_next) {
28 char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
29
30
31 if (rp->ai_family == AF_INET6)
32 continue;
33
34 getnameinfo(rp->ai_addr, rp->ai_addrlen, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV);
35 auto result = std::string(hbuf);
36 bool duplicate = false;
37 for (auto& res : output) {
38 if (res == result) {
39 duplicate = true;
40 break;
41 }
42 }
43 if (!duplicate) {
44 TLOG_DEBUG(13) <<
"Found address " << result <<
" for hostname " << hostname;
45 output.push_back(result);
46 }
47 }
48
49 freeaddrinfo(result);
50
51 return output;
52}
#define TLOG_DEBUG(lvl,...)
void error(const Issue &issue)