[pmg-devel] Separate smtp injection port for IN e OUT in pmg-filter

Davide Bozzelli davide.bozzelli at gmail.com
Mon Feb 19 12:50:15 CET 2018


Ok

This is my proof of concept code

Added to the sub reinject_mail:


 # smtp 10025 = orginal pmg , INCOMING
 # smtp 10026 = OUTGOING

        my %relay_domains = () ;
        my $inject_port = 10025 ;

        if ( -e "/etc/pmg/domains" ) {
                open DOMAINS,"</etc/pmg/domains" ;

                while ( <DOMAINS> ) {
                        my $domain = $_ ;
                        $domain =~ s/1//g;
                        $domain =~ s/\s+//g;
                        $relay_domains{$domain} = 1 ;
                        syslog ('info', "- Domain $domain loaded");
                }

                syslog ('info', '- Protected domains loaded completed.');

                close DOMAINS ;
        }


 if ( defined $relay_domains{$domain_part} )  {
                $inject_port = "10026" ;
                syslog('info', "Domin $domain_part is Local: Outgoing port:
$inject_port");

        } else {
                syslog('info', "Domin $domain_part is Local: Incoming port:
$inject_port");

        }


        my $smtp = Net::SMTP->new('127.0.0.1', Port => $inject_port, Hello
=> $me) ||
            die "unable to connect to localhost at port 10025"


The concept is to load the relay_domains in hash AND to change the
$inject_port based on the fact that the sender's domain is found in the
hash.
If the domain is found I assume that is a OUTGOING mail and so change the
port to 10026

The problem of this code is that at EVERY call of reinject_mail I need to
reload all the domains ad thus read the file on the file system.
I have tried to load the hash directly from the pmg-smtp-filter code BUT
the sub reinject_mail does not "see" it.

Maybe there is a much better way to do this.

Thx


On Mon, Feb 19, 2018 at 12:40 PM, Dietmar Maurer <dietmar at proxmox.com>
wrote:

> > I've found this:
> > RuleDB/Notify.pm: my $qid = PMG::Utils::reinject_mail(
> > RuleDB/Accept.pm:     my ($qid, $code, $mess) =
> PMG::Utils::reinject_mail(
> > RuleDB/BCC.pm:     my $qid = PMG::Utils::reinject_mail(
> > Utils.pm:sub reinject_mail {
> > Utils.pm:    PMG::Utils::reinject_mail ($top, '', [$receiver], undef,
> > $data->{fqdn});
> >
> > Do you use the  PMG::Utils::reinject_mai every time in ALL the
> > pmg-smtp-filter to reinject ?
>
> AFAIK yes.
>
> > I've found the var at the top of pmg-filter:
> >
> > my $opt_int_port = 10023;
> > my $opt_inject_port = 10025; <--- HERE
> >
> > BUT seems to be not used.
> >
> > I'm planning to distinguish two different smtp port to reinject back, how
> > can I figure out inside the function
> >  PMG::Utils::reinject_mail which direction (and so which port of
> > pmg-filter) I'm using ?
>
> I guess you need to check all call sites, and maybe you need
> to add an extra parameter ...
>
> _______________________________________________
> pmg-devel mailing list
> pmg-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
>



-- 
Got problems with Windows? - ReBooT
Got problems with Linux? - Be RooT
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://pve.proxmox.com/pipermail/pmg-devel/attachments/20180219/fa95a0bb/attachment.html>


More information about the pmg-devel mailing list