File getaddrinfo.patch of Package darkstat

--- a/dns.c	2022-02-22 00:20:44.069669211 +0200
+++ b/dns.c	2022-02-22 19:14:35.446932383 +0200
@@ -340,7 +340,8 @@
          struct dns_reply reply;
          struct sockaddr_in sin;
          struct sockaddr_in6 sin6;
-         struct hostent *he;
+         int errcode;
+         struct addrinfo hints, *res;
          char host[NI_MAXHOST];
          int ret, flags;
 
@@ -356,16 +357,18 @@
                ret = getnameinfo((struct sockaddr *) &sin, sizeof(sin),
                                  host, sizeof(host), NULL, 0, flags);
                if (ret == EAI_FAMILY) {
-                  verbosef("getnameinfo error %s, trying gethostbyname",
-                     gai_strerror(ret));
-                  he = gethostbyaddr(&sin.sin_addr.s_addr,
-                     sizeof(sin.sin_addr.s_addr), sin.sin_family);
-                  if (he == NULL) {
+                  verbosef("getnameinfo error %s, trying getaddrinfo", gai_strerror(ret));
+                  memset (&hints, 0, sizeof (hints));
+                  hints.ai_family = AF_INET;
+                  hints.ai_socktype = SOCK_STREAM;
+                  hints.ai_flags |= AI_CANONNAME;
+                  errcode = getaddrinfo(host, NULL, &hints, &res);
+                  if (errcode != 0) {
                      ret = EAI_FAIL;
-                     verbosef("gethostbyname error %s", hstrerror(h_errno));
+                     verbosef("getaddrinfo error %s", gai_strerror(ret));
                   } else {
                      ret = 0;
-                     strlcpy(host, he->h_name, sizeof(host));
+                     strlcpy(host, res->ai_canonname, sizeof(host));
                   }
                }
                break;
openSUSE Build Service is sponsored by