📄 mmailfiledetector.java
字号:
package net.jumperz.app.MGuardian.plugin;
import java.io.*;
import java.util.*;
import java.net.*;
import java.util.regex.*;
import net.jumperz.net.*;
import net.jumperz.util.*;
import net.jumperz.app.MGuardian.*;
public class MMailFileDetector
extends MGuardianPlugin
{
private int maxCount;
private static final String DEFAULT_COUNT = "50";
private Pattern pattern;
private static final String regex = "[-_a-zA-Z0-9]{1,}@[-_a-zA-Z0-9]{1,}\\.[-_a-zA-Z0-9]{1,}";
private String command;
private Boolean block;
//--------------------------------------------------------------------------------
public void startup()
throws IOException
{
maxCount = Integer.parseInt( control.getProperty( "mailFileDetector.maxCount", DEFAULT_COUNT ) );
pattern = Pattern.compile( regex );
command = control.getProperty( "mailFileDetector.command", "" );
block = new Boolean( control.getProperty( "mailFileDetector.block", "false" ).equalsIgnoreCase( "true" ) );
}
//--------------------------------------------------------------------------------
public Map execute( Map sessionInfo )
throws IOException
{
MHttpResponse response = ( MHttpResponse )sessionInfo.get( "response" );
Map pluginResult = new HashMap();
if( !response.hasBody() )
{
return null;
}
BufferedReader reader = new BufferedReader( new InputStreamReader( response.getBodyInputStream(), "ISO-8859-1" ) );
String line = null;
int count = 0;
while( true )
{
line = reader.readLine();
if( line == null )
{
break;
}
Matcher matcher = pattern.matcher( line );
if( matcher.find() )
{
++count;
if( count == maxCount )
{
pluginResult.put( "block", block );
pluginResult.put( "log", new Boolean( true ) );
if( !command.equals( "" ) )
{
pluginResult.put( "command", command );
}
return pluginResult;
}
}
}
return null;
}
//--------------------------------------------------------------------------------
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -