📄 trackerimpl.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: TrackerImpl.java
package org.gudy.azureus2.pluginsimpl.local.tracker;
import java.net.InetAddress;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.gudy.azureus2.core3.tracker.host.*;
import org.gudy.azureus2.core3.tracker.util.TRTrackerUtils;
import org.gudy.azureus2.core3.util.AEMonitor;
import org.gudy.azureus2.core3.util.Debug;
import org.gudy.azureus2.plugins.torrent.Torrent;
import org.gudy.azureus2.plugins.tracker.*;
import org.gudy.azureus2.plugins.tracker.web.TrackerAuthenticationListener;
import org.gudy.azureus2.plugins.tracker.web.TrackerWebContext;
import org.gudy.azureus2.pluginsimpl.local.torrent.TorrentImpl;
// Referenced classes of package org.gudy.azureus2.pluginsimpl.local.tracker:
// TrackerWCHelper, TrackerTorrentImpl, TrackerWebContextImpl
public class TrackerImpl extends TrackerWCHelper
implements Tracker, TRHostListener, TRHostAuthenticationListener
{
private static TrackerImpl singleton;
private static AEMonitor class_mon = new AEMonitor("Tracker");
private List listeners;
private TRHost host;
private List auth_listeners;
public static Tracker getSingleton()
{
TrackerImpl trackerimpl;
class_mon.enter();
if (singleton == null)
singleton = new TrackerImpl(TRHostFactory.getSingleton());
trackerimpl = singleton;
class_mon.exit();
return trackerimpl;
Exception exception;
exception;
class_mon.exit();
throw exception;
}
protected TrackerImpl(TRHost _host)
{
listeners = new ArrayList();
auth_listeners = new ArrayList();
setTracker(this);
host = _host;
host.addListener(this);
}
public String getName()
{
return host.getName();
}
public URL[] getURLs()
{
URL url_sets[][] = TRTrackerUtils.getAnnounceURLs();
URL res[] = new URL[url_sets.length];
for (int i = 0; i < res.length; i++)
res[i] = url_sets[i][0];
return res;
}
public TrackerTorrent host(Torrent _torrent, boolean _persistent)
throws TrackerException
{
return host(_torrent, _persistent, false);
}
public TrackerTorrent host(Torrent _torrent, boolean _persistent, boolean _passive)
throws TrackerException
{
TorrentImpl torrent = (TorrentImpl)_torrent;
return new TrackerTorrentImpl(host.hostTorrent(torrent.getTorrent(), _persistent, _passive));
Throwable e;
e;
throw new TrackerException("Tracker: host operation fails", e);
}
public TrackerTorrent publish(Torrent _torrent)
throws TrackerException
{
TorrentImpl torrent = (TorrentImpl)_torrent;
return new TrackerTorrentImpl(host.publishTorrent(torrent.getTorrent()));
Throwable e;
e;
throw new TrackerException("Tracker: publish operation fails", e);
}
public TrackerTorrent[] getTorrents()
{
TRHostTorrent hts[] = host.getTorrents();
TrackerTorrent res[] = new TrackerTorrent[hts.length];
for (int i = 0; i < hts.length; i++)
res[i] = new TrackerTorrentImpl(hts[i]);
return res;
}
public TrackerTorrent getTorrent(Torrent torrent)
{
TRHostTorrent ht = host.getHostTorrent(((TorrentImpl)torrent).getTorrent());
if (ht == null)
return null;
else
return new TrackerTorrentImpl(ht);
}
public TrackerWebContext createWebContext(int port, int protocol)
throws TrackerException
{
return new TrackerWebContextImpl(this, null, port, protocol, null);
}
public TrackerWebContext createWebContext(String name, int port, int protocol)
throws TrackerException
{
return new TrackerWebContextImpl(this, name, port, protocol, null);
}
public TrackerWebContext createWebContext(String name, int port, int protocol, InetAddress bind_ip)
throws TrackerException
{
return new TrackerWebContextImpl(this, name, port, protocol, bind_ip);
}
public void torrentAdded(TRHostTorrent t)
{
this_mon.enter();
for (int i = 0; i < listeners.size(); i++)
((TrackerListener)listeners.get(i)).torrentAdded(new TrackerTorrentImpl(t));
this_mon.exit();
break MISSING_BLOCK_LABEL_74;
Exception exception;
exception;
this_mon.exit();
throw exception;
}
public void torrentChanged(TRHostTorrent t)
{
for (int i = 0; i < listeners.size(); i++)
((TrackerListener)listeners.get(i)).torrentChanged(new TrackerTorrentImpl(t));
}
public void torrentRemoved(TRHostTorrent t)
{
this_mon.enter();
for (int i = 0; i < listeners.size(); i++)
((TrackerListener)listeners.get(i)).torrentRemoved(new TrackerTorrentImpl(t));
this_mon.exit();
break MISSING_BLOCK_LABEL_74;
Exception exception;
exception;
this_mon.exit();
throw exception;
}
public void addListener(TrackerListener listener)
{
this_mon.enter();
listeners.add(listener);
TrackerTorrent torrents[] = getTorrents();
for (int i = 0; i < torrents.length; i++)
listener.torrentAdded(torrents[i]);
this_mon.exit();
break MISSING_BLOCK_LABEL_68;
Exception exception;
exception;
this_mon.exit();
throw exception;
}
public void removeListener(TrackerListener listener)
{
this_mon.enter();
listeners.remove(listener);
this_mon.exit();
break MISSING_BLOCK_LABEL_38;
Exception exception;
exception;
this_mon.exit();
throw exception;
}
public boolean authenticate(URL resource, String user, String password)
{
int i = 0;
_L3:
if (i >= auth_listeners.size()) goto _L2; else goto _L1
_L1:
boolean res = ((TrackerAuthenticationListener)auth_listeners.get(i)).authenticate(resource, user, password);
if (res)
return true;
continue; /* Loop/switch isn't completed */
Throwable e;
e;
Debug.printStackTrace(e);
i++;
goto _L3
_L2:
return false;
}
public byte[] authenticate(URL resource, String user)
{
int i = 0;
_L3:
if (i >= auth_listeners.size()) goto _L2; else goto _L1
_L1:
byte res[] = ((TrackerAuthenticationListener)auth_listeners.get(i)).authenticate(resource, user);
if (res != null)
return res;
continue; /* Loop/switch isn't completed */
Throwable e;
e;
Debug.printStackTrace(e);
i++;
goto _L3
_L2:
return null;
}
public void addAuthenticationListener(TrackerAuthenticationListener l)
{
this_mon.enter();
auth_listeners.add(l);
if (auth_listeners.size() == 1)
host.addAuthenticationListener(this);
this_mon.exit();
break MISSING_BLOCK_LABEL_61;
Exception exception;
exception;
this_mon.exit();
throw exception;
}
public void removeAuthenticationListener(TrackerAuthenticationListener l)
{
this_mon.enter();
auth_listeners.remove(l);
if (auth_listeners.size() == 0)
host.removeAuthenticationListener(this);
this_mon.exit();
break MISSING_BLOCK_LABEL_60;
Exception exception;
exception;
this_mon.exit();
throw exception;
}
public void destroy()
{
super.destroy();
auth_listeners.clear();
host.removeAuthenticationListener(this);
listeners.clear();
host.close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -