]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Improving received header insertion
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Thu, 22 May 2025 18:42:13 +0000 (14:42 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Thu, 22 May 2025 18:42:13 +0000 (14:42 -0400)
data-feed/feed02.tst
data-feed/xxfeed.tst
lib/devsoc.c
lib/lvleml.c
lib/lvleml.h

index cff9b248524c8675ec64d3813040c960639b3ce6..050495784749a25a3d9df39ba12e224e698dde65 100644 (file)
@@ -6,6 +6,8 @@ R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
 S:HELO example.com
 #R:250-mailleur.example.com, link (cleartext) ready, your IP/FQDN=[127.127.0.2/feed2.example.com]
 R:250-mailleur.example.com, link (cleartext) ready,...
+C:GOTLS
+R:250 Link now encryp...
 S:MAIL FROM: <postmaster@example.com>
 R:250 2.1.3 postmaster@example.com.. sender ok
 S:RCPT TO: <webmaster@example.com>
index cff9b248524c8675ec64d3813040c960639b3ce6..050495784749a25a3d9df39ba12e224e698dde65 100644 (file)
@@ -6,6 +6,8 @@ R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
 S:HELO example.com
 #R:250-mailleur.example.com, link (cleartext) ready, your IP/FQDN=[127.127.0.2/feed2.example.com]
 R:250-mailleur.example.com, link (cleartext) ready,...
+C:GOTLS
+R:250 Link now encryp...
 S:MAIL FROM: <postmaster@example.com>
 R:250 2.1.3 postmaster@example.com.. sender ok
 S:RCPT TO: <webmaster@example.com>
index 1d8d2913664063a2a300336b87c6c617316927f4..1de5f007bdd4b0b95cfd1301e114689ba4943aed 100644 (file)
@@ -1349,7 +1349,10 @@ if (soc!=(SOCTYP *)0) {
           data=strdup(host);
           break;
         case false      :
-          data=strdup(serv);
+          char local[NI_MAXHOST+NI_MAXSERV+1];
+
+          (void) snprintf(local,sizeof(local),"%s:%s",host,serv);
+          data=strdup(local);
           break;
         }
       break;
index c8876c800b2b308749201e255eed9b6695fe56f9..b9a6d5df7452bd48ea357668952af0e035725fbe 100644 (file)
@@ -47,8 +47,9 @@ if (contact!=(CONTYP *)0) {
   contact->fqdn=rou_freestr(contact->fqdn);
   contact->peername=rou_freestr(contact->peername);
   contact->peerip=rou_freestr(contact->peerip);
-  contact->locname=rou_freestr(contact->locname);
   contact->locserv=rou_freestr(contact->locserv);
+  contact->locip=rou_freestr(contact->locip);
+  contact->locname=rou_freestr(contact->locname);
   (void) free(contact);
   contact=(CONTYP *)0;
   }
@@ -188,13 +189,43 @@ static _Bool addreceived(CONTYP *contact,FILE *data)
 
 {
 _Bool status;
+time_t curtime;
+int phase;
+_Bool proceed;
 
 status=true;
-(void) fprintf(data,"Received: from %s ([%s])\n",contact->peername,contact->peerip);
-(void) fprintf(data,"\t by %s ([%s]/%s-%s)\n",
-                    contact->locname,contact->locserv,
-                    appname,rou_getversion());
-(void) fprintf(data,"\t id <%s@%s>;\n",contact->cursesid,contact->locname);
+curtime=time((time_t *)0);
+phase=0;
+proceed=true;
+while (proceed==true) {
+  switch (phase) {
+    case 0      :       //Inserting the remote information
+      (void) fprintf(data,"Received: from %s ([%s])\n",
+                           contact->peername,contact->peerip);
+      break;
+    case 1      :       //Inserting the Receive information
+      (void) fprintf(data,"\tby %s ([%s:%s]/%s-%s) with ESMTP\n",
+                          contact->locname,contact->locip,contact->locserv,
+                          appname,rou_getversion());
+      break;
+    case 2      :       //Inserting TLS information
+      if (soc_iscrypted(contact->socptr)==true) {
+        (void) fprintf(data,"\t(JMPDBG crypted)\n");
+        }
+      break;
+    case 3      :       //Inserting ID information
+      (void) fprintf(data,"\tid <%s@%s>;\n",
+                          contact->cursesid,contact->locname);
+      break;
+    case 4      :       //date information
+      (void) fprintf(data,"\t%s\n",rou_ascsysstamp(curtime));
+      break;
+    default     :       //SAFE Guard
+      proceed=false;
+      break;
+    }
+  phase++;
+  }
 return status;
 }
 /*
@@ -828,7 +859,16 @@ while (proceed==true) {
       contact->mainsesid=eml_getmainsesid();
       contact->cursesid=eml_getcursesid(contact->mainsesid,contact->numreset);
       contact->locname=soc_getaddrinfo(contact->socptr,true,true);
-      contact->locserv=soc_getaddrinfo(contact->socptr,true,false);
+      contact->locip=soc_getaddrinfo(contact->socptr,true,false);
+      if (contact->locip!=(char *)0) {
+        char *ptr;
+        
+        //extracting service port number
+        if ((ptr=strrchr(contact->locip,':'))!=(char *)0) {
+          *ptr='\000';
+          contact->locserv=strdup(ptr+1);
+          }
+        }
       contact->peername=soc_getaddrinfo(contact->socptr,false,true);
       contact->peerip=soc_getaddrinfo(contact->socptr,false,false);
       contact->logptr=log_openlog(contact->mainsesid,true);
index bc49ba895476bd702492a0f8e31fb82dd3440533..6d6c2168738721068bfcdd799f0c271f4045d875 100644 (file)
@@ -19,6 +19,7 @@ typedef struct  {
         SQLPTR *sqlptr;         //established contact database access
         char *fqdn;             //fully qualified domain from peer
         char *locname;          //socket local hostname
+        char *locip;            //socket local IP num
         char *locserv;          //local service port
         char *peerip;           //socket remote peer IP
         char *peername;         //socket remote peer FQDN