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

📄 trtrackerservertcp.java

📁 java 文件下载器。可自定义
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   TRTrackerServerTCP.java

package org.gudy.azureus2.core3.tracker.server.impl.tcp;

import java.io.*;
import java.net.*;
import java.text.SimpleDateFormat;
import java.util.*;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.tracker.server.TRTrackerServerException;
import org.gudy.azureus2.core3.tracker.server.TRTrackerServerListener;
import org.gudy.azureus2.core3.tracker.server.impl.TRTrackerServerImpl;
import org.gudy.azureus2.core3.util.*;

// Referenced classes of package org.gudy.azureus2.core3.tracker.server.impl.tcp:
//			TRTrackerServerProcessorTCP

public abstract class TRTrackerServerTCP extends TRTrackerServerImpl
{
	protected class DOSEntry
	{

		String ip;
		long last_time;
		final TRTrackerServerTCP this$0;

		protected DOSEntry(String _ip)
		{
			this$0 = TRTrackerServerTCP.this;
			super();
			ip = _ip;
			last_time = last_dos_check;
		}
	}


	private static int THREAD_POOL_SIZE;
	public static long PROCESSING_GET_LIMIT;
	public static int PROCESSING_POST_MULTIPLIER;
	private boolean ssl;
	private int port;
	private boolean apply_ip_filter;
	private ThreadPool thread_pool;
	static boolean LOG_DOS_TO_FILE = false;
	protected static File dos_log_file;
	protected static AEMonitor class_mon = new AEMonitor("TRTrackerServerTCP:class");
	Map DOS_map;
	List dos_list;
	long last_dos_check;
	long MAX_DOS_ENTRIES;
	long MAX_DOS_RETENTION;
	int DOS_CHECK_DEAD_WOOD_COUNT;
	int DOS_MIN_INTERVAL;
	int dos_check_count;

	public TRTrackerServerTCP(String _name, int _port, boolean _ssl, boolean _apply_ip_filter, boolean _start_up_ready)
		throws TRTrackerServerException
	{
		super(_name, _start_up_ready);
		DOS_map = new LinkedHashMap(1000, 0.75F, true) {

			final TRTrackerServerTCP this$0;

			protected boolean removeEldestEntry(java.util.Map.Entry eldest)
			{
				return checkDOSRemove(eldest);
			}

			
			{
				this$0 = TRTrackerServerTCP.this;
				super(x0, x1, x2);
			}
		};
		dos_list = new ArrayList(128);
		last_dos_check = 0L;
		MAX_DOS_ENTRIES = 10000L;
		MAX_DOS_RETENTION = 10000L;
		DOS_CHECK_DEAD_WOOD_COUNT = 512;
		DOS_MIN_INTERVAL = 1000;
		dos_check_count = 0;
		port = _port;
		ssl = _ssl;
		apply_ip_filter = _apply_ip_filter;
		thread_pool = new ThreadPool((new StringBuilder()).append("TrackerServer:TCP:").append(port).toString(), THREAD_POOL_SIZE);
		if (PROCESSING_GET_LIMIT > 0L)
			thread_pool.setExecutionLimit(PROCESSING_GET_LIMIT);
	}

	public void runProcessor(TRTrackerServerProcessorTCP processor)
	{
		thread_pool.run(processor);
	}

	protected boolean isIPFilterEnabled()
	{
		return apply_ip_filter;
	}

