From: Jean-Marc Pigeon Date: Mon, 3 Nov 2025 18:39:05 +0000 (-0500) Subject: TRying to add remoteip value to actions table. X-Git-Tag: tag-0.17~52 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=82f399cba980b871646e27c37bd8c1c1d0e60cc2;p=jmp%2Fmailleur TRying to add remoteip value to actions table. --- diff --git a/lib/gessql.c b/lib/gessql.c index 31b973a..47bab39 100644 --- a/lib/gessql.c +++ b/lib/gessql.c @@ -46,7 +46,7 @@ PUBLIC _Bool sql_mngact(SQLPTR *sqlptr,ACTTYP *act) #define OPEP "gessql.c:sql_mngact," static const char *del="DELETE FROM "ACTTBL" WHERE sessid=%s AND rcptto=%s"; -static const char *ins="INSERT INTO "ACTTBL" (%s) VALUES(%s,%s,%s,%s,%s,%s,%s,%d,%d,%s)"; +static const char *ins="INSERT INTO "ACTTBL" (%s) VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%d,%d,%s)"; _Bool isok; @@ -54,7 +54,8 @@ isok=false; if (act!=(ACTTYP *)0) { char strcode[10]; char *gid; - char *greverse; //remote reverse address + char *gremoteip; //remote IP address + char *greverse; //remote reverse name char *gsfrom; //SMTP "mail from:" char *ghfrom; //email Header "From:" char *ghsubject; //email Header "Subject:" @@ -64,6 +65,7 @@ if (act!=(ACTTYP *)0) { (void) memset(strcode,'\000',sizeof(strcode)); strcode[0]=act->code; gid=sql_gooddata(sqlptr,act->sessid); + gremoteip=sql_gooddata(sqlptr,act->remoteip); greverse=sql_gooddata(sqlptr,act->reverse); gsfrom=sql_gooddata(sqlptr,act->sfrom); ghsubject=sql_gooddata(sqlptr,act->hsubject); @@ -73,7 +75,7 @@ if (act!=(ACTTYP *)0) { if (act->resp!=(char **)0) { char *field; - field="code,sessid,reverse,smtpfrom,emailfrom,subject,rcptto,numline,status,info"; + field="code,sessid,remoteip,reverse,smtpfrom,emailfrom,subject,rcptto,numline,status,info"; (void) sql_request(sqlptr,del,gid,grcpt); if (act->resp!=(char **)0) { char **resp; @@ -94,7 +96,8 @@ if (act!=(ACTTYP *)0) { ginfo=sql_gooddata(sqlptr,(*resp)+3); (void) sql_request(sqlptr,ins,field, gcode,gid, - greverse,gsfrom,ghfrom,ghsubject, + gremoteip,greverse, + gsfrom,ghfrom,ghsubject, grcpt,num,status,ginfo); ginfo=rou_freestr(ginfo); } @@ -156,6 +159,7 @@ if (tralist!=(TRATYP **)0) { (void) memset(&action,'\000',sizeof(ACTTYP)); action.sessid=(*tralist)->sessid; action.code=(*tralist)->code; + action.remoteip=(*tralist)->remoteip; action.reverse=(*tralist)->reverse; action.sfrom=(*tralist)->sfrom; action.hfrom=(*tralist)->hfrom; diff --git a/lib/lvleml.c b/lib/lvleml.c index f8196af..7b0133c 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -2882,6 +2882,7 @@ if ((contact!=(CONTYP *)0)&&(contact->recipients!=(RCPTYP **)0)) { tra->code=(*ptr)->code; tra->date=isnow; tra->delay=0; + tra->remoteip=strdup(contact->peerip); tra->reverse=strdup(contact->peername); tra->sessid=strdup(contact->session->sessid); tra->sfrom=strdup(contact->mailfrom); diff --git a/lib/unieml.c b/lib/unieml.c index 54efb0a..5aedee3 100644 --- a/lib/unieml.c +++ b/lib/unieml.c @@ -99,6 +99,7 @@ if (tra!=(TRATYP *)0) { tra->hfrom=rou_freestr(tra->hfrom); tra->hsubject=rou_freestr(tra->hsubject); tra->reverse=rou_freestr(tra->reverse); + tra->remoteip=rou_freestr(tra->remoteip); tra->rcptto=rou_freestr(tra->rcptto); tra->sessid=rou_freestr(tra->sessid); tra->sfrom=rou_freestr(tra->sfrom); diff --git a/lib/unieml.h b/lib/unieml.h index 3c10e98..45623e9 100644 --- a/lib/unieml.h +++ b/lib/unieml.h @@ -100,7 +100,8 @@ typedef struct { u_int delay; //Transaction execution delay char *hfrom; //Email HEADER originator char *hsubject; //Email HEADER subject - char *reverse; //remote reverse-address + char *remoteip; //remote server pure IP + char *reverse; //remote server reverse-address char *rcptto; //Email Recipient char *sessid; //session id char *sfrom; //Email SMTP Originator diff --git a/lib/unisql.h b/lib/unisql.h index a0a49fc..95afe3e 100644 --- a/lib/unisql.h +++ b/lib/unisql.h @@ -52,6 +52,7 @@ typedef struct { typedef struct { char *sessid; //session id char code; //Email status code + char *remoteip; //The remoter server IP number char *reverse; //The remoter server reverse address char *sfrom; //the "MAIL FROM:" within the SMTP exchange char *hfrom; //the "From:" within the email header diff --git a/sql/mailleur.sql b/sql/mailleur.sql index d02bc75..81cbecb 100644 --- a/sql/mailleur.sql +++ b/sql/mailleur.sql @@ -95,7 +95,10 @@ CREATE TABLE actions ( DFLT NOW(), code SHORTTEXT, //action status (one char) sessid TEXT, //Session id - reverse TEXT, //IP reverse address name + remoteip TEXT //Remote serveur IP number + DFLT NULL, + reverse TEXT //remote server reverse address name + DFLT 'Unknown IP', smtpfrom TEXT, //SMTP Connection "MAIL FROM:" rcptto TEXT, //SMTP Connection "RCPT TO:" emailfrom TEXT, //email contents "From:" diff --git a/www/gessql.php b/www/gessql.php index 02152cf..1abc672 100644 --- a/www/gessql.php +++ b/www/gessql.php @@ -160,6 +160,45 @@ while ($proceed==true) { rou_alert(0,"$OPEP, now logname=<$logname>"); } +//============================================================== +// +// Function to retreive remote SMTP serveur list +// +//============================================================== +function sql_getremotelist($dbsql,$remoteip,$limit,$skip) + +{ +$OPEP="gessql.php:sql_getremotelist"; + +$strlim=""; +$strskip=""; +$select=""; +if ($remoteip!=NULL) + $select="where remoteip like '%$remoteip%'"; +$strsel="Select * from remotes $select order by remoteip asc"; +if ($limit!=NULL) + $strlim="limit $limit"; +if ($skip!=NULL) + $strskip="offset $skip"; +$stmt=$dbsql->Select("$strsel $strlim $strskip"); +return $stmt->fetchAll(); +} +//============================================================== +// +// Function to return the number of record within remotes +// table according a select. +// +//============================================================== +function sql_getnumremotes($dbsql,$remoteip) + +{ +$OPEP="gessql.php:sql_getnumremotes"; + +$select=NULL; +if ($remoteip!=NULL) + $select="where remoteip like '%$remoteip%'"; +return sql_getnumrec($dbsql,$select,"remotes"); +} //============================================================== // // Function to retreive user email list diff --git a/www/lvlrmt.php b/www/lvlrmt.php index d466cf9..dceb0b4 100644 --- a/www/lvlrmt.php +++ b/www/lvlrmt.php @@ -2,7 +2,7 @@ // vim: smarttab tabstop=8 shiftwidth=2 expandtab //============================================================== // -// Main screen management +// remote server management screen // //============================================================== include_once "subrou.php"; @@ -10,7 +10,7 @@ include_once "unienv.php"; include_once "gesdis.php"; include_once "gessql.php"; -function tblheader(string $username,int $numrec,int $offset,int $limit) +function tblheader(string $remoteip,int $numrec,int $offset,int $limit) { global $userlang; @@ -21,8 +21,8 @@ $email=gettranslate($userlang,"Remote SMTP server"); $STR = << -
- + +