From: Jean-Marc Pigeon (Delson) Date: Wed, 16 Jul 2025 16:37:29 +0000 (-0400) Subject: hecking table relayok seems to be working X-Git-Tag: tag-0.14~80 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=15e7c8fd720617568da42b136f6a0f1bc4589d88;p=jmp%2Fmailleur hecking table relayok seems to be working --- diff --git a/lib/lvleml.c b/lib/lvleml.c index b5b9443..746e9ed 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -2345,7 +2345,6 @@ while (proceed==true) { } break; case 2 : //loading the relayable IP list - //contact->relayok=eml_load_relayed(getenv(RELAYS)); contact->relayok=eml_load_relayed(getenv(RELAYS)); break; case 3 : //waiting from contact @@ -2380,14 +2379,18 @@ while (proceed==true) { (void) rou_alert(0,"Contact from peer <%s> to port <%s> started", contact->peerip,contact->locserv); break; - case 5 : //check contact validity + case 5 : //checking if remote IP is relayable + if (afn_is_ip_relayable(contact->peerip,contact->relayok)==true) + contact->privilege=rel_isrelay; //IP is relayable + break; + case 6 : //check contact validity if ((contact->locname==(char *)0)||(contact->peerip==(char *)0)) { (void) rou_alert(0,"%s Unable to establish contact entities",OPEP); contact=freecontact(contact); phase=999; //no identity } break; - case 6 : //contact is good, then sending a signon + case 7 : //contact is good, then sending a signon (void) log_fprintlog(contact->logptr,false,"opening connection CNT=%s", contact->mainsesid); break; diff --git a/lib/subafn.c b/lib/subafn.c index eeb856a..4f5b868 100644 --- a/lib/subafn.c +++ b/lib/subafn.c @@ -563,14 +563,14 @@ return reversip; /* return -1 if unexpected type */ /* */ /********************************************************/ -int afn_cmpipnum(AFNTYP *afnnum1,AFNTYP *afnnum2,int mask) +PUBLIC int afn_cmpipnum(AFNTYP *afnnum1,AFNTYP *afnnum2,int mask) { int areequal; int phase; int proceed; -areequal=false; +areequal=0; phase=0; proceed=true; while (proceed==true) { @@ -581,7 +581,7 @@ while (proceed==true) { break; case 1 : /*is mask 0, all IP ok */ if (mask==0) { - areequal=true; + areequal=1; proceed=false; } break; @@ -623,7 +623,7 @@ return areequal; /* acceptable to be relayed list. */ /* */ /********************************************************/ -PUBLIC _Bool afn_ip_rlylist(char *iptocheck,AFNTYP **list) +PUBLIC _Bool afn_is_ip_relayable(char *iptocheck,AFNTYP **list) { #define OPEP "subafn.c:afn_ip_inlist," @@ -636,7 +636,7 @@ _Bool proceed; isok=false; afn=(AFNTYP *)0; phase=0; -proceed=false; +proceed=true; while (proceed==true) { switch (phase) { case 0 : //converting IP @@ -651,7 +651,18 @@ while (proceed==true) { phase=999; //No need to go further break; case 2 : //do we have a list - while (*list!=(AFNTYP *)0) { + while ((isok==false)&&(*list!=(AFNTYP *)0)) { + switch (afn_cmpipnum(*list,afn,(*list)->afnmask)) { + case -1 : //trouble! + (void) fprintf(stderr,"%s, Unable to check IP=<%s> (error=<%s> bug?)", + OPEP,iptocheck,strerror(errno)); + break; + case 0 : //no match, nothing to do + break; + case 1 : //found a match + isok=true; + break; + } list++; } break; diff --git a/lib/subafn.h b/lib/subafn.h index 3b06623..15a93c9 100644 --- a/lib/subafn.h +++ b/lib/subafn.h @@ -61,6 +61,6 @@ extern char *afn_reversipnum(AFNTYP *afnnum); extern int afn_cmpipnum(AFNTYP *afnnum1,AFNTYP *afnnum2,int mask); //procedure to check if a remote ip is part of the relayable list -extern _Bool afn_ip_inrlylist(char *iptocheck,AFNTYP **list); +extern _Bool afn_is_ip_relayable(char *iptocheck,AFNTYP **list); #endif