]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Still working on relaying question
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sat, 19 Jul 2025 16:00:38 +0000 (12:00 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sat, 19 Jul 2025 16:00:38 +0000 (12:00 -0400)
data-feed/feed08.tst
lib/lvleml.c
lib/unidns.c
lib/unidns.h

index a9a66e9f0943f8c831754d31ef08a8aa86dabb2e..1b687b637cbf6bc6531d76fcb12936b8eea57d71 100644 (file)
@@ -17,6 +17,8 @@ R:250 2.1.3 supertool@mxtoolboxsmtpdiag.com.. sender ok
 S:RCPT TO: <webmaster@example.com>
 R:250 2.6.4 Address accepted <webmaster@example.com>
 S:RCPT TO:<test@mxtoolboxsmtpdiag.com>
-R:250 2.6.4 SOULD Be rejected
+R:555 2.7.0 No MX nor IP for for domain <mxtoolboxsmtpdiag.com>
+S:RCPT TO: <user1@posdb.example.com>
+R:250 2.6.4 Address accepted <user1@posdb.example.com>
 S:QUIT
 R:221 2.0.0 Bye, closing connection...
index e39304bcb24eee4a6b9b62be1260f962c5c0c5d5..157b805cb02659bd5080b317c5582602508e8eda 100644 (file)
@@ -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) {
index 6432858908383778a1752ab879c5788efacee67d..6c50eeb5fe7ebf526e5ba5232dcd713d5e40f8ac 100644 (file)
@@ -5,6 +5,7 @@
 /*     exchange.                                       */
 /*                                                     */
 /********************************************************/
+#include        <arpa/inet.h>
 #include        <errno.h>
 #include        <malloc.h>
 #include        <resolv.h>
@@ -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             */
index 27547b628fad4e5bc072440588fc88208290f891..2f0b111f20c972fd474eb5a1337a59b04adb7ac0 100644 (file)
@@ -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);