⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mconfig.java

📁 httptunnel.jar httptunnel java 源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
					// check error
				if( host	== null
				 || port	== null
				 || protocol	== null
				  )
					{
					throwParseError( configDir.getCanonicalPath() + "/" + LISTENING_SOCKET, lineNumber );
					}
	
				if( protocol.equalsIgnoreCase( "HTTP" ) )
					{
					acceptorList.add( new MMultiAcceptor( host, Integer.parseInt( port ) ) );			
					}
				else if( protocol.equalsIgnoreCase( "HTTPS" ) )
					{
						// check error
					if( privateKeyFileName	== null
					 || certificateFileName	== null
					 || algorithm		== null
					  )
						{
						throwParseError( configDir.getCanonicalPath() + "/" + LISTENING_SOCKET, lineNumber );
						}
					ServerSocketFactory serverSocketFactory = MSecurityUtil.getServerSocketFactory( certificateFileName, privateKeyFileName, algorithm );
					ServerSocket serverSocket = serverSocketFactory.createServerSocket( Integer.parseInt( port ), MMultiAcceptor.BACKLOG, InetAddress.getByName( host ) );
					MMultiAcceptor acceptor = new MMultiAcceptor( serverSocket );
					acceptorList.add( acceptor );
					}
					
					// set null
				protocol		= null;
				port			= null;
				host			= null;
				privateKeyFileName	= null;
				certificateFileName	= null;
				algorithm		= null;
				}
			else if( line.indexOf( "protocol" ) == 0 )
				{
				protocol = getParam( line, "protocol=" );
				}
			else if( line.indexOf( "port" ) == 0 )
				{
				port = getParam( line, "port=" );
				}
			else if( line.indexOf( "host" ) == 0 )
				{
				host = getParam( line, "host=" );
				}
			else if( line.indexOf( "privateKeyFileName" ) == 0 )
				{
				privateKeyFileName = getParam( line, "privateKeyFileName=" );
				}
			else if( line.indexOf( "certificateFileName" ) == 0 )
				{
				certificateFileName = getParam( line, "certificateFileName=" );
				}
			else if( line.indexOf( "algorithm" ) == 0 )
				{
				algorithm = getParam( line, "algorithm=" );
				}
			}
		}
	}
finally
	{
	reader.close();
	}
}
//--------------------------------------------------------------------------------------
private String getParam( String line, String paramName )
{
return line.substring( paramName.length() );
}
//--------------------------------------------------------------------------------------
private void throwParseError( String ruleFileName, int lineNumber )
throws IOException
{
throw new IOException( "Parse error. " + ruleFileName + " line: " + lineNumber );
}
//-----------------------------------------------------------------------------------
private void loadAdditionalRequestHeader()
throws IOException
{
additionalRequestHeaderMap = loadAdditionalHeader( configDir.getCanonicalPath() + "/" + ADDITIONAL_REQUEST_HEADER );
}
//-----------------------------------------------------------------------------------
private void loadAdditionalResponseHeader()
throws IOException
{
additionalResponseHeaderMap = loadAdditionalHeader( configDir.getCanonicalPath() + "/" + ADDITIONAL_RESPONSE_HEADER );
}
//-----------------------------------------------------------------------------------
private HashMap loadAdditionalHeader( String additionalHeaderFileName )
throws IOException
{
HashMap additionalHeaderMap = new HashMap();
BufferedReader reader = new BufferedReader( new InputStreamReader( new FileInputStream( additionalHeaderFileName ), MCharset.CS_ISO_8859_1 ) );
String line;
try
	{
	while( true )
		{
		line = reader.readLine();
		if( line == null )
			{
			break;
			}
		if( !MStringUtil.isComment( line ) )
			{
			String name	= MRegEx.getMatch( "([^:]+):.+", line );
			if( !name.equals( "" ) )
				{
				String value	= ( line.substring( name.length() + 1 ) ).trim();
				additionalHeaderMap.put( name , value );
				}
			}
		}
	}
finally
	{
	reader.close();
	}
return additionalHeaderMap;
}
//-----------------------------------------------------------------------------------
private void loadAllowedAddress()
throws IOException
{
allowedAddressSet = new HashSet();
allowedAddressSet.addAll( MStringUtil.loadListFromFile( configDir.getCanonicalPath() + "/" + ALLOWED_ADDRESS ) );
}
//-----------------------------------------------------------------------------------
private void loadAllowedRequestHeader()
throws IOException
{
if( limitRequestHeader )
	{
	requestFilter = new MHttpFilter( MStringUtil.loadListFromFile( configDir.getCanonicalPath() + "/" + ALLOWED_REQUEST_HEADER ) );
	}
}
//-----------------------------------------------------------------------------------
private void loadAllowedResponseHeader()
throws IOException
{
if( limitResponseHeader )
	{
	responseFilter = new MHttpFilter( MStringUtil.loadListFromFile( configDir.getCanonicalPath() + "/" + ALLOWED_RESPONSE_HEADER ) );
	}
}
//--------------------------------------------------------------------------------
public String getRequiredProperty( String key )
throws IOException
{
String s = control.getProperty( key );
if( s == null )
	{
	throw new IOException(  "'" + key + "' must be defined in the 'control' file." );
	}
return s;
}
//-----------------------------------------------------------------------------------
public String getLogFileName() {
	return logFileName;
}

public boolean getReplaceHostField() {
	return replaceHostField;
}

/*
public boolean getReplaceLocationField() {
	return replaceLocationField;
}
*/

public String getTargetHost() {
	return targetHost;
}

public int getTargetPort() {
	return targetPort;
}

public int getThreadCount() {
	return threadCount;
}

public String getSessionLogDirName() {
	return sessionLogDirName;
}

public int getMaxConnectionCount()
{
return maxConnectionCount;
}

public int getRequestBodyTimeOut() {
	return requestBodyTimeOut;
}

public int getRequestHeaderTimeOut() {
	return requestHeaderTimeOut;
}

public Map getAdditionalRequestHeaderMap() {
	return additionalRequestHeaderMap;
}

public Map getAdditionalResponseHeaderMap() {
	return additionalResponseHeaderMap;
}

public Set getAllowedAddressSet() {
	return allowedAddressSet;
}

public MHttpFilter getRequestFilter() {
	return requestFilter;
}

public boolean getLimitRequestHeader() {
	return limitRequestHeader;
}

public boolean getLimitResponseHeader() {
	return limitResponseHeader;
}

public MHttpFilter getResponseFilter() {
	return responseFilter;
}

public List getRequestRuleList() {
	return requestRuleList;
}

public List getResponseRuleList() {
	return responseRuleList;
}

public String getUrlDecodingCharset() {
	return urlDecodingCharset;
}

public int getConnectTimeOut() {
	return connectTimeOut;
}

public long getCommandInterval() {
	return commandInterval;
}

public int getMaxQueueCount() {
	return maxQueueCount;
}

public Properties getControlProperties() {
	return control;
}

public File getConfigDir() {
	return configDir;
}

public boolean getEnableConsole()
{

return enableConsole;
}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -