mbangzone.java

来自「httptunnel.jar httptunnel java 源码」· Java 代码 · 共 95 行

JAVA
95
字号
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 + =
减小字号Ctrl + -
显示快捷键?