]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Added contact->credits, problem with relayed on feed02
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sat, 26 Jul 2025 11:44:16 +0000 (07:44 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sat, 26 Jul 2025 11:44:16 +0000 (07:44 -0400)
lib/gessql.c
lib/lvleml.c
lib/lvleml.h

index 77704db7829da11d0d0cb583903860b90ae08c24..9b27df74298bf3d0f92f22776398aa15e6c1752e 100644 (file)
@@ -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;
index 27263de785d41d606a51e27018905c6fcec881b3..b57042128e45db1d1156bb7cdfe2bde85a94d1af 100644 (file)
@@ -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);
index c6bad40caa380e62448e2c135ace0de26f7d9083..21d0b01d15833b4c7f9ed97a6bca0cc218a83812 100644 (file)
@@ -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