From: Jean-Marc Pigeon (Delson) Date: Sun, 17 Aug 2025 11:18:13 +0000 (-0400) Subject: Better doconnect within feeder.c X-Git-Tag: tag-0.15~1 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=9a7fc6cb15e7d038f890a37f4e0e4131fd779bf0;p=jmp%2Fmailleur Better doconnect within feeder.c --- diff --git a/Makefile b/Makefile index 200ade2..816dd79 100644 --- 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" diff --git a/app/feeder.c b/app/feeder.c index 48f60db..e5c7fd0 100644 --- a/app/feeder.c +++ b/app/feeder.c @@ -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; diff --git a/data-feed/feed000.tst b/data-feed/feed000.tst index 64c1b4b..5d2714d 100644 --- a/data-feed/feed000.tst +++ b/data-feed/feed000.tst @@ -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 diff --git a/data-feed/feed001.tst b/data-feed/feed001.tst index b96ddb7..fb7e5e6 100644 --- a/data-feed/feed001.tst +++ b/data-feed/feed001.tst @@ -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 diff --git a/data-feed/feed002.tst b/data-feed/feed002.tst index 43b85b5..d3f588c 100644 --- a/data-feed/feed002.tst +++ b/data-feed/feed002.tst @@ -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 diff --git a/data-feed/feed003.tst b/data-feed/feed003.tst index eb223cc..23eae13 100644 --- a/data-feed/feed003.tst +++ b/data-feed/feed003.tst @@ -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 diff --git a/data-feed/feed004.tst b/data-feed/feed004.tst index 598a2d5..0942767 100644 --- a/data-feed/feed004.tst +++ b/data-feed/feed004.tst @@ -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 index 0000000..5d272e1 --- /dev/null +++ b/data-feed/feed010.tst @@ -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 index 62cf8a8..0000000 --- a/data-feed/feedx11.tst +++ /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. -#-------------------------------------------------------------------------