fix code for certain types of /etc/hosts files
authorChristian Grothoff <christian@grothoff.org>
Thu, 8 Oct 2009 09:56:40 +0000 (09:56 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 8 Oct 2009 09:56:40 +0000 (09:56 +0000)
src/util/resolver_api.c

index b86e5c6669e0165df0e2b548b6e7a91ec1835964..cc81aa6b8bdcf682db25de71326ec572259b0b6d 100644 (file)
@@ -311,7 +311,7 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched,
   v6.sin6_len = sizeof(v6);
 #endif
   /* first, check if this is a numeric address */
-  if ( ( (domain == AF_UNSPEC) ||(domain == AF_INET) ) && 
+  if ( ( (domain == AF_UNSPEC) || (domain == AF_INET) ) && 
        (0 == inet_pton (AF_INET,
                        hostname,
                        &v4.sin_addr)) )
@@ -319,7 +319,17 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched,
       callback (callback_cls,
                (const struct sockaddr*) &v4,
                sizeof(v4));
-      callback (callback_cls, NULL, 0);
+      if ( (domain == AF_UNSPEC) && 
+          (0 == inet_pton (AF_INET6,
+                           hostname,
+                           &v6.sin6_addr)) )
+       {
+         /* this can happen on some systems IF "hostname" is "localhost" */
+         callback (callback_cls,
+                   (const struct sockaddr*) &v6,
+                   sizeof(v6));
+       }
+      callback (callback_cls, NULL, 0);      
       return;
     }
   if ( ( (domain == AF_UNSPEC) ||(domain == AF_INET) ) &&