From 3c9906d903515a340505e24ab1eff54b0e059aa9 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Tue, 6 May 2025 18:56:13 -0400 Subject: [PATCH] Moved ORGN debug command to feeder command. --- Makefile | 4 +-- app/feeder.c | 49 ++++++++++++++++++++++++----- data-tst/feed00.tst | 10 ++---- data-tst/{feedxx.tst => xxfeed.tst} | 6 ++-- lib/lvleml.c | 3 -- lib/unieml.c | 3 -- 6 files changed, 49 insertions(+), 26 deletions(-) rename data-tst/{feedxx.tst => xxfeed.tst} (87%) diff --git a/Makefile b/Makefile index e9ed543..233921a 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ onefeed : debug -c ./conf/feeder.conf.dvl \ $(TESTIP) \ $(TESTPORT) \ - $(DATATST)/feedxx.tst + $(DATATST)/xxfeed.tst # # -i 127.63.31.15 #direct test @@ -79,7 +79,7 @@ dbgfeed : debug -c ./conf/feeder.conf.dvl \ $(TESTIP) \ $(TESTPORT) \ - $(DATATST)/feed00.tst + $(DATATST)/feedxx.tst valfeed : debug #valgring of emlrcvr @ echo "feed valgrind test" diff --git a/app/feeder.c b/app/feeder.c index 0a42a33..c125142 100644 --- a/app/feeder.c +++ b/app/feeder.c @@ -36,10 +36,11 @@ typedef struct { }FEEDTYP; typedef enum { //List of command + cmd_comment, //Test sequence in int/out comment mode cmd_gotls, //going in tls mode + cmd_orgn, //Change peer IP origin cmd_restart, //restart connection with remote server cmd_wait, //delay exchange with remote - cmd_comment, //Test sequence in int/out comment mode cmd_unknown }CMDTYP; /* @@ -183,6 +184,32 @@ while (proceed==true) { return status; } /* +^L +*/ +/************************************************/ +/* */ +/* procedure to to restart link with a */ +/* new source IP. */ +/* */ +/************************************************/ +static _Bool dorestart(FEEDTYP *fd,char *newip) + +{ +_Bool status; + +status=true; +if ((newip!=(char *)0)&&(strlen(newip)>0)) { + fd->srcip=rou_freestr(fd->srcip); + fd->srcip=strdup(newip); + } +fd->socptr=soc_closefeedsock(fd->socptr); +(void) usleep(100000); //wait 10 millisec +fd->socptr=soc_openfeedsock(pro_smtp,fd->srcip,fd->destip,fd->destport); +if (fd->socptr==(SOCPTR *)0) + status=false; +return status; +} +/* */ /********************************************************/ @@ -201,6 +228,7 @@ static struct { }cmdavail[]={ {cmd_comment,"COMMENT"}, {cmd_gotls,"GOTLS"}, + {cmd_orgn,"ORGN"}, {cmd_restart,"RESTART"}, {cmd_wait,"WAIT"}, {cmd_unknown,(const char *)0} @@ -242,6 +270,16 @@ switch (getcmd(line)) { if ((status=gomodetls(fd->socptr))==false) (void) report(numline,line,"Unable to set TLS mode"); break; + case cmd_orgn : //Changing PEERIP + if (param!=(char *)0) { + if(( status=dorestart(fd,param))==false) + (void) report(numline,line,"Unable to change srcip!"); + } + else { + (void) report(numline,line,"Missing new PEER IP value"); + status=false; + } + break; case cmd_wait : //SLEEP mode if (param!=(char *)0) (void) sleep(atoi(param)); @@ -251,13 +289,8 @@ switch (getcmd(line)) { } break; case cmd_restart : //restart link - fd->socptr=soc_closefeedsock(fd->socptr); - (void) usleep(100000); //wait 10 millisec - fd->socptr=soc_openfeedsock(pro_smtp,fd->srcip,fd->destip,fd->destport); - if (fd->socptr==(SOCPTR *)0) { - (void) report(numline,line,"Unable to restart feed socket!"); - status=false; - } + if ((status=dorestart(fd,(char *)0))==false) + (void) report(numline,line,"Unable to restart feed socket!"); break; case cmd_comment : //restart link if (setcomment(fd,param)==false) diff --git a/data-tst/feed00.tst b/data-tst/feed00.tst index 8bab494..a6873d8 100644 --- a/data-tst/feed00.tst +++ b/data-tst/feed00.tst @@ -4,7 +4,7 @@ # # comment # C: command to execute # GOTLS - Going in TLS mode -# SLEEP X - Stop for X seconds +# WAIT X - Stop for X seconds # RESTART - Restart connection with remote # COMMENT START - START commenting mode # COMMENT STOP - STOP commenting mode @@ -40,7 +40,6 @@ R:250-STARTTLS R:250-8BITMIME R:250-ENHANCEDSTATUSCODES R:250-AUTH PLAIN LOGIN -R:250-ORGN R:250 HELP C:GOTLS R:250 Link now encryp... @@ -51,7 +50,6 @@ R:250-SIZE 52428800 R:250-8BITMIME R:250-ENHANCEDSTATUSCODES R:250-AUTH PLAIN LOGIN -R:250-ORGN R:250 HELP #send a empty ehlo S:EHLO @@ -64,10 +62,8 @@ C:WAIT 1 #-restarting link C:RESTART R:220 mailleur.example.com ESMTP (cleartext) emlrcvr... -S:ORGN 127.168.0.1 -R:250 2.9.9 New peer [127.168.0.1/No.Reverse] set -S:ORGN 127.168.10.1 -R:250 2.9.9 New peer [127.168.10.1/foreign1.badserver.tld] set +C:ORGN 127.168.0.1 +R:220 mailleur.example.com ESMTP (cleartext) emlrcvr... S:QUIT R:221 2.0.0 Bye, closing connection... #------------------------------------------------------------------------- diff --git a/data-tst/feedxx.tst b/data-tst/xxfeed.tst similarity index 87% rename from data-tst/feedxx.tst rename to data-tst/xxfeed.tst index 7317fb5..d4972c4 100644 --- a/data-tst/feedxx.tst +++ b/data-tst/xxfeed.tst @@ -2,14 +2,14 @@ #==================================================== T:Simple email sending R:220 mailleur.example.com ESMTP (cleartext) emlrcvr... -S:ORGN 127.127.0.2 -R:250 2.9.9 New peer [127.127.0.2/feed2.example.com] set +C:ORGN 127.127.0.2 +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] S:MAIL FROM: R:250 2.1.3 postmaster@example.com.. sender ok -S:RCP TO: +S:RCPT TO: R:250 Address accepted #------------------------------------------------------------------------- #-sending data diff --git a/lib/lvleml.c b/lib/lvleml.c index 747ab3e..73a6225 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -292,9 +292,6 @@ static char *ehlostr[]= { "-8BITMIME", "-ENHANCEDSTATUSCODES", "-AUTH PLAIN LOGIN", -#ifdef MODEDEBUG - "-ORGN", //specific command to change ORIGIN IP -#endif " HELP", (char *)0 }; diff --git a/lib/unieml.c b/lib/unieml.c index 903e1b0..40d4efd 100644 --- a/lib/unieml.c +++ b/lib/unieml.c @@ -24,9 +24,6 @@ static VOCTYP vocsmtp[]={ {c_helo,"HELO"}, {c_mail,"MAIL FROM:"}, {c_noop,"NOOP"}, -#ifdef MODEDEBUG - {c_orgn,"ORGN"}, -#endif {c_quit,"QUIT"}, {c_rcpt,"RCPT TO:"}, {c_rset,"RSET"}, -- 2.47.3