From e4a424a2f961b1bb0118ac49572aee5078c956a2 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Sat, 26 Jul 2025 07:44:16 -0400 Subject: [PATCH] Added contact->credits, problem with relayed on feed02 --- lib/gessql.c | 2 +- lib/lvleml.c | 26 ++++++++++++++++++++------ lib/lvleml.h | 1 + 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/gessql.c b/lib/gessql.c index 77704db..9b27df7 100644 --- a/lib/gessql.c +++ b/lib/gessql.c @@ -288,7 +288,7 @@ while (proceed==true) { switch (phase) { case 0 : //checking parameters if (strlen(rmtip)==0) { - (void) rou_alert(0,"%s rmtip=<%s> sing (Bug?)",OPEP,rmtip); + (void) rou_alert(0,"%s rmtip=<%s> missing (Bug?)",OPEP,rmtip); phase=999; } break; diff --git a/lib/lvleml.c b/lib/lvleml.c index 27263de..b570421 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -542,8 +542,10 @@ if ((received==(char *)0)||(strlen(received)==0)) { else decoded=cnv_getb64(received); if (decoded!=(char *)0) { - if (checklogin(contact,rmtpass,decoded)==true) + if (checklogin(contact,rmtpass,decoded)==true) { + contact->credits+=2; contact->privilege=rel_authentic; + } decoded=rou_freestr(decoded); } @@ -588,8 +590,10 @@ for (int i=0;i<2;i++) { line=rou_freestr(line); } if (strlen(local)>0) { - if (checklogin(contact,rmtpass,local)==true) + if (checklogin(contact,rmtpass,local)==true) { + contact->credits+=2; contact->privilege=rel_authentic; + } } } /* @@ -724,8 +728,10 @@ while (proceed==true) { (void) rou_alert(0,"%s Unable to get the hash response (Bug!)",OPEP); break; } - if (strcmp(HA0,resp->response)==0) + if (strcmp(HA0,resp->response)==0) { + contact->credits+=3; //very good authentication contact->privilege=rel_authentic; + } HA0=rou_freestr(HA0); } break; @@ -960,6 +966,7 @@ while (proceed==true) { break; case rel_plain : cmt="No relay accepted"; + contact->credits-=2; //Trying to abuse server phase=999; //not relayable break; default : @@ -2390,8 +2397,9 @@ while (proceed==true) { status=-3; break; } - (void) log_fprintlog(contact->logptr,true,"Contact terminated; " - "condition=<%s>",str); + (void) log_fprintlog(contact->logptr,true,"Contact terminated (credit='%d'); " + "condition=<%s>", + contact->credits,str); //(void) rou_alert(0,"%s exit status='%d'",OPEP,status); break; //no need to go further @@ -2415,6 +2423,7 @@ while (proceed==true) { case c_quit : //QUIT SMTP protocol (void) transmit(contact,true,"%d 2.0.0 Bye, closing connection CNT=%s", QUITOK,contact->mainsesid); + contact->credits++; //clean disconnect status=1; //every thing fine proceed=false; break; @@ -2460,6 +2469,7 @@ while (proceed==true) { } break; case c_unknown : //unknown keyword + contact->credits-=2; //Trying to confuse server? (void) rou_alert(0,"SMTP Command <%s> from [%s] is unknown (config?)", line,contact->peerip); (void) transmit(contact,true,"%d-5.5.1 Unrecognized command, see RFC 5321", @@ -2469,6 +2479,7 @@ while (proceed==true) { CMDBAD,contact->mainsesid); break; default : + contact->credits-=10; //Trying to bug server (void) rou_alert(0,"%s Unable to find entry for code='%d' (Bug?)",OPEP,code); (void) transmit(contact,true,"%d-5.5.1 Unrecognized command, see RFC 5321", CMDBAD); @@ -2521,6 +2532,7 @@ while (proceed==true) { case 1 : //connecting to database contact=(CONTYP *)calloc(1,sizeof(CONTYP)); contact->sqlptr=sql_opensql(); + contact->credits=0; if (contact->sqlptr==(SQLPTR *)0) { (void) rou_alert(0,"%s Unable to contact database",OPEP); (void) sleep(2);//delay to avoid avalanche @@ -2572,8 +2584,10 @@ while (proceed==true) { } break; case 6 : //checking if remote IP is relayable - if (afn_is_ip_relayable(contact->peerip,contact->relayok)==true) + if (afn_is_ip_relayable(contact->peerip,contact->relayok)==true) { contact->privilege=rel_isrelay; //IP is relayable + contact->credits++; + } break; case 7 : //contact is good, then sending a signon (void) log_fprintlog(contact->logptr,true,"Start CNT=%s",contact->mainsesid); diff --git a/lib/lvleml.h b/lib/lvleml.h index c6bad40..21d0b01 100644 --- a/lib/lvleml.h +++ b/lib/lvleml.h @@ -20,6 +20,7 @@ typedef struct { SQLPTR *sqlptr; //established contact database access int delay; //communication max delay char *fqdn; //fully qualified domain from peer + int credits; //Credits to be added or removed from contact RELTYP privilege; //onnection privilege char *authname; //Link is authenticated name AFNTYP **localafns; //local IP as an AFNUM -- 2.47.3