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

📄 trtrackerserverimpl.java

📁 java 文件下载器。可自定义
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		long res = ((long)torrent.getPeerCount() * current_scrape_retry_interval) / clients;
		if (res < (long)current_min_poll_interval)
			res = current_min_poll_interval;
		return res;
	}

	public long getMinScrapeRetryInterval()
	{
		return (long)current_min_poll_interval;
	}

	public TRTrackerServerStats getStats()
	{
		return stats;
	}

	public void updateStats(int request_type, TRTrackerServerTorrentImpl torrent, int bytes_in, int bytes_out)
	{
		int num;
		stats.update(request_type, bytes_in, bytes_out);
		if (torrent != null)
		{
			torrent.updateXferStats(bytes_in, bytes_out);
			break MISSING_BLOCK_LABEL_186;
		}
		num = torrent_map.size();
		if (num >= 256)
			break MISSING_BLOCK_LABEL_186;
		class_mon.enter();
		if (num > 0)
		{
			int ave_in = bytes_in / num;
			int ave_out = bytes_out / num;
			int rem_in = bytes_in - ave_in * num;
			int rem_out = bytes_out - ave_out * num;
			for (Iterator it = torrent_map.values().iterator(); it.hasNext();)
			{
				TRTrackerServerTorrentImpl this_torrent = (TRTrackerServerTorrentImpl)it.next();
				if (it.hasNext())
					this_torrent.updateXferStats(ave_in, ave_out);
				else
					this_torrent.updateXferStats(ave_in + rem_in, ave_out + rem_out);
			}

		}
		class_mon.exit();
		break MISSING_BLOCK_LABEL_186;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

	protected void updateTime(int request_type, long time)
	{
		stats.updateTime(request_type, time);
	}

	protected void timerLoop()
	{
		long time_to_go = 0x2bf20L;
_L2:
		if (destroyed)
			break; /* Loop/switch isn't completed */
		int max;
		int inc_by;
		int inc_per;
		int scrape_percentage;
		int retry;
		int clients;
		Thread.sleep(60000L);
		time_to_go -= 60000L;
		current_min_poll_interval = COConfigurationManager.getIntParameter("Tracker Poll Interval Min", 120);
		if (current_min_poll_interval < 60)
			current_min_poll_interval = 60;
		int min = current_min_poll_interval;
		max = COConfigurationManager.getIntParameter("Tracker Poll Interval Max", 3600);
		inc_by = COConfigurationManager.getIntParameter("Tracker Poll Inc By", 60);
		inc_per = COConfigurationManager.getIntParameter("Tracker Poll Inc Per", 10);
		scrape_percentage = COConfigurationManager.getIntParameter("Tracker Scrape Retry Percentage", 200);
		retry = min;
		clients = 0;
		class_mon.enter();
		for (Iterator it = torrent_map.values().iterator(); it.hasNext();)
		{
			TRTrackerServerTorrentImpl t = (TRTrackerServerTorrentImpl)it.next();
			clients += t.getPeerCount();
		}

		class_mon.exit();
		break MISSING_BLOCK_LABEL_177;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
		if (inc_by > 0 && inc_per > 0)
			retry += inc_by * (clients / inc_per);
		if (max > 0 && retry > max)
			retry = max;
		if (retry < 60)
			retry = 60;
		current_announce_retry_interval = retry;
		current_scrape_retry_interval = (current_announce_retry_interval * (long)scrape_percentage) / 100L;
		current_total_clients = clients;
		if (time_to_go > 0L)
			continue; /* Loop/switch isn't completed */
		time_to_go = 0x2bf20L;
		class_mon.enter();
		TRTrackerServerTorrentImpl t;
		for (Iterator it = torrent_map.values().iterator(); it.hasNext(); t.checkTimeouts())
			t = (TRTrackerServerTorrentImpl)it.next();

		class_mon.exit();
		continue; /* Loop/switch isn't completed */
		Exception exception1;
		exception1;
		class_mon.exit();
		throw exception1;
		InterruptedException e;
		e;
		Debug.printStackTrace(e);
		if (true) goto _L2; else goto _L1
_L1:
	}

	public TRTrackerServerTorrent permit(String _originator, byte _hash[], boolean _explicit)
		throws TRTrackerServerException
	{
		return permit(_originator, _hash, _explicit, true);
	}

	public TRTrackerServerTorrent permit(String _originator, byte _hash[], boolean _explicit, boolean _enabled)
		throws TRTrackerServerException
	{
		HashWrapper hash = new HashWrapper(_hash);
		TRTrackerServerTorrentImpl entry;
		class_mon.enter();
		entry = (TRTrackerServerTorrentImpl)torrent_map.get(hash);
		class_mon.exit();
		break MISSING_BLOCK_LABEL_54;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
		if (entry != null)
			break MISSING_BLOCK_LABEL_189;
		for (int i = 0; i < listeners.size(); i++)
			if (!((TRTrackerServerListener)listeners.elementAt(i)).permitted(_originator, _hash, _explicit))
				throw new TRTrackerServerException("operation denied");

		class_mon.enter();
		entry = (TRTrackerServerTorrentImpl)torrent_map.get(hash);
		if (entry == null)
		{
			entry = new TRTrackerServerTorrentImpl(this, hash, _enabled);
			torrent_map.put(hash, entry);
		}
		class_mon.exit();
		break MISSING_BLOCK_LABEL_189;
		Exception exception1;
		exception1;
		class_mon.exit();
		throw exception1;
		return entry;
	}

	public void deny(byte _hash[], boolean _explicit)
		throws TRTrackerServerException
	{
		HashWrapper hash;
		hash = new HashWrapper(_hash);
		for (int i = 0; i < listeners.size(); i++)
			if (!((TRTrackerServerListener)listeners.elementAt(i)).denied(_hash, _explicit))
				throw new TRTrackerServerException("operation denied");

		class_mon.enter();
		TRTrackerServerTorrentImpl entry = (TRTrackerServerTorrentImpl)torrent_map.get(hash);
		if (entry != null)
			entry.delete();
		torrent_map.remove(hash);
		class_mon.exit();
		break MISSING_BLOCK_LABEL_125;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

	public TRTrackerServerTorrentImpl getTorrent(byte hash[])
	{
		TRTrackerServerTorrentImpl trtrackerservertorrentimpl;
		class_mon.enter();
		trtrackerservertorrentimpl = (TRTrackerServerTorrentImpl)torrent_map.get(new HashWrapper(hash));
		class_mon.exit();
		return trtrackerservertorrentimpl;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

	public TRTrackerServerTorrentImpl getTorrent(String link)
	{
		TRTrackerServerTorrentImpl trtrackerservertorrentimpl;
		class_mon.enter();
		trtrackerservertorrentimpl = (TRTrackerServerTorrentImpl)link_map.get(link);
		class_mon.exit();
		return trtrackerservertorrentimpl;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

	public TRTrackerServerTorrentImpl[] getTorrents()
	{
		TRTrackerServerTorrentImpl atrtrackerservertorrentimpl[];
		class_mon.enter();
		TRTrackerServerTorrentImpl res[] = new TRTrackerServerTorrentImpl[torrent_map.size()];
		torrent_map.values().toArray(res);
		atrtrackerservertorrentimpl = res;
		class_mon.exit();
		return atrtrackerservertorrentimpl;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

	public int getTorrentCount()
	{
		return torrent_map.size();
	}

	public TRTrackerServerTorrentStats getStats(byte hash[])
	{
		TRTrackerServerTorrentImpl torrent = getTorrent(hash);
		if (torrent == null)
			return null;
		else
			return torrent.getStats();
	}

	public TRTrackerServerPeer[] getPeers(byte hash[])
	{
		TRTrackerServerTorrentImpl torrent = getTorrent(hash);
		if (torrent == null)
			return null;
		else
			return torrent.getPeers();
	}

	public void addListener(TRTrackerServerListener l)
	{
		this_mon.enter();
		listeners.addElement(l);
		this_mon.exit();
		break MISSING_BLOCK_LABEL_35;
		Exception exception;
		exception;
		this_mon.exit();
		throw exception;
	}

	public void removeListener(TRTrackerServerListener l)
	{
		this_mon.enter();
		listeners.removeElement(l);
		this_mon.exit();
		break MISSING_BLOCK_LABEL_36;
		Exception exception;
		exception;
		this_mon.exit();
		throw exception;
	}

	public void addAuthenticationListener(TRTrackerServerAuthenticationListener l)
	{
		auth_listeners.add(l);
	}

	public void removeAuthenticationListener(TRTrackerServerAuthenticationListener l)
	{
		auth_listeners.remove(l);
	}

	public void preProcess(TRTrackerServerPeer peer, TRTrackerServerTorrent torrent, int type, String request, Map response)
		throws TRTrackerServerException
	{
		if (request_listeners.size() > 0)
		{
			if (type == 2)
				try
				{
					int request_pos = 10;
					do
					{
						int p = request.indexOf("info_hash=", request_pos);
						String bit;
						if (p == -1)
						{
							if (request_pos == 10)
								break;
							bit = request.substring(request_pos);
						} else
						{
							bit = request.substring(request_pos, p);
						}
						int pos = bit.indexOf('&');
						String hash_str = pos != -1 ? bit.substring(0, pos) : bit;
						hash_str = URLDecoder.decode(hash_str, "ISO-8859-1");
						byte hash[] = hash_str.getBytes("ISO-8859-1");
						if (Arrays.equals(hash, torrent.getHash().getBytes()))
						{
							request = (new StringBuilder()).append("info_hash=").append(bit).toString();
							if (request.endsWith("&"))
								request = request.substring(0, request.length() - 1);
							break;
						}
						if (p == -1)
							break;
						request_pos = p + 10;
					} while (true);
				}
				catch (Throwable e)
				{
					Debug.printStackTrace(e);
				}
			TRTrackerServerRequestImpl req = new TRTrackerServerRequestImpl(this, peer, torrent, type, request, response);
			for (int i = 0; i < request_listeners.size(); i++)
				try
				{
					((TRTrackerServerRequestListener)request_listeners.elementAt(i)).preProcess(req);
				}
				catch (TRTrackerServerException e)
				{
					throw e;
				}
				catch (Throwable e)
				{
					Debug.printStackTrace(e);
				}

		}
	}

	public void postProcess(TRTrackerServerPeer peer, TRTrackerServerTorrentImpl torrent, int type, String request, Map response)
		throws TRTrackerServerException
	{
		if (request_listeners.size() > 0)
		{
			TRTrackerServerRequestImpl req = new TRTrackerServerRequestImpl(this, peer, torrent, type, request, response);
			for (int i = 0; i < request_listeners.size(); i++)
				try
				{
					((TRTrackerServerRequestListener)request_listeners.elementAt(i)).postProcess(req);
				}
				catch (TRTrackerServerException e)
				{
					throw e;
				}
				catch (Throwable e)
				{
					Debug.printStackTrace(e);
				}

		}
	}

	public void addRequestListener(TRTrackerServerRequestListener l)
	{
		request_listeners.addElement(l);
	}

	public void removeRequestListener(TRTrackerServerRequestListener l)
	{
		request_listeners.removeElement(l);
	}

	public void close()
	{
		TRTrackerServerFactoryImpl.close(this);
	}

	protected abstract void closeSupport();

	protected void destroySupport()
	{
		destroyed = true;
		COConfigurationManager.removeListener(config_listener);
	}

	static 
	{
		COConfigurationManager.addListener(new COConfigurationListener() {

			public void configurationSaved()
			{
				TRTrackerServerImpl.readConfig();
			}

		});
		readConfig();
	}
}

⌨️ 快捷键说明

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