	protected boolean checkDOS(String ip)
		throws UnknownHostException
	{
		boolean res;
		InetAddress inet_address = InetAddress.getByName(ip);
		if (inet_address.isLoopbackAddress() || InetAddress.getLocalHost().equals(inet_address))
			return false;
		last_dos_check = SystemTime.getCurrentTime();
		DOSEntry entry = (DOSEntry)DOS_map.get(ip);
		if (entry == null)
		{
			entry = new DOSEntry(ip);
			DOS_map.put(ip, entry);
			res = false;
		} else
		{
			res = last_dos_check - entry.last_time < (long)DOS_MIN_INTERVAL;
			if (res && LOG_DOS_TO_FILE)
				dos_list.add(entry);
			entry.last_time = last_dos_check;
		}
		dos_check_count++;
		if (dos_check_count != DOS_CHECK_DEAD_WOOD_COUNT)
			break MISSING_BLOCK_LABEL_512;
		dos_check_count = 0;
		Iterator it = DOS_map.values().iterator();
		do
		{
			if (!it.hasNext())
				break;
			DOSEntry this_entry = (DOSEntry)it.next();
			if (last_dos_check - this_entry.last_time <= MAX_DOS_RETENTION)
				break;
			it.remove();
		} while (true);
		if (dos_list.size() <= 0)
			break MISSING_BLOCK_LABEL_512;
label0:
		{
			class_mon.enter();
			if (dos_log_file == null)
				dos_log_file = new File((new StringBuilder()).append(System.getProperty("user.dir")).append(File.separator).append("dos.log").toString());
			PrintWriter pw = null;
			try
			{
				pw = new PrintWriter(new FileWriter(dos_log_file, true));
				for (int i = 0; i < dos_list.size(); i++)
				{
					DOSEntry this_entry = (DOSEntry)dos_list.get(i);
					String ts = (new SimpleDateFormat("hh:mm:ss - ")).format(new Date(this_entry.last_time));
					pw.println((new StringBuilder()).append(ts).append(this_entry.ip).toString());
				}

			}
			catch (Throwable e)
			{
				dos_list.clear();
				if (pw != null)
					try
					{
						pw.close();
					}
					// Misplaced declaration of an exception variable
					catch (Throwable e) { }
				break label0;
			}
			finally
			{
				dos_list.clear();
				if (pw != null)
					try
					{
						pw.close();
					}
					catch (Throwable e) { }
				throw exception;
			}
			dos_list.clear();
			if (pw != null)
				try
				{
					pw.close();
				}
				catch (Throwable e) { }
			break label0;
		}
		class_mon.exit();
		break MISSING_BLOCK_LABEL_512;
		Exception exception1;
		exception1;
		class_mon.exit();
		throw exception1;
		return res;
	}

	protected boolean checkDOSRemove(java.util.Map.Entry eldest)
	{
		boolean res = (long)DOS_map.size() > MAX_DOS_ENTRIES || last_dos_check - ((DOSEntry)eldest.getValue()).last_time > MAX_DOS_RETENTION;
		return res;
	}

	public int getPort()
	{
		return port;
	}

	protected void setPort(int _port)
	{
		port = _port;
	}

	public String getHost()
	{
		return COConfigurationManager.getStringParameter("Tracker IP", "");
	}

	public boolean isSSL()
	{
		return ssl;
	}

	protected boolean handleExternalRequest(InetSocketAddress client_address, String user, String url, URL absolute_url, String header, InputStream is, OutputStream os, 
			AsyncController async)
		throws IOException
	{
		int i = 0;
_L2:
		if (i >= listeners.size())
			break; /* Loop/switch isn't completed */
		this_mon.enter();
		if (i >= listeners.size())
		{
			this_mon.exit();
			break; /* Loop/switch isn't completed */
		}
		TRTrackerServerListener listener = (TRTrackerServerListener)listeners.elementAt(i);
		this_mon.exit();
		break MISSING_BLOCK_LABEL_80;
		Exception exception;
		exception;
		this_mon.exit();
		throw exception;
		if (listener.handleExternalRequest(client_address, user, url, absolute_url, header, is, os, async))
			return true;
		i++;
		if (true) goto _L2; else goto _L1
_L1:
		return false;
	}

	static 
	{
		THREAD_POOL_SIZE = COConfigurationManager.getIntParameter("Tracker Max Threads");
		PROCESSING_GET_LIMIT = COConfigurationManager.getIntParameter("Tracker Max GET Time") * 1000;
		PROCESSING_POST_MULTIPLIER = COConfigurationManager.getIntParameter("Tracker Max POST Time Multiplier");
		if (THREAD_POOL_SIZE <= 0)
			THREAD_POOL_SIZE = 1;
		if (PROCESSING_GET_LIMIT < 0L)
			PROCESSING_GET_LIMIT = 0L;
		if (PROCESSING_POST_MULTIPLIER < 0)
			PROCESSING_POST_MULTIPLIER = 0;
		LOG_DOS_TO_FILE = System.getProperty("azureus.log.dos") != null;
	}
}

⌨️ 快捷键说明

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