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