]> SAFE projects GIT repository - jmp/mailleur/commitdiff
onefeed is NOT able to feed connection
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 11 Jun 2025 16:35:54 +0000 (12:35 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 11 Jun 2025 16:35:54 +0000 (12:35 -0400)
lib/Makefile
lib/devsoc.c
lib/devsoc.h
lib/lvleml.c
lib/modrec.c
lib/unidns.c
lib/unidns.h
lib/unitls.c
lib/unitls.h

index 0dd77ab4af859c02e66ec9cad2ab86b8ce187197..615702d77a1a7ccaa8dcfdc9bb73a731f1498e73 100644 (file)
@@ -74,7 +74,7 @@ devsql.o:                                     \
           devsql.h devsql.c
 
 unidns.o:                                      \
-          subrou.h                             \
+          subafn.h subrou.h                    \
           unidns.h unidns.c
 
 unieml.o:                                      \
index 04c93320e8b055dc399d5724e60010b1a78c94ee..38f741b48043d6c682f76879c337e94cb732b183 100644 (file)
@@ -595,7 +595,7 @@ return socptr;
 /*     definition.                                     */
 /*                                                     */
 /********************************************************/
-PUBLIC SOCPTR **soc_mkbindinf(SOCPTR **socptr,LISTYP *bind)
+PUBLIC SOCPTR **soc_mkbindinf(SOCPTR **socptr,const LISTYP *bind)
 
 {
 SOCTYP *soc;
@@ -746,8 +746,8 @@ while (proceed==true) {
       break;
     case 8      :       //checking socket status
       if ((status=checksockstat(handle))!=0) {
-        (void) rou_alert(0,"%s  Unable establish socklink with <%s> (error=<%s>)",
-                           OPEP,ip,strerror(status));
+        (void) rou_alert(0,"%s  Unable establish socklink with <%s:%s> (error=<%s>)",
+                           OPEP,ip,port,strerror(status));
         (void) close(handle);
         phase=999;
         }
index 1dddfdcc8e58d38f33e14f446323bcb4d8976b69..7e73072c50143bf08f51dd5356c680e0cbbc1d25 100644 (file)
@@ -29,7 +29,7 @@ extern SOCPTR **soc_freebindinf(SOCPTR **socptr);
 
 //procedure to assign memory to be used by a TCP socket
 //definition
-extern SOCPTR **soc_mkbindinf(SOCPTR **s,LISTYP *bind);
+extern SOCPTR **soc_mkbindinf(SOCPTR **socptr,const LISTYP *bind);
 
 //procedure to open one exchange socket
 //to connect a remote smtp server
index 95b85737a21ef7ff909b4d4205fd05874029bc31..96e1ee057b795057ffb4839f11d78de403c45b50 100644 (file)
@@ -91,7 +91,7 @@ while (proceed==true) {
     case 1      :       //check about local domain, TEMPORARY code
       int status;
 
-      status=dns_is_domain_local(rcpt->domain);
+      status=dns_is_domain_local(rcpt->domain,tls_get_bind_afn());
       switch (status) {
         case dns_nomx   :
           done=false;
index a62f1a9c0f6292f27c97ae7cefb646a1aff4aa13..21298012c9e56a4f070347c0fbea5207cb2759c8 100644 (file)
@@ -46,10 +46,10 @@ static int prepbinding(SOCPTR ***bindings)
 {
 #define OPEP    "modrec.c:prepbinding"
 
-LISTYP **bind;
+const LISTYP **bind;
 
 *bindings=(SOCPTR **)0;
-if ((bind=tls_get_bind_data())==(LISTYP **)0) {
+if ((bind=tls_get_bind_data())==(const LISTYP **)0) {
   (void) rou_alert(0,"%s SMTPPORTS data fully missing (config?, bug?)",OPEP);
   (void) exit(-1);
   }
index 41db7e3200ce6cec614fcb4215d4403910bb46fa..9ca296c84d16e1860f2ed0168a96e7adadfa493d 100644 (file)
@@ -26,10 +26,6 @@ typedef      union   {
         u_char buf[B64K];      //according US Cert VU#738331
        }RSPTYP;
 
-//list of SMTP local IPV4
-in_addr_t *local_ipv4=(in_addr_t  *)0;
-int num_ipv4=0;                 //number of IP within local_ipv4
-
 /*
 \f
 */
@@ -478,7 +474,7 @@ return match;
 /*     local interface (serveur is primary MX).        */
 /*                                                     */
 /********************************************************/
-PUBLIC LOCTYP dns_is_domain_local(const char *domain)
+PUBLIC LOCTYP dns_is_domain_local(const char *domain,AFNTYP **afns)
 
 
 {
@@ -490,6 +486,7 @@ int phase;
 _Bool proceed;
 
 status=dns_nomx;
+dns=(MXTYP **)0;
 phase=0;
 proceed=true;
 while (proceed==true) {
@@ -502,20 +499,22 @@ while (proceed==true) {
       if ((dns=dns_getmx(domain))==(MXTYP **)0)
         phase=999;      //domain without MX?
       break;
-    case 2      :       //listing MX
-      MXTYP **ptr;
-
-      ptr=dns;
-      while ((*ptr)!=(MXTYP *)0) {
-        (void) rou_alert(0,"%s JMPDBG pref='%d' mxname=<%s>",
-                            OPEP,(*ptr)->preference,(*ptr)->mxname);
-        ptr++;
-        }
+    case 2      :       //establishing MX IP
+      status=dns_remote;
+      if (afns==(AFNTYP **)0)     //No local IP?
+        phase=999;
       break;
-    case 3      :       //cleaning MX list
-      dns=dns_freemxlist(dns);
+    case 3      :       //checking best MX with local interface
+      while (*afns!=(AFNTYP *)0) {
+        if (dns_matchiprec((*dns)->mxname,*afns,32)==true) {
+          (void) rou_alert(0,"%s JMPDBG mxname=<%s> is local",OPEP,(*dns)->mxname);
+          status=dns_local;
+          }
+        afns++;
+        }
       break;
     default     :       //SAFE Guard
+      dns=dns_freemxlist(dns);  //cleaning MX
       proceed=false;
       break;
     }
index 1114ee8b31903fe0310a197dae1a89022d2a6659..1e58cfa8c03cb76ced0973d093bdc1e951390cea 100644 (file)
@@ -40,6 +40,6 @@ extern _Bool dns_matchiprec(char *hostname,AFNTYP *afnnum,int mask);
 
 //procedure to detect if a domain is served by a local
 //smtp server
-extern LOCTYP dns_is_domain_local(const char *domain);
+extern LOCTYP dns_is_domain_local(const char *domain,AFNTYP **afns);
 
 #endif
index 40f616c7de7c6deb3ae0736793ed4a10bb664ba7..4b2e188f94c7fb4b85ca8ad2253702c00a435314 100644 (file)
@@ -23,7 +23,8 @@
 #define SSL_CIPHER_LIST "DEFAULT"
 
 static  _Bool modopen;          //module open/close status
-static  LISTYP **binds;         //Binding information
+static const  LISTYP **binds;   //Binding information
+static        AFNTYP **afns;    //Binding information as AFN
 /*
 ^L
 */
@@ -476,7 +477,7 @@ while (proceed==true) {
               if (strlen(seq)==0)
                 seq=DIP;
               if ((afn=afn_getipnum(seq))==(AFNTYP *)0)
-                (void) rou_alert(0,"%s, Not valid IP <%s> config",OPEP,seq);
+                (void) rou_alert(0,"%s, Not valid IP <%s> (config?)",OPEP,seq);
               break;
             case 2      :       
               if (strlen(seq)>0)
@@ -493,7 +494,7 @@ while (proceed==true) {
           list->port=strdup(port);;
           list->iteration=iteration;
           list->afn=afn;
-          binds=(LISTYP **)rou_addlist((void **)binds,(void *)list);
+          binds=(const LISTYP **)rou_addlist((void **)binds,(void *)list);
           }
         seq=ptr;
         }
@@ -1278,7 +1279,7 @@ return ssl;
 /*     Procedure to return the list of binding data    */
 /*                                                      */
 /********************************************************/
-PUBLIC LISTYP **tls_get_bind_data()
+PUBLIC const LISTYP **tls_get_bind_data()
 
 {
 return binds;
@@ -1288,6 +1289,19 @@ return binds;
 */
 /********************************************************/
 /*                                                      */
+/*     Procedure to return the AFN list of binding data*/
+/*                                                      */
+/********************************************************/
+PUBLIC AFNTYP **tls_get_bind_afn()
+
+{
+return afns;
+}
+/*
+^L
+*/
+/********************************************************/
+/*                                                      */
 /*     Procedure to "open/close" module and do         */
 /*      homework purpose                                */
 /*      return zero if everything right                 */
@@ -1310,6 +1324,7 @@ if (mode!=modopen) {
       (void) buildbinds();
       break;
     case false    :
+      (void) free(afns);
       (void) rou_freelist((void **)binds,(genfree_t)freelisten);
       break;
     default       :
index 1efce0028235a6d56f720b6eb83dca9cb481ffa1..d4356ca0c7ffee7fab10b8b97e0693e6ec4e36f7 100644 (file)
@@ -78,7 +78,10 @@ extern int tls_check_peer(TLSTYP *tls);
 extern SSL *tls_setsocket(int handle,SSL_CTX *ctx);
 
 //getting binding information
-extern LISTYP **tls_get_bind_data();
+extern const LISTYP **tls_get_bind_data();
+
+//getting binding information as AFN structure
+extern AFNTYP **tls_get_bind_afn();
 
 //homework to be done before starting/stopping module.
 extern int tls_modeunitls(_Bool mode);