alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code


package com.ice.syslogd;

import java.io.*;
import java.net.*;
import java.lang.*;
import com.ice.rexec.RExec;


public class
SpammerAction
	{
	public static final String		RCS_ID = "$Id: SpammerAction.java,v 1.2 1998/02/24 03:39:36 time Exp $";
	public static final String		RCS_REV = "$Revision: 1.2 $";
	public static final String		RCS_NAME = "$Name:  $";

	private String			expr;
	private SyslogMatch		matcher;

	public
	SpammerAction()
		{
		this.expr = expr;
		}

	public void
	setParameters( String[] parameters )
		{
		this.expr = parameters[0];
		}

	public void
	restart()
		{
		}

	public void
	openAction()
		{
		this.matcher = new SyslogMatch();

		try {
			this.matcher.compile( this.expr );
			}
		catch ( MatchCompileException ex )
			{
			this.matcher = null;
			}
		}

	public void
	closeAction()
		{
		}

	public void
	processMessage( SyslogMessage logMsg )
		{
		if ( this.matcher.matchMessage( logMsg.message ) )
			{
			String ipAddr = this.matcher.getMatchSubExpr( 1 );

			RExec exec =
				new RExec( "stylus.ice.com", "time", "timebomb",
							"/home/time/killspam " + ipAddr );

			try { exec.open(); }
			catch ( UnknownHostException ex )
				{
				System.err.println
					( "UNKNOWN HOST opening killspam: "
						+ ex.getMessage() );
				}
			catch ( IOException ex )
				{
				System.err.println
					( "ERROR opening killspam: "
						+ ex.getMessage() );
				}

			exec.close();
			}
		}

	}



... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.