- /* Initialize pipe for result */
- if( pipe( s->pipe ) != 0 )
- {
- free( s );
- Log( LOG_ALERT, "Resolver: Can't create output pipe: %s!", strerror( errno ));
- return NULL;
+ array_init(&resolved_addr);
+ ng_ipaddr_tostr_r(Addr, tmp_ip_str);
+#ifdef DEBUG
+ Log_Subprocess(LOG_DEBUG, "Now resolving %s ...", tmp_ip_str);
+#endif
+ if (!ReverseLookup(Addr, hostname, sizeof(hostname)))
+ goto dns_done;
+
+ if (ForwardLookup(hostname, &resolved_addr, ng_ipaddr_af(Addr))) {
+ if (!Addr_in_list(&resolved_addr, Addr)) {
+ Log_Forgery_WrongIP(tmp_ip_str, hostname);
+ strlcpy(hostname, tmp_ip_str, sizeof(hostname));
+ }
+ } else {
+ Log_Forgery_NoIP(tmp_ip_str, hostname);
+ strlcpy(hostname, tmp_ip_str, sizeof(hostname));
+ }
+#ifdef DEBUG
+ Log_Subprocess(LOG_DEBUG, "Ok, translated %s to \"%s\".", tmp_ip_str, hostname);
+#endif
+ dns_done:
+ len = strlen(hostname);
+ hostname[len] = '\n';
+ if (!array_copyb(&resolved_addr, hostname, ++len)) {
+ Log_Subprocess(LOG_CRIT,
+ "Resolver: Can't copy resolved name: %s!",
+ strerror(errno));
+ array_free(&resolved_addr);
+ return;