Skip to content

Commit

Permalink
Reinforced the implementation of the FQDN resolver
Browse files Browse the repository at this point in the history
The previous version was prone to crashes when DNS was not returning
a well-formed result.
  • Loading branch information
iagaponenko committed Jan 29, 2025
1 parent 4776612 commit a0a28f6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/util/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ string get_current_host_fqdn(bool all) {
hints.ai_family = AF_UNSPEC; /* either IPV4 or IPV6 */
hints.ai_socktype = SOCK_STREAM; /* IP */
hints.ai_flags = AI_CANONNAME; /* canonical name */
hints.ai_canonname = NULL;
struct addrinfo* info;
while (true) {
int const retCode = getaddrinfo(hostname.data(), "http", &hints, &info);
Expand All @@ -63,6 +64,7 @@ string get_current_host_fqdn(bool all) {
}
string fqdn;
for (struct addrinfo* p = info; p != NULL; p = p->ai_next) {
if (p->ai_canonname == NULL) continue;
if (!fqdn.empty()) {
if (!all) break;
fqdn += ",";
Expand Down

0 comments on commit a0a28f6

Please sign in to comment.