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

📄 trackerloadtester.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:   TrackerLoadTester.java

package org.gudy.azureus2.core3.tracker.client.impl.bt;

import java.net.*;

public class TrackerLoadTester
{

	private static final String trackerUrl = "http://localhost:6969/announce";

	public TrackerLoadTester(int nbTorrents, int nbClientsPerTorrent)
	{
		for (int i = 0; i < nbTorrents; i++)
		{
			byte hash[] = generate20BytesHash(i);
			for (int j = 0; j < nbClientsPerTorrent; j++)
			{
				byte peerId[] = generate20BytesHash(j);
				announce("http://localhost:6969/announce", hash, peerId, 6881 + j);
			}

		}

	}

	public static void main(String args[])
	{
		if (args.length < 2)
		{
			return;
		} else
		{
			int nbTorrents = Integer.parseInt(args[0]);
			int nbClientsPerTorrent = Integer.parseInt(args[1]);
			new TrackerLoadTester(nbTorrents, nbClientsPerTorrent);
			return;
		}
	}

	private void announce(String trackerURL, byte hash[], byte peerId[], int port)
	{
		try
		{
			String strUrl = (new StringBuilder()).append(trackerURL).append("?info_hash=").append(URLEncoder.encode(new String(hash, "ISO-8859-1"), "ISO-8859-1").replaceAll("\\+", "%20")).append("&peer_id=").append(URLEncoder.encode(new String(peerId, "ISO-8859-1"), "ISO-8859-1").replaceAll("\\+", "%20")).append("&port=").append(port).append("&uploaded=0&downloaded=0&left=0&numwant=50&no_peer_id=1&compact=1").toString();
			URL url = new URL(strUrl);
			URLConnection con = url.openConnection();
			con.connect();
			con.getContent();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}

	private byte[] generate20BytesHash(int iter)
	{
		byte result[] = new byte[20];
		int pos = 0;
		for (; iter > 0; iter /= 255)
			result[pos++] = (byte)(iter % 255);

		return result;
	}
}

⌨️ 快捷键说明

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