trackerwebcontextimpl.java

来自「java 文件下载器。可自定义」· Java 代码 · 共 168 行

JAVA
168
字号
// 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:   TrackerWebContextImpl.java

package org.gudy.azureus2.pluginsimpl.local.tracker;

import java.net.*;
import java.util.ArrayList;
import java.util.List;
import org.gudy.azureus2.core3.tracker.server.*;
import org.gudy.azureus2.core3.util.AEMonitor;
import org.gudy.azureus2.core3.util.Debug;
import org.gudy.azureus2.plugins.tracker.TrackerException;
import org.gudy.azureus2.plugins.tracker.web.TrackerAuthenticationListener;

// Referenced classes of package org.gudy.azureus2.pluginsimpl.local.tracker:
//			TrackerWCHelper, TrackerImpl

public class TrackerWebContextImpl extends TrackerWCHelper
	implements TRTrackerServerListener
{

	protected TRTrackerServer server;
	protected List auth_listeners;

	public TrackerWebContextImpl(TrackerImpl _tracker, String name, int port, int protocol, InetAddress bind_ip)
		throws TrackerException
	{
		auth_listeners = new ArrayList();
		setTracker(_tracker);
		try
		{
			if (protocol == 1)
				server = TRTrackerServerFactory.create(name, 1, port, bind_ip, false, false);
			else
				server = TRTrackerServerFactory.createSSL(name, 1, port, bind_ip, false, false);
			server.addListener(this);
		}
		catch (TRTrackerServerException e)
		{
			throw new TrackerException("TRTrackerServerFactory failed", e);
		}
	}

	public String getName()
	{
		return server.getName();
	}

	public URL[] getURLs()
	{
		URL url;
		url = new URL((new StringBuilder()).append(server.isSSL() ? "https" : "http").append("://").append(server.getHost()).append(":").append(server.getPort()).append("/").toString());
		if (url.getPort() != server.getPort())
		{
			Debug.out((new StringBuilder()).append("Invalid URL '").append(url).append("' - check tracker configuration").toString());
			url = new URL((new StringBuilder()).append("http://i.am.invalid:").append(server.getPort()).append("/").toString());
		}
		return (new URL[] {
			url
		});
		MalformedURLException e;
		e;
		Debug.printStackTrace(e);
		return null;
	}

	public int getProtocol()
	{
		return server.isSSL() ? 2 : 1;
	}

	public String getHostName()
	{
		return server.getHost();
	}

	public int getPort()
	{
		return server.getPort();
	}

	public boolean permitted(String originator, byte hash[], boolean explicit)
	{
		return false;
	}

	public boolean denied(byte hash[], boolean explicit)
	{
		return false;
	}

	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)
			server.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)
			server.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();
		server.removeAuthenticationListener(this);
		server.close();
	}
}

⌨️ 快捷键说明

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