📄 trtrackerserverimpl.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: TRTrackerServerImpl.java
package org.gudy.azureus2.core3.tracker.server.impl;
import java.io.PrintStream;
import java.net.URL;
import java.net.URLDecoder;
import java.util.*;
import org.gudy.azureus2.core3.config.COConfigurationListener;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.ipfilter.*;
import org.gudy.azureus2.core3.tracker.server.*;
import org.gudy.azureus2.core3.util.*;
// Referenced classes of package org.gudy.azureus2.core3.tracker.server.impl:
// TRTrackerServerFactoryImpl, TRTrackerServerRequestImpl, TRTrackerServerStatsImpl, TRTrackerServerTorrentImpl
public abstract class TRTrackerServerImpl
implements TRTrackerServer
{
public static final int RETRY_MINIMUM_SECS = 60;
public static final int RETRY_MINIMUM_MILLIS = 60000;
public static final int CLIENT_TIMEOUT_MULTIPLIER = 3;
public static final int TIMEOUT_CHECK = 0x2bf20;
public static int max_peers_to_send = 0;
public static boolean send_peer_ids = true;
public static int announce_cache_period = 500;
public static int scrape_cache_period = 5000;
public static int announce_cache_threshold = 500;
public static int max_seed_retention = 0;
public static int seed_limit = 0;
public static boolean full_scrape_enable = true;
public static boolean restrict_non_blocking_requests = true;
public static boolean all_networks_permitted = true;
public static String permitted_networks[] = new String[0];
public static boolean support_experimental_extensions;
public static String redirect_on_not_found = "";
private static Map torrent_map = new HashMap();
private static Map link_map = new HashMap();
protected AEMonitor class_mon;
protected IpFilter ip_filter;
private long current_announce_retry_interval;
private long current_scrape_retry_interval;
private long current_total_clients;
private int current_min_poll_interval;
private int current_min_seed_announce_mult;
private TRTrackerServerStatsImpl stats;
private String name;
private boolean web_password_enabled;
private boolean web_password_https_only;
private boolean tracker_password_enabled;
private String password_user;
private byte password_pw[];
private boolean compact_enabled;
private boolean key_enabled;
private boolean enabled;
protected Vector listeners;
private List auth_listeners;
private Vector request_listeners;
protected AEMonitor this_mon;
private COConfigurationListener config_listener;
private boolean destroyed;
private Set biased_peers;
private boolean is_ready;
protected static void readConfig()
{
send_peer_ids = COConfigurationManager.getBooleanParameter("Tracker Send Peer IDs");
max_peers_to_send = COConfigurationManager.getIntParameter("Tracker Max Peers Returned");
scrape_cache_period = COConfigurationManager.getIntParameter("Tracker Scrape Cache", 5000);
announce_cache_period = COConfigurationManager.getIntParameter("Tracker Announce Cache", 500);
announce_cache_threshold = COConfigurationManager.getIntParameter("Tracker Announce Cache Min Peers", 500);
max_seed_retention = COConfigurationManager.getIntParameter("Tracker Max Seeds Retained", 0);
seed_limit = COConfigurationManager.getIntParameter("Tracker Max Seeds", 0);
List nets = new ArrayList();
for (int i = 0; i < AENetworkClassifier.AT_NETWORKS.length; i++)
{
String net = AENetworkClassifier.AT_NETWORKS[i];
boolean enabled = COConfigurationManager.getBooleanParameter((new StringBuilder()).append("Tracker Network Selection Default.").append(net).toString());
if (enabled)
nets.add(net);
}
String s_nets[] = new String[nets.size()];
nets.toArray(s_nets);
permitted_networks = s_nets;
all_networks_permitted = s_nets.length == AENetworkClassifier.AT_NETWORKS.length;
full_scrape_enable = COConfigurationManager.getBooleanParameter("Tracker Server Full Scrape Enable");
redirect_on_not_found = COConfigurationManager.getStringParameter("Tracker Server Not Found Redirect").trim();
support_experimental_extensions = COConfigurationManager.getBooleanParameter("Tracker Server Support Experimental Extensions");
restrict_non_blocking_requests = COConfigurationManager.getBooleanParameter("Tracker TCP NonBlocking Restrict Request Types");
}
protected static boolean getSendPeerIds()
{
return send_peer_ids;
}
protected static int getMaxPeersToSend()
{
return max_peers_to_send;
}
protected static int getScrapeCachePeriod()
{
return scrape_cache_period;
}
protected static int getAnnounceCachePeriod()
{
return announce_cache_period;
}
protected static int getAnnounceCachePeerThreshold()
{
return announce_cache_threshold;
}
protected static int getMaxSeedRetention()
{
return max_seed_retention;
}
protected static int getSeedLimit()
{
return seed_limit;
}
public static boolean isFullScrapeEnabled()
{
return full_scrape_enable;
}
protected static boolean getAllNetworksSupported()
{
return all_networks_permitted;
}
protected static String[] getPermittedNetworks()
{
return permitted_networks;
}
public static boolean supportsExtensions()
{
return support_experimental_extensions;
}
public TRTrackerServerImpl(String _name, boolean _start_up_ready)
{
class_mon = new AEMonitor("TRTrackerServer:class");
ip_filter = IpFilterManagerFactory.getSingleton().getIPFilter();
stats = new TRTrackerServerStatsImpl(this);
enabled = true;
listeners = new Vector();
auth_listeners = new ArrayList();
request_listeners = new Vector();
this_mon = new AEMonitor("TRTrackerServer");
name = _name != null ? _name : "Azureus";
is_ready = _start_up_ready;
config_listener = new COConfigurationListener() {
final TRTrackerServerImpl this$0;
public void configurationSaved()
{
readConfigSettings();
}
{
this$0 = TRTrackerServerImpl.this;
super();
}
};
COConfigurationManager.addListener(config_listener);
readConfigSettings();
current_min_poll_interval = COConfigurationManager.getIntParameter("Tracker Poll Interval Min", 120);
if (current_min_poll_interval < 60)
current_min_poll_interval = 60;
current_min_seed_announce_mult = COConfigurationManager.getIntParameter("Tracker Poll Seed Interval Mult");
current_announce_retry_interval = current_min_poll_interval;
int scrape_percentage = COConfigurationManager.getIntParameter("Tracker Scrape Retry Percentage", 200);
current_scrape_retry_interval = (current_announce_retry_interval * (long)scrape_percentage) / 100L;
Thread timer_thread = new AEThread("TrackerServer:timer.loop") {
final TRTrackerServerImpl this$0;
public void runSupport()
{
timerLoop();
}
{
this$0 = TRTrackerServerImpl.this;
super(x0);
}
};
timer_thread.setDaemon(true);
timer_thread.start();
}
protected void readConfigSettings()
{
web_password_enabled = COConfigurationManager.getBooleanParameter("Tracker Password Enable Web");
tracker_password_enabled = COConfigurationManager.getBooleanParameter("Tracker Password Enable Torrent");
web_password_https_only = COConfigurationManager.getBooleanParameter("Tracker Password Web HTTPS Only");
if (web_password_enabled || tracker_password_enabled)
{
password_user = COConfigurationManager.getStringParameter("Tracker Username", "");
password_pw = COConfigurationManager.getByteParameter("Tracker Password", new byte[0]);
}
compact_enabled = COConfigurationManager.getBooleanParameter("Tracker Compact Enable");
key_enabled = COConfigurationManager.getBooleanParameter("Tracker Key Enable Server");
}
public void setReady()
{
is_ready = true;
}
public final boolean isReady()
{
return is_ready;
}
public void setEnabled(boolean e)
{
enabled = e;
}
public boolean isEnabled()
{
return enabled;
}
public TRTrackerServerTorrent addLink(String link, TRTrackerServerTorrent target)
{
TRTrackerServerTorrent trtrackerservertorrent;
class_mon.enter();
trtrackerservertorrent = (TRTrackerServerTorrent)link_map.put(link, target);
class_mon.exit();
return trtrackerservertorrent;
Exception exception;
exception;
class_mon.exit();
throw exception;
}
public void removeLink(String link, TRTrackerServerTorrent target)
{
class_mon.enter();
link_map.remove(link);
class_mon.exit();
break MISSING_BLOCK_LABEL_37;
Exception exception;
exception;
class_mon.exit();
throw exception;
}
public void setBiasedPeers(Set peers)
{
if (biased_peers != null && peers.equals(biased_peers))
return;
String str = "";
for (Iterator it = peers.iterator(); it.hasNext();)
str = (new StringBuilder()).append(str).append(" ").append(it.next()).toString();
System.out.println((new StringBuilder()).append("biased peers: ").append(str).toString());
class_mon.enter();
biased_peers = new HashSet(peers);
TRTrackerServerTorrentImpl this_torrent;
for (Iterator tit = torrent_map.values().iterator(); tit.hasNext(); this_torrent.updateBiasedPeers(biased_peers))
this_torrent = (TRTrackerServerTorrentImpl)tit.next();
class_mon.exit();
break MISSING_BLOCK_LABEL_185;
Exception exception;
exception;
class_mon.exit();
throw exception;
}
protected Set getBiasedPeers()
{
return biased_peers;
}
public boolean isWebPasswordEnabled()
{
return web_password_enabled || auth_listeners.size() > 0;
}
public boolean isTrackerPasswordEnabled()
{
return tracker_password_enabled || auth_listeners.size() > 0;
}
public boolean isWebPasswordHTTPSOnly()
{
return web_password_https_only;
}
public boolean hasExternalAuthorisation()
{
return auth_listeners.size() > 0;
}
public boolean hasInternalAuthorisation()
{
return web_password_enabled || tracker_password_enabled;
}
public boolean performExternalAuthorisation(URL resource, String user, String password)
{
int i = 0;
_L3:
if (i >= auth_listeners.size()) goto _L2; else goto _L1
_L1:
if (((TRTrackerServerAuthenticationListener)auth_listeners.get(i)).authenticate(resource, user, password))
return true;
continue; /* Loop/switch isn't completed */
Throwable e;
e;
Debug.printStackTrace(e);
i++;
goto _L3
_L2:
return false;
}
public byte[] performExternalAuthorisation(URL resource, String user)
{
int i = 0;
_L3:
if (i >= auth_listeners.size()) goto _L2; else goto _L1
_L1:
byte sha_pw[] = ((TRTrackerServerAuthenticationListener)auth_listeners.get(i)).authenticate(resource, user);
if (sha_pw != null)
return sha_pw;
continue; /* Loop/switch isn't completed */
Throwable e;
e;
Debug.printStackTrace(e);
i++;
goto _L3
_L2:
return null;
}
public String getName()
{
return name;
}
public boolean isCompactEnabled()
{
return compact_enabled;
}
public boolean isKeyEnabled()
{
return key_enabled;
}
public String getUsername()
{
return password_user;
}
public byte[] getPassword()
{
return password_pw;
}
public long getMinAnnounceRetryInterval()
{
return (long)current_min_poll_interval;
}
public long getAnnounceRetryInterval(TRTrackerServerTorrentImpl torrent)
{
long clients = current_total_clients;
if (clients == 0L)
return current_announce_retry_interval;
long res = ((long)torrent.getPeerCount() * current_announce_retry_interval) / clients;
if (res < (long)current_min_poll_interval)
res = current_min_poll_interval;
return res;
}
public long getSeedAnnounceIntervalMultiplier()
{
return (long)current_min_seed_announce_mult;
}
public long getScrapeRetryInterval(TRTrackerServerTorrentImpl torrent)
{
long clients = current_total_clients;
if (torrent == null || clients == 0L)
return current_scrape_retry_interval;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -