From a4d5cd957c5db1e86d08b0b705520f74b6cf1f88 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Sat, 26 Jul 2025 07:20:29 -0400 Subject: [PATCH] Removing "wrong IP" from remote tables --- app/scanner.c | 1 + lib/devsoc.c | 4 +++- lib/gessql.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++-- lib/lvleml.c | 10 +++++----- 4 files changed, 62 insertions(+), 8 deletions(-) diff --git a/app/scanner.c b/app/scanner.c index 062812e..6688990 100644 --- a/app/scanner.c +++ b/app/scanner.c @@ -62,6 +62,7 @@ while (proceed==true) { if ((afn=afn_getoneipnum(rmtip))==(AFNTYP *)0) { (void) rou_alert(0,"%s Unable to get afn data for remote <%s> (WRONG IP?)", OPEP,rmtip); + (void) sql_mngremote(scanref->sqlptr,sql_delete,rmtip,&srv); phase=999; //Trouble trouble } break; diff --git a/lib/devsoc.c b/lib/devsoc.c index 465b725..1879660 100644 --- a/lib/devsoc.c +++ b/lib/devsoc.c @@ -1359,10 +1359,12 @@ if (soc!=(SOCTYP *)0) { case -1 : //trouble to read socket data switch(errno) { case ENOTCONN : //other side just vanished + (void) rou_alert(0,"%s, Remote side vanished (local=%d, error=<%s>)", + OPEP,local,strerror(errno)); break; default : (void) rou_alert(0,"%s, Unable to socket data (local=%d, error=<%s>)", - OPEP,local,strerror(errno)); + OPEP,local,strerror(errno)); break; } break; diff --git a/lib/gessql.c b/lib/gessql.c index 21b8d7b..77704db 100644 --- a/lib/gessql.c +++ b/lib/gessql.c @@ -30,7 +30,6 @@ static const FLDTYP usrfield[]={ {0,(char *)0} }; -_Bool isok; /* */ @@ -260,6 +259,53 @@ while (proceed==true) { *usr=locusr; return isok; +#undef OPEP +} +/* + +*/ +/********************************************************/ +/* */ +/* Procedure to delete a remote record from the */ +/* table. */ +/* */ +/********************************************************/ +static _Bool delete_remote(SQLPTR *sqlptr,char *rmtip,SRVTYP *srv) + +{ +#define OPEP "gessql.c:delete_remote," + +static const char *del="DELETE FROM "RMTTBL" WHERE remoteip=%s"; + +_Bool isok; +register int phase; +register _Bool proceed; + +isok=false; +phase=0; +proceed=true; +while (proceed==true) { + switch (phase) { + case 0 : //checking parameters + if (strlen(rmtip)==0) { + (void) rou_alert(0,"%s rmtip=<%s> sing (Bug?)",OPEP,rmtip); + phase=999; + } + break; + case 1 : //Selecting user + if (sql_request(sqlptr,del,rmtip)!=1) { + (void) rou_alert(0,"%s Unable to delete remote_ip <%s> (Database?)", + OPEP,rmtip); + phase=999; //Trouble trouble + } + break; + case 2 : //everything fine + isok=true; + break; + } + } +return isok; + #undef OPEP } /* @@ -278,6 +324,7 @@ static _Bool select_remote(SQLPTR *sqlptr,char *rmtip,SRVTYP **srv) static const char *sel="SELECT * FROM "RMTTBL" WHERE remoteip=%s"; +_Bool isok; SRVTYP *locsrv; SQLRES *rs; register int phase; @@ -292,7 +339,8 @@ while (proceed==true) { switch (phase) { case 0 : //checking parameters if ((srv==(SRVTYP **)0)||(rmtip==(char *)0)||(strlen(rmtip)==0)) { - (void) rou_alert(0,"%s srv=<%p> or rmtip=<%s> sing (Bug?)",OPEP,srv,rmtip); + (void) rou_alert(0,"%s srv=<%p> or rmtip=<%s> missing (Bug?)", + OPEP,srv,rmtip); phase=999; } break; @@ -728,6 +776,9 @@ while (proceed==true) { case sql_update : isok=update_remote(sqlptr,gooddata,*srv); break; + case sql_delete : + isok=delete_remote(sqlptr,gooddata,*srv); + break; default : (void) rou_alert(0,"%s action='%d' not yet implemented!",OPEP,action); break; diff --git a/lib/lvleml.c b/lib/lvleml.c index 5e112d4..27263de 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -2564,17 +2564,17 @@ while (proceed==true) { (void) rou_alert(0,"Contact from peer <%s> to port <%s> started", contact->peerip,contact->locserv); break; - 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 + case 5 : //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 : //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 7 : //contact is good, then sending a signon (void) log_fprintlog(contact->logptr,true,"Start CNT=%s",contact->mainsesid); (void) log_fprintlog(contact->logptr,false,"(Contact open from [%s] to " -- 2.47.3