Chapter 10. Custom Article Filtering

If you wish to have tight control over which articles get accepted by the system, you should consider using a filtering program. A filtering program can be enabled by providing a full path (or relative path from the bin directory) to the "-program" option.

On startup, the system will spawn a copy of the program specified by the "-program" option. When an article is received and ready to be considered for outgoing feeds, a copy of the header lines terminated by a line containing ".\r\n" will be sent to the standard input of the filtering program.

After the header is sent to the filtering program, the system will attempt to read 5 bytes from the standard output of the filtering program. If the 5 bytes are "335\r\n", the article will be accepted. If the 5 bytes are "435\r\n", the article will be discarded.

It is important to remember that the filtering program should NOT exit. In addition, since the system waits for the filtering program to make a decision about each article, speed is very important. Here is a simple example of a filtering program. Although this example is written in Perl, filtering programs can be written in any language. This example is included as sample_filter.pl in the bin directory.

	
		#!/usr/local/bin/perl
		#
		$| = 1; # Flush STDOUT
		$good_article = "335\r\n";
		$bad_article = "435\r\n";
		
		# Initialize
		$result = $good_article;
		
		# Loop on input
		while($line = <>) {
			# If the Subject contains "MAKE MONEY FAST", reject the article.
			if ($line =~ /^Subject:/) {
				if ($line =~ /MAKE MONEY FAST/) {
					$result = $bad_article;
				} else {
					$result = $good_article;
				}
			}
		
			if ($line eq ".\r\n") { print $result; }
		}
		
	

Several spam filtering engines are plug-in compatible with Typhoon, Twister, and Tornado Back End including SpamHippo and CleanFeed.