From 550ab1d9acba1c2ad9f1b5ad4b5c1aad5a7ac090 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Wed, 11 Jun 2025 12:35:54 -0400 Subject: [PATCH] onefeed is NOT able to feed connection --- lib/Makefile | 2 +- lib/devsoc.c | 6 +++--- lib/devsoc.h | 2 +- lib/lvleml.c | 2 +- lib/modrec.c | 4 ++-- lib/unidns.c | 31 +++++++++++++++---------------- lib/unidns.h | 2 +- lib/unitls.c | 23 +++++++++++++++++++---- lib/unitls.h | 5 ++++- 9 files changed, 47 insertions(+), 30 deletions(-) diff --git a/lib/Makefile b/lib/Makefile index 0dd77ab..615702d 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -74,7 +74,7 @@ devsql.o: \ devsql.h devsql.c unidns.o: \ - subrou.h \ + subafn.h subrou.h \ unidns.h unidns.c unieml.o: \ diff --git a/lib/devsoc.c b/lib/devsoc.c index 04c9332..38f741b 100644 --- a/lib/devsoc.c +++ b/lib/devsoc.c @@ -595,7 +595,7 @@ return socptr; /* definition. */ /* */ /********************************************************/ -PUBLIC SOCPTR **soc_mkbindinf(SOCPTR **socptr,LISTYP *bind) +PUBLIC SOCPTR **soc_mkbindinf(SOCPTR **socptr,const LISTYP *bind) { SOCTYP *soc; @@ -746,8 +746,8 @@ while (proceed==true) { break; case 8 : //checking socket status if ((status=checksockstat(handle))!=0) { - (void) rou_alert(0,"%s Unable establish socklink with <%s> (error=<%s>)", - OPEP,ip,strerror(status)); + (void) rou_alert(0,"%s Unable establish socklink with <%s:%s> (error=<%s>)", + OPEP,ip,port,strerror(status)); (void) close(handle); phase=999; } diff --git a/lib/devsoc.h b/lib/devsoc.h index 1dddfdc..7e73072 100644 --- a/lib/devsoc.h +++ b/lib/devsoc.h @@ -29,7 +29,7 @@ extern SOCPTR **soc_freebindinf(SOCPTR **socptr); //procedure to assign memory to be used by a TCP socket //definition -extern SOCPTR **soc_mkbindinf(SOCPTR **s,LISTYP *bind); +extern SOCPTR **soc_mkbindinf(SOCPTR **socptr,const LISTYP *bind); //procedure to open one exchange socket //to connect a remote smtp server diff --git a/lib/lvleml.c b/lib/lvleml.c index 95b8573..96e1ee0 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -91,7 +91,7 @@ while (proceed==true) { case 1 : //check about local domain, TEMPORARY code int status; - status=dns_is_domain_local(rcpt->domain); + status=dns_is_domain_local(rcpt->domain,tls_get_bind_afn()); switch (status) { case dns_nomx : done=false; diff --git a/lib/modrec.c b/lib/modrec.c index a62f1a9..2129801 100644 --- a/lib/modrec.c +++ b/lib/modrec.c @@ -46,10 +46,10 @@ static int prepbinding(SOCPTR ***bindings) { #define OPEP "modrec.c:prepbinding" -LISTYP **bind; +const LISTYP **bind; *bindings=(SOCPTR **)0; -if ((bind=tls_get_bind_data())==(LISTYP **)0) { +if ((bind=tls_get_bind_data())==(const LISTYP **)0) { (void) rou_alert(0,"%s SMTPPORTS data fully missing (config?, bug?)",OPEP); (void) exit(-1); } diff --git a/lib/unidns.c b/lib/unidns.c index 41db7e3..9ca296c 100644 --- a/lib/unidns.c +++ b/lib/unidns.c @@ -26,10 +26,6 @@ typedef union { u_char buf[B64K]; //according US Cert VU#738331 }RSPTYP; -//list of SMTP local IPV4 -in_addr_t *local_ipv4=(in_addr_t *)0; -int num_ipv4=0; //number of IP within local_ipv4 - /* */ @@ -478,7 +474,7 @@ return match; /* local interface (serveur is primary MX). */ /* */ /********************************************************/ -PUBLIC LOCTYP dns_is_domain_local(const char *domain) +PUBLIC LOCTYP dns_is_domain_local(const char *domain,AFNTYP **afns) { @@ -490,6 +486,7 @@ int phase; _Bool proceed; status=dns_nomx; +dns=(MXTYP **)0; phase=0; proceed=true; while (proceed==true) { @@ -502,20 +499,22 @@ while (proceed==true) { if ((dns=dns_getmx(domain))==(MXTYP **)0) phase=999; //domain without MX? break; - case 2 : //listing MX - MXTYP **ptr; - - ptr=dns; - while ((*ptr)!=(MXTYP *)0) { - (void) rou_alert(0,"%s JMPDBG pref='%d' mxname=<%s>", - OPEP,(*ptr)->preference,(*ptr)->mxname); - ptr++; - } + case 2 : //establishing MX IP + status=dns_remote; + if (afns==(AFNTYP **)0) //No local IP? + phase=999; break; - case 3 : //cleaning MX list - dns=dns_freemxlist(dns); + case 3 : //checking best MX with local interface + while (*afns!=(AFNTYP *)0) { + if (dns_matchiprec((*dns)->mxname,*afns,32)==true) { + (void) rou_alert(0,"%s JMPDBG mxname=<%s> is local",OPEP,(*dns)->mxname); + status=dns_local; + } + afns++; + } break; default : //SAFE Guard + dns=dns_freemxlist(dns); //cleaning MX proceed=false; break; } diff --git a/lib/unidns.h b/lib/unidns.h index 1114ee8..1e58cfa 100644 --- a/lib/unidns.h +++ b/lib/unidns.h @@ -40,6 +40,6 @@ extern _Bool dns_matchiprec(char *hostname,AFNTYP *afnnum,int mask); //procedure to detect if a domain is served by a local //smtp server -extern LOCTYP dns_is_domain_local(const char *domain); +extern LOCTYP dns_is_domain_local(const char *domain,AFNTYP **afns); #endif diff --git a/lib/unitls.c b/lib/unitls.c index 40f616c..4b2e188 100644 --- a/lib/unitls.c +++ b/lib/unitls.c @@ -23,7 +23,8 @@ #define SSL_CIPHER_LIST "DEFAULT" static _Bool modopen; //module open/close status -static LISTYP **binds; //Binding information +static const LISTYP **binds; //Binding information +static AFNTYP **afns; //Binding information as AFN /* ^L */ @@ -476,7 +477,7 @@ while (proceed==true) { if (strlen(seq)==0) seq=DIP; if ((afn=afn_getipnum(seq))==(AFNTYP *)0) - (void) rou_alert(0,"%s, Not valid IP <%s> config",OPEP,seq); + (void) rou_alert(0,"%s, Not valid IP <%s> (config?)",OPEP,seq); break; case 2 : if (strlen(seq)>0) @@ -493,7 +494,7 @@ while (proceed==true) { list->port=strdup(port);; list->iteration=iteration; list->afn=afn; - binds=(LISTYP **)rou_addlist((void **)binds,(void *)list); + binds=(const LISTYP **)rou_addlist((void **)binds,(void *)list); } seq=ptr; } @@ -1278,7 +1279,7 @@ return ssl; /* Procedure to return the list of binding data */ /* */ /********************************************************/ -PUBLIC LISTYP **tls_get_bind_data() +PUBLIC const LISTYP **tls_get_bind_data() { return binds; @@ -1288,6 +1289,19 @@ return binds; */ /********************************************************/ /* */ +/* Procedure to return the AFN list of binding data*/ +/* */ +/********************************************************/ +PUBLIC AFNTYP **tls_get_bind_afn() + +{ +return afns; +} +/* +^L +*/ +/********************************************************/ +/* */ /* Procedure to "open/close" module and do */ /* homework purpose */ /* return zero if everything right */ @@ -1310,6 +1324,7 @@ if (mode!=modopen) { (void) buildbinds(); break; case false : + (void) free(afns); (void) rou_freelist((void **)binds,(genfree_t)freelisten); break; default : diff --git a/lib/unitls.h b/lib/unitls.h index 1efce00..d4356ca 100644 --- a/lib/unitls.h +++ b/lib/unitls.h @@ -78,7 +78,10 @@ extern int tls_check_peer(TLSTYP *tls); extern SSL *tls_setsocket(int handle,SSL_CTX *ctx); //getting binding information -extern LISTYP **tls_get_bind_data(); +extern const LISTYP **tls_get_bind_data(); + +//getting binding information as AFN structure +extern AFNTYP **tls_get_bind_afn(); //homework to be done before starting/stopping module. extern int tls_modeunitls(_Bool mode); -- 2.47.3