-#ifdef IDENTAUTH
- /* Do "IDENT" (aka "AUTH") lookup and append result to resolved_addr array */
- Log_Resolver( LOG_DEBUG, "Doing IDENT lookup on socket %d ...", Sock );
- res = ident_id( Sock, 10 );
- Log_Resolver( LOG_DEBUG, "Ok, IDENT lookup on socket %d done: \"%s\"", Sock, res ? res : "" );
-
- if (res) {
- if (!array_cats(&resolved_addr, res))
- Log_Resolver(LOG_WARNING, "Resolver: Cannot copy IDENT result: %s!", strerror(errno));
- /* try to omit ident and return hostname only */
+ Log_Subprocess(LOG_WARNING, "%s: Can't resolve address \"%s\": %s",
+ funcname, tmp_ip_str, errmsg);
+ strlcpy(resbuf, tmp_ip_str, reslen);
+ return false;
+}
+
+
+/**
+ * perform DNS lookup of given host name and fill IpAddr with a list of
+ * ip addresses associated with that name.
+ * ip addresses found are stored in the "array *IpAddr" argument (type ng_ipaddr_t)
+ * @param hostname The domain name to look up.
+ * @param IpAddr pointer to empty and initialized array to store results
+ * @return true if lookup successful, false if domain name not found
+ */
+static bool
+ForwardLookup(const char *hostname, array *IpAddr)
+{
+ ng_ipaddr_t addr;
+
+#ifdef HAVE_GETADDRINFO
+ int res;
+ struct addrinfo *a, *ai_results;
+ static struct addrinfo hints;
+
+#ifndef WANT_IPV6
+ hints.ai_family = AF_INET;
+#endif
+#ifdef AI_ADDRCONFIG /* glibc has this, but not e.g. netbsd 4.0 */
+ hints.ai_flags = AI_ADDRCONFIG;
+#endif
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_protocol = IPPROTO_TCP;
+
+#ifdef WANT_IPV6
+ assert(Conf_ConnectIPv6 || Conf_ConnectIPv4);
+
+ if (!Conf_ConnectIPv6)
+ hints.ai_family = AF_INET;
+ if (!Conf_ConnectIPv4)
+ hints.ai_family = AF_INET6;
+#endif
+ memset(&addr, 0, sizeof(addr));
+
+ res = getaddrinfo(hostname, NULL, &hints, &ai_results);
+ switch (res) {
+ case 0: break;
+ case EAI_SYSTEM:
+ Log_Subprocess(LOG_WARNING, "Can't resolve \"%s\": %s", hostname, strerror(errno));
+ return false;
+ default:
+ Log_Subprocess(LOG_WARNING, "Can't resolve \"%s\": %s", hostname, gai_strerror(res));
+ return false;