📄 mbangzone.java
字号:
package net.jumperz.app.MBangzone;
import java.io.*;
import java.util.*;
import java.net.*;
import net.jumperz.net.*;
import net.jumperz.util.*;
public final class MBangzone
{
private MThreadPool threadPool;
private String logFileName;
private int threadCount;
private static MBangzone instance;
//--------------------------------------------------------------------------------------
public static MBangzone getInstance()
{
return instance;
}
//--------------------------------------------------------------------------------------
public static void main( String[] args )
throws Exception
{
if( args.length == 1 )
{
instance = new MBangzone( args[ 0 ]);
instance.start();
}
else
{
System.out.println( "Usage: java net.jumperz.app.MBangzone.MBangzone [ CONFIG_FILE ]" );
return;
}
}
//--------------------------------------------------------------------------------------
private MBangzone( String configFileName )
throws Exception
{
loadConfig( configFileName );
threadPool = new MThreadPool( threadCount );
MStandardLogger.getInstance().addStream( new FileOutputStream( new File( logFileName ), true ) );
MStandardLogger.getInstance().addStream( System.out );
}
//--------------------------------------------------------------------------------------
private void loadConfig ( String configFileName )
throws Exception
{
MConfig config = MConfig.getInstance();
config.load( configFileName );
logFileName = config.getLogFileName();
threadCount = config.getThreadCount();
}
//--------------------------------------------------------------------------------------
public void start()
throws Exception
{
BufferedReader reader = new BufferedReader( new InputStreamReader( System.in ) );
// read all input
while( true )
{
String line = reader.readLine();
if( line == null )
{
break;
}
MAgent agent = new MAgent( line );
if( MConfig.getInstance().getUseProxy() == true )
{
agent.setProxy( MConfig.getInstance().getProxyHost(), MConfig.getInstance().getProxyPort() );
}
threadPool.addCommand( agent );
}
// wait until end
while( true )
{
Thread.sleep( 1000 );
if( threadPool.getRunningThreadCount() == 0 )
{
break;
}
}
exit();
}
//--------------------------------------------------------------------------------------
public void exit()
{
threadPool.stop();
System.exit( 0 );
}
//--------------------------------------------------------------------------------------
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -