]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Better doconnect within feeder.c
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 17 Aug 2025 11:18:13 +0000 (07:18 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 17 Aug 2025 11:18:13 +0000 (07:18 -0400)
Makefile
app/feeder.c
data-feed/feed000.tst
data-feed/feed001.tst
data-feed/feed002.tst
data-feed/feed003.tst
data-feed/feed004.tst
data-feed/feed010.tst [new file with mode: 0644]
data-feed/feedx11.tst [deleted file]

index 200ade298f14bb6bde66f494876ac476e1d7e996..816dd792dc95033fc0c8ce13b1f48266f870ddfc 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -67,10 +67,10 @@ dbgfeed     :  debug
                        bin-utils/feeder                \
                          -f                            \
                          -d 2                          \
-                         -c ./conf/feeder.conf.dvl     \
+                         -c ./conf/$(APPNAME).conf.dvl \
                          $(TESTIP)                     \
                          $(TESTPORT)                   \
-                         $(DATATST)/$(ONEFEED)
+                         ./$(DATATST)/$(ONEFEED).tst
 
 valfeed        :  debug                        #valgring of emlrcvr
           @ echo "feed valgrind test"
index 48f60db0583c14600dabbef43395e69420dcb2dc..e5c7fd04a4f91b42e3496079db38d16d74fdac02 100644 (file)
@@ -315,16 +315,54 @@ return status;
 static _Bool doconnect(FEEDTYP *fd)
 
 {
+#define OPEP    "feeder.c:doconnect"
+
 _Bool isopen;
+int phase;
+_Bool proceed;
 
 isopen=true;
-if (fd->socptr==(SOCPTR *)0) 
-  fd->socptr=soc_openfeedsock(pro_smtp,fd->srcip,fd->destip,fd->destport);
-if (fd->socptr==(SOCPTR *)0) {
-  (void) rou_alert(0,"Unable to open link to [%s:%s]",fd->destip,fd->destport);
-  isopen=false;
+phase=0;
+proceed=true;
+while (proceed==true) {
+  //(void) rou_alert(0,"%s JMPDBG phase='%d'",OPEP,phase);
+  switch (phase) {
+    case 0      :       //is the connection really open
+      if (fd->socptr==(SOCPTR *)0) {
+        fd->socptr=soc_openfeedsock(pro_smtp,fd->srcip,fd->destip,fd->destport);
+        if (fd->socptr==(SOCPTR *)0) {
+          (void) rou_alert(0,"%s Unable to open link to [%s:%s]",
+                              OPEP,fd->destip,fd->destport);
+          isopen=false;
+          phase=999;
+          }
+        }
+      break;
+    case 1      :       //is the connect really open
+      (void) usleep(100000);    //let wait form remote disconnect
+      if (soc_waitforchar(fd->socptr,10*1000)>=0) {
+        phase=999;      //Yes no need to go further
+        }
+      break;
+    case 2      :       //the remote just disconnect
+      fd->socptr=soc_closefeedsock(fd->socptr); //let clean the link
+      fd->socptr=soc_openfeedsock(pro_smtp,fd->srcip,fd->destip,fd->destport);
+      if (soc_waitforchar(fd->socptr,10*1000)<0) {
+        (void) rou_alert(0,"%s Unable to re-open link to [%s:%s]",
+                            OPEP,fd->destip,fd->destport);
+        isopen=false;
+        phase=999;
+        }
+      break;
+    default     :       //SAFE Guard
+      proceed=false;
+      break;
+    }
+  phase++;
   }
 return isopen;
+
+#undef  OPEP
 }
 /*
 ^L
@@ -601,10 +639,6 @@ while (proceed==true) {
       switch (action) {
         case 'R'        :       //wait Receiving line
         case 'S'        :       //Sending line
-          if (doconnect(fd)==false) {
-            status=false;
-            phase=999;          //Not Connected!
-            }
           break;
         default         :       //Nothing to do
           break;
index 64c1b4b448f8d46a378edf8d080a63b99f75ade4..5d2714d4ccf1a8837404b32d75072b85dbdb9458 100644 (file)
@@ -25,6 +25,7 @@ C:COMMENT START
 #====================================================
 C:COMMENT STOP
 T:(feed000) Sending a very Simple Email with ONE local delivery
+C:CONNECT
 R:220 mailleur.example.com, ESMTP (cleartext) mailleur...
 #====================================================
 S:HELO example.com
index b96ddb7d0415cffd16a7dddaa5b63a8872024aa0..fb7e5e66847b944d913314874232c7fe23ebba6f 100644 (file)
@@ -1,5 +1,6 @@
 #====================================================
 T:(feed001) Sending a a simple mail to remote server
+C:CONNECT
 R:220 mailleur.example.com, ESMTP (cleartext) mailleur...
 #====================================================
 S:EHLO example.com
index 43b85b5af50695df7c1d0d79870b7237740678b5..d3f588caf0ffe629926d8cae8cf51c5f5ad0f6e9 100644 (file)
@@ -1,4 +1,5 @@
 T:(feed002) Sending a very Simple Email to 2 domains
+C:CONNECT
 R:220 mailleur.example.com, ESMTP (cleartext) mailleur...
 #====================================================
 S:HELO example.com
index eb223cc1436ab06030b0a93de1d435dd5ed2f97d..23eae1335877d52d1d9ca785c09cd127fe21738c 100644 (file)
@@ -1,4 +1,5 @@
 T:(feed003) Sending two email within the same session
+C:CONNECT
 R:220 mailleur.example.com, ESMTP (cleartext) mailleur...
 #=========================================================================
 S:HELO example.com
index 598a2d50019fd664998fdcd5ddbe90197e69ed1a..0942767f598e28fc1b2b0a91e8116a304a86ce0b 100644 (file)
@@ -1,4 +1,5 @@
 T:(feed004) Email using UTF-8 characters on local delivery
+C:CONNECT
 R:220 mailleur.example.com, ESMTP (cleartext) mailleur...
 #====================================================
 S:HELO example.com
diff --git a/data-feed/feed010.tst b/data-feed/feed010.tst
new file mode 100644 (file)
index 0000000..5d272e1
--- /dev/null
@@ -0,0 +1,33 @@
+#====================================================
+T:(feed010) Testing if helo and ehlo fdqdn is  OK
+C:CONNECT
+R:220 mailleur.example.com, ESMTP (cleartext) mailleur...
+#====================================================
+S:HELO [129.219.254.34]
+R:501 5.5.4 HELO argument is mandatory, closing connection.
+#====================================================
+C:CONNECT
+R:220 mailleur.example.com, ESMTP (cleartext) mailleur...
+S:EHLO domain
+R:501 5.5.4 syntax error (domain part missing), closing connection.
+#====================================================
+C:CONNECT
+R:220 mailleur.example.com, ESMTP (cleartext) mailleur...
+S:EHLO 8.8.8.8
+R:501 5.5.4 syntax error (domain part missing), closing connection.
+#====================================================
+C:CONNECT
+R:220 mailleur.example.com, ESMTP (cleartext) mailleur...
+S:EHLO [4.4.4.4]
+R:501 5.5.4 syntax error (domain part missing), closing connection.
+#====================================================
+C:CONNECT
+R:220 mailleur.example.com, ESMTP (cleartext) mailleur...
+S:EHLO .com
+R:501 5.5.4 syntax error (domain part missing), closing connection.
+#====================================================
+C:CONNECT
+R:220 mailleur.example.com, ESMTP (cleartext) mailleur...
+S:EHLO domain..com
+R:501 5.5.4 syntax error (domain part missing), closing connection.
+#====================================================
diff --git a/data-feed/feedx11.tst b/data-feed/feedx11.tst
deleted file mode 100644 (file)
index 62cf8a8..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#very simple  test to feed SMTP server
-#====================================================
-T:(feedx11) Testing if helo fdqdn is  OK
-R:220 mailleur.example.com, ESMTP (cleartext) mailleur...
-#====================================================
-S:HELO [129.219.254.34]
-R:501 5.5.4 HELO argument is mandatory, closing connection.
-#-------------------------------------------------------------------------