james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Noel J. Bergman" <n...@devtech.com>
Subject RE: [PATCH] fetchmail branch_2_1_fcs - Pass info. required by InSpammerBlackList matcher
Date Fri, 10 Oct 2003 23:26:08 GMT
Steve,

If I don't get the patch submitted today, it would have to wait for Monday
evening at the earliest, since I expect to be offline for the weekend.
Based upon your comments, sounds like it is fine to wait.

I have some code that might be of help to you, and am pasting it below my
signature.  It is part of a proposed/planned James v3 matcher when we would
(I hope) have some notion of a MatcherConfig.  But I think you'll still get
some use out of the code.

	--- Noel

    public void init(/*MatcherConfig newConfig*/) throws MessagingException
    {
//      super.init(newConfig);
        boolean checkRelays = false;

//      try
//      {
//          checkRelays = new
Boolean(getInitParameter("checkRelays")).booleanValue();
//      } catch (Exception e) { }

        if (checkRelays) try
        {
            matcher = new Perl5Matcher();
            pattern = new Perl5Compiler().compile("(from|FROM)
.*[\\(\\[]([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})[\\]\\)]");
        }
        catch(MalformedPatternException mpe)
        {
            throw new MessagingException("Could not initialize pattern
matcher", mpe);
        }
    }

    protected Collection getRelays(Mail mail) throws MessagingException
    {
        Collection relays = new Vector();
        relays.add(mail.getRemoteAddr());

        if (matcher != null)
        {
            MimeMessage message = mail.getMessage();
            String headers[] = message.getHeader("Received");
            for (int i = 0; i < headers.length; i++) {
                if (matcher.contains(headers[i], pattern))
                    relays.add(matcher.getMatch().group(2));
            }
        }

        return relays;
    }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message