📄 trtrackerutils.java
字号:
res.add(new Integer(tok.nextToken().trim()));
}
catch (Throwable e)
{
Debug.out((new StringBuilder()).append("Invalid port entry in '").append(str).append("'").toString(), e);
}
return res;
}
public static URL adjustURLForHosting(URL url_in)
{
String url;
if (!isHosting(url_in))
break MISSING_BLOCK_LABEL_193;
url = (new StringBuilder()).append(url_in.getProtocol()).append("://").toString();
if (bind_ip.length() < 7)
url = (new StringBuilder()).append(url).append("127.0.0.1").toString();
else
url = (new StringBuilder()).append(url).append(bind_ip).toString();
int port = url_in.getPort();
if (port != -1)
url = (new StringBuilder()).append(url).append(":").append(url_in.getPort()).toString();
url = (new StringBuilder()).append(url).append(url_in.getPath()).toString();
String query = url_in.getQuery();
if (query != null)
url = (new StringBuilder()).append(url).append("?").append(query).toString();
return new URL(url);
MalformedURLException e;
e;
Debug.printStackTrace(e);
return url_in;
}
public static String adjustHostFromHosting(String host_in)
{
if (tracker_ip.length() > 0)
{
String address_type = AENetworkClassifier.categoriseAddress(host_in);
String target_ip = (String)override_map.get(address_type);
if (target_ip == null)
target_ip = tracker_ip;
if (host_in.equals("127.0.0.1"))
return target_ip;
if (host_in.equals(bind_ip))
return target_ip;
}
return host_in;
}
public static boolean isLoopback(String host)
{
return host.equals("127.0.0.1") || host.equals(bind_ip);
}
public static void checkForBlacklistedURLs(URL url)
throws IOException
{
for (int i = 0; i < BLACKLISTED_HOSTS.length; i++)
if (url.getHost().equalsIgnoreCase(BLACKLISTED_HOSTS[i]) && url.getPort() == BLACKLISTED_PORTS[i])
throw new IOException((new StringBuilder()).append("http://").append(BLACKLISTED_HOSTS[i]).append(":").append(BLACKLISTED_PORTS[i]).append("/ is not a tracker").toString());
}
public static Map mergeResponseCache(Map map1, Map map2)
{
return TRTrackerBTAnnouncerImpl.mergeResponseCache(map1, map2);
}
public static String getPortsForURL()
{
return ports_for_url;
}
public static String getPortsForURLFullCrypto()
{
return ports_for_url_with_crypto;
}
public static boolean isAZTracker(URL tracker_url)
{
String host;
host = tracker_url.getHost();
if (Constants.isAzureusDomain(host))
return true;
Map map = az_trackers;
JVM INSTR monitorenter ;
return az_trackers.containsKey((new StringBuilder()).append(host).append(":").append(tracker_url.getPort()).toString());
Exception exception;
exception;
throw exception;
}
public static void setAZTracker(URL tracker_url, boolean az_tracker)
{
String key = (new StringBuilder()).append(tracker_url.getHost()).append(":").append(tracker_url.getPort()).toString();
synchronized (az_trackers)
{
boolean changed = false;
if (az_trackers.get(key) == null)
{
if (az_tracker)
{
az_trackers.put(key, new Long(SystemTime.getCurrentTime()));
changed = true;
}
} else
if (!az_tracker && az_trackers.remove(key) != null)
changed = true;
if (changed)
COConfigurationManager.setParameter("Tracker Client AZ Instances", az_trackers);
}
}
public static boolean isUDPProbeOK(URL tracker_url)
{
String host;
host = tracker_url.getHost();
if (Constants.isAzureusDomain(host))
return false;
Map map = udp_probe_results;
JVM INSTR monitorenter ;
return udp_probe_results.containsKey(host);
Exception exception;
exception;
throw exception;
}
public static void setUDPProbeResult(URL tracker_url, boolean probe_ok)
{
String key = tracker_url.getHost();
synchronized (udp_probe_results)
{
boolean changed = false;
if (udp_probe_results.get(key) == null)
{
if (probe_ok)
{
if (udp_probe_results.size() > 512)
udp_probe_results.clear();
udp_probe_results.put(key, new Long(SystemTime.getCurrentTime()));
changed = true;
}
} else
if (!probe_ok && udp_probe_results.remove(key) != null)
changed = true;
if (changed)
COConfigurationManager.setParameter("Tracker Client UDP Probe Results", udp_probe_results);
}
}
public static void addListener(TRTrackerUtilsListener l)
{
listeners.add(l);
}
public static void removeListener(TRTrackerUtilsListener l)
{
listeners.remove(l);
}
static
{
COConfigurationManager.addAndFireParameterListeners(new String[] {
"Proxy.Data.Enable", "Proxy.Data.SOCKS.inform", "TCP.Listen.Port.Override", "Tracker Client No Port Announce", "network.transport.encrypted.use.crypto.port", "network.transport.encrypted.require", "network.transport.encrypted.fallback.incoming", "TCP.Listen.Port", "UDP.Listen.Port", "HTTP.Data.Listen.Port",
"HTTP.Data.Listen.Port.Override", "HTTP.Data.Listen.Port.Enable", "Tracker Client Min Announce Interval"
}, new ParameterListener() {
public void parameterChanged(String parameterName)
{
String port = TRTrackerUtils.computePortsForURL(false, true);
String port_with_crypto = TRTrackerUtils.computePortsForURL(true, false);
if (TRTrackerUtils.ports_for_url != null && !TRTrackerUtils.ports_for_url.equals(port))
synchronized (TRTrackerUtils.listeners)
{
if (TRTrackerUtils.listener_thread == null)
{
TRTrackerUtils.listener_thread = new AEThread2("TRTrackerUtils:listener", true) {
final 1 this$0;
public void run()
{
try
{
Thread.sleep(30000L);
}
catch (Throwable e) { }
synchronized (TRTrackerUtils.listeners)
{
TRTrackerUtils.listener_thread = null;
}
for (Iterator it = TRTrackerUtils.listeners.iterator(); it.hasNext();)
try
{
((TRTrackerUtilsListener)it.next()).announceDetailsChanged();
}
catch (Throwable e)
{
Debug.printStackTrace(e);
}
}
{
this$0 = 1.this;
super(x0, x1);
}
};
TRTrackerUtils.listener_thread.start();
}
}
TRTrackerUtils.ports_for_url = port;
TRTrackerUtils.ports_for_url_with_crypto = port_with_crypto;
}
});
COConfigurationManager.addListener(new COConfigurationListener() {
public void configurationSaved()
{
TRTrackerUtils.readConfig();
}
});
NetworkAdmin.getSingleton().addPropertyChangeListener(new NetworkAdminPropertyChangeListener() {
public void propertyChanged(String property)
{
if (property == "Default Bind IP")
TRTrackerUtils.readConfig();
}
});
readConfig();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -