--- helodnscheck2.c.orig 2011-06-15 22:30:55.571844910 +0200 +++ helodnscheck2.c 2011-06-16 08:17:36.919991526 +0200 @@ -17,6 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *** +* 2011-06-16 Modified to work in dualstack environment +* (IPv6 support) Carsten Schoene * 1/16 Modified original version to check helo/ehlo instead of mail from *** * @@ -80,6 +82,7 @@ char *remote_ip = getenv("TCPREMOTEIP"); char *action = getenv("HELO_DNS_CHECK"); struct hostent* result; + int fIPv4 = 0; if (!action) { action = ""; @@ -101,11 +104,15 @@ return 0; } + fIPv4 = (NULL == strchr(remote_ip, ':')); /* init DNS library */ res_init(); /* check A record */ + if (!fIPv4) { + _res.options |= RES_USE_INET6; + } result = gethostbyname(helo_domain); /* check if there is any result */ @@ -175,7 +182,11 @@ count=0; while (result->h_addr_list[count] && (found==0)) { addr=result->h_addr_list[count]; - inet_ntop(AF_INET, addr, print_address, 1000); + if (!fIPv4) { + inet_ntop(AF_INET6, addr, print_address, 1000); + } else { + inet_ntop(AF_INET, addr, print_address, 1000); + } if (strcmp(print_address, remote_ip) == 0) { found = 1; };