🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #80300

Re: Can Cleanfeed filter on a specific user?

#80300
From: John F. Morse
Date: Mon, 09 Mar 2009 16:15
98 lines
4507 bytes
Ray Banana wrote:
> If you just want to filter articles by the From: header, this might be
> as simple as adding a subroutine
>
> sub local_filter_first {
>
>     if ( $hdr{'From'} =~ /$your_regex_goes_here/ ) {
>         return 'Spam';
>     }
>
>     return '';
>
> }
>
> to your cleanfeed.local.
>
> hth


I was hoping too, Ray, but the articles are getting past it.

Here is what I have added to the bottom of the sub local_filter_first 
(the "from_name_here" is the actual name in the header From entry):

sub local_filter_first {
        my $localpost = 0;

        $localpost = 1 if $hdr{'X-Trace'} and $hdr{'X-Trace'} =~ 
/\.inwind\.it /;

        study $hdr{__BODY__} if $hdr{__LINES__} <= 250;

        # local posts 
############################################################
        if ($localpost) {
                if ($hdr{Approved}) {
                    foreach (@groups) {
                                if (not /^(?:alt|wind|inwind)\./) {
                                        saveart('CF.approved');
                                        return reject("Forged approval 
in $_ ($hdr{Approved})");
                                }
                    }
                }

#               if ($hdr{Subject} =~ /^R: /) { saveart('L.r'); }

                return reject('Non usare HTML in Usenet!')
                       
                        if $hdr{'Content-Type'} and 
($hdr{'Content-Type'} =~ m#text/html#
                                or $hdr{'Content-Type'} =~ 
m#multipart/alternative#);

                    if ( $hdr{'From'} =~ /$from_name_here/ ) {
                                return 'Spam';
                        }

                        return '';
                       
        }
        
##########################################################################


I am not a Perl programmer, so I probably have something broken above, 
or I placed your suggested addition in the wrong place. Maybe you can 
spot a goof in syntax?

All I can see that is different from the original stanzas above the 
addition, is you added extra spaces at the parentheses. I don't know if 
this would cause a problem or not.

Then I see the conditional immediately above the added one appears to 
have an "if" without any "then" or "else" (a "do-nothing" check?). I 
wonder what happens if either "if" is met? Does it put the added "From" 
text into its conditional check? That might be why the new text is skipped.

And there is one line which is commented out. Maybe it causes all of the 
remainder to be ignored?

Finally, I see references to "localpost" which is not what my problem 
is, since I'm concerned by articles arriving from peers.

What "local" means is a mystery to me since innd handles everything, and 
innd is where Cleanfeed hooks up. IOW, I'd think filter_nnrpd.pl would 
be the place for "localpost" configuration to stop trouble at the front 
door before filter_innd.pl even sees the local-posted messages. 
Misunderstanding of terminology I suspect. ;-)

I don't know if any of these are problems, or if I should simply remove 
these "factory" examples.

Seems there was a routine to check Perl script syntax, but I can't find it.


-- 
John
Technical Details
Message-ID: <gp3fbd$k29$1@optima7.xanadu-bbs.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!border2.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.freenet.de!feeder.news-service.com!nntp.club.cc.cmu.edu!74.222.216.191.MISMATCH!optima7.xanadu-bbs.net!not-for-mail
References: <gou9pu$a8c$1@optima7.xanadu-bbs.net> <80ocwdgpxd.fsf@banana.shacknet.nu>

Show Full Headers
Complete Article Headers
Message-ID: <gp3fbd$k29$1@optima7.xanadu-bbs.net>
Subject: Re: Can Cleanfeed filter on a specific user?
Date: Mon, 09 Mar 2009 11:15:41 -0500
From: "John F. Morse" <xanadu.bbs@example.invalid>
References: <gou9pu$a8c$1@optima7.xanadu-bbs.net> <80ocwdgpxd.fsf@banana.shacknet.nu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!border2.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.freenet.de!feeder.news-service.com!nntp.club.cc.cmu.edu!74.222.216.191.MISMATCH!optima7.xanadu-bbs.net!not-for-mail
Newsgroups: news.software.nntp
Organization: Xanadu BBS
Lines: 98
Reply-To: dont.bother
NNTP-Posting-Host: n100.xanadu-bbs.net
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: optima7.xanadu-bbs.net 1236615341 20553 192.168.89.210 (9 Mar 2009
X-Complaints-To: newsmaster@xanadu-bbs.net
NNTP-Posting-Date: Mon, 9 Mar 2009 16:15:41 +0000 (UTC)
User-Agent: Thunderbird 2.0.0.19 (X11/20090105)
In-Reply-To: <80ocwdgpxd.fsf@banana.shacknet.nu>