From: Jean-Marc Pigeon (Delson) Date: Sat, 19 Jul 2025 16:00:38 +0000 (-0400) Subject: Still working on relaying question X-Git-Tag: tag-0.14~44 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=7d283e186dd260f388fa5f9d6e8ef551feeba16d;p=jmp%2Fmailleur Still working on relaying question --- diff --git a/data-feed/feed08.tst b/data-feed/feed08.tst index a9a66e9..1b687b6 100644 --- a/data-feed/feed08.tst +++ b/data-feed/feed08.tst @@ -17,6 +17,8 @@ R:250 2.1.3 supertool@mxtoolboxsmtpdiag.com.. sender ok S:RCPT TO: R:250 2.6.4 Address accepted S:RCPT TO: -R:250 2.6.4 SOULD Be rejected +R:555 2.7.0 No MX nor IP for for domain +S:RCPT TO: +R:250 2.6.4 Address accepted S:QUIT R:221 2.0.0 Bye, closing connection... diff --git a/lib/lvleml.c b/lib/lvleml.c index e39304b..157b805 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -945,7 +945,13 @@ while (proceed==true) { } } break; - case 1 : //is the domain with an IP address + case 1 : { //is the domain with an IP address + char **iplist; + + if ((iplist=dns_get_ip_list(rmtusr->domain))==(char **)0) + phase=999; //not even an IP for domain + iplist=(char **)rou_freelist((void **)iplist,(genfree_t)rou_freestr); + } break; case 2 : //is connection acceptable switch (contact->privilege) { diff --git a/lib/unidns.c b/lib/unidns.c index 6432858..6c50eeb 100644 --- a/lib/unidns.c +++ b/lib/unidns.c @@ -5,6 +5,7 @@ /* exchange. */ /* */ /********************************************************/ +#include #include #include #include @@ -249,6 +250,89 @@ return inftxt; */ /********************************************************/ /* */ +/* Routine to extract ipaddr from addr */ +/* */ +/********************************************************/ +static char *addrip(struct addrinfo *addinf) + +{ +static char straddr[INET6_ADDRSTRLEN]; + +char *ipaddr; +void *addr; + +ipaddr=straddr; +addr=(void *)0; +switch (addinf->ai_family) { + case AF_INET6 : /*IPV6 */ + addr=&(((struct sockaddr_in6 *)addinf->ai_addr)->sin6_addr); + break; + case AF_INET : /*IPV4 */ + default : + addr=&(((struct sockaddr_in *)addinf->ai_addr)->sin_addr); + break; + } +if (inet_ntop(addinf->ai_family,addr,straddr,sizeof(straddr))==(char *)0) { + (void) rou_alert(0,"%s Unable to find IP for hostname <%s> (error=<%s>)", + "unidns.c:dns_addrip,",addinf->ai_canonname,strerror(errno)); + ipaddr=(char *)0; + } +return ipaddr; +} +/* +^L +*/ +/********************************************************/ +/* */ +/* Routine to extract iplist in string format from */ +/* addr list. */ +/* */ +/********************************************************/ +static char **addriplist(struct addrinfo *addrlst) + +{ +char **iplist; +struct addrinfo *pif; + +iplist=(char **)0; +for (pif=addrlst;pif!=(struct addrinfo *)0;pif=pif->ai_next) { + char *straddr; + + if ((straddr=addrip(pif))!=(char *)0) + iplist=(char **)rou_addlist((void **)iplist,(void *)strdup(straddr)); + } +return iplist; +} +/* +^L +*/ +/********************************************************/ +/* */ +/* Procedure to extract IPs from an hostname */ +/* */ +/********************************************************/ +PUBLIC char **dns_get_ip_list(char *hostname) + +{ +char **iplst; +struct addrinfo hints; +struct addrinfo *res; + +iplst=(char **)0; +(void) memset(&hints,'\000',sizeof(hints)); +hints.ai_family=PF_UNSPEC; +hints.ai_socktype=SOCK_STREAM; +if (getaddrinfo(hostname,(char *)0,&hints,&res)==0) { + iplst=addriplist(res); + (void) freeaddrinfo(res); + } +return iplst; +} +/* +^L +*/ +/********************************************************/ +/* */ /* Procedure to extract a hostname SPF */ /* Search first for an SPF record, if not */ /* implemented search for a TXT record */ diff --git a/lib/unidns.h b/lib/unidns.h index 27547b6..2f0b111 100644 --- a/lib/unidns.h +++ b/lib/unidns.h @@ -26,6 +26,9 @@ typedef enum { //domain MX status dns_unknown //Unknow domain status. }LOCTYP; +//Procedure to get a list of IP related to a hostname +extern char **dns_get_ip_list(char *hostname); + //Procedure to get ONE SPF entry within domain dns extern char *dns_getspf(char *domain);