devdaily home | apple | java | perl | unix | directory | blog

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();
			}
		}

	}






Copyright 1998-2008 Alvin Alexander
All Rights Reserved.
 
devdaily.com is based in louisville, kentucky, and this web site is hosted by godaddy.com