static char *
lookup_node_ip(const char *nodename)
{
+ char buf[INET6_ADDRSTRLEN];
struct addrinfo *ainfo;
struct addrinfo ahints;
memset(&ahints, 0, sizeof(ahints));
return NULL;
if (ainfo->ai_family == AF_INET) {
- char buf[INET6_ADDRSTRLEN];
struct sockaddr_in *sa = (struct sockaddr_in *)ainfo->ai_addr;
inet_ntop(ainfo->ai_family, &sa->sin_addr, buf, sizeof(buf));
if (strncmp(buf, "127.", 4) != 0) {
}
}
- // ipv6 support ?
+ if (ainfo->ai_family == AF_INET6) {
+ struct sockaddr_in6 *sa = (struct sockaddr_in6 *)ainfo->ai_addr;
+ inet_ntop(ainfo->ai_family, &sa->sin6_addr, buf, sizeof(buf));
+ if (strcmp(buf, "::1") != 0) {
+ return g_strdup(buf);
+ }
+ }
return NULL;
}