Skip to content

Commit

Permalink
Show IP address as well as hostnames
Browse files Browse the repository at this point in the history
Issue White-Tiger#11 of White-Tiger version
  • Loading branch information
LatinSuD authored Aug 12, 2022
1 parent 8a0df70 commit 24b5be0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/WinMTRNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,18 @@ void DnsResolverThread(void* p)
}
if(wn->wmtrdlg->useDNS) {
TRACE_MSG("DNS resolver thread started.");
if(!getnameinfo(wn->GetAddr(dnt->index),sizeof(sockaddr_in6),hostname,NI_MAXHOST,NULL,0,0)) {
wn->SetName(dnt->index,hostname);
if (!getnameinfo(wn->GetAddr(dnt->index), sizeof(sockaddr_in6), hostname, NI_MAXHOST, NULL, 0, 0)) {
char ip[NI_MAXHOST];
wn->GetName(dnt->index, ip);
if (strcmp(hostname, ip) != 0) {
// Append IP to hostname
char final_name[NI_MAXHOST];
snprintf(final_name, NI_MAXHOST - 1, "%s (%s)", hostname, ip);
wn->SetName(dnt->index, final_name);
}
else {
wn->SetName(dnt->index, hostname);
}
}
TRACE_MSG("DNS resolver thread stopped.");
}
Expand Down

0 comments on commit 24b5be0

Please sign in to comment.