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

📄 webplugin.java

📁 java 文件下载器。可自定义
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// 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:   WebPlugin.java

package org.gudy.azureus2.ui.webplugin;

import com.aelitis.azureus.plugins.upnp.UPnPPlugin;
import java.io.*;
import java.net.InetAddress;
import java.net.URL;
import java.util.Arrays;
import java.util.Properties;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.plugins.*;
import org.gudy.azureus2.plugins.ipfilter.IPFilter;
import org.gudy.azureus2.plugins.ipfilter.IPRange;
import org.gudy.azureus2.plugins.logging.*;
import org.gudy.azureus2.plugins.tracker.Tracker;
import org.gudy.azureus2.plugins.tracker.TrackerException;
import org.gudy.azureus2.plugins.tracker.web.*;
import org.gudy.azureus2.plugins.ui.UIManager;
import org.gudy.azureus2.plugins.ui.components.*;
import org.gudy.azureus2.plugins.ui.config.*;
import org.gudy.azureus2.plugins.ui.model.BasicPluginConfigModel;
import org.gudy.azureus2.plugins.ui.model.BasicPluginViewModel;
import org.gudy.azureus2.plugins.utils.Utilities;
import org.gudy.azureus2.plugins.utils.security.SESecurityManager;

public class WebPlugin
	implements Plugin, TrackerWebPageGenerator
{

	public static final String PR_PORT = "Port";
	public static final String PR_BIND_IP = "Bind IP";
	public static final String PR_ROOT_RESOURCE = "Root Resource";
	public static final String PR_LOG = "DefaultLoggerChannel";
	public static final String PR_CONFIG_MODEL = "DefaultConfigModel";
	public static final String PR_VIEW_MODEL = "DefaultViewModel";
	public static final String PR_HIDE_RESOURCE_CONFIG = "DefaultHideResourceConfig";
	public static final String PROPERTIES_MIGRATED = "Properties Migrated";
	public static final String CONFIG_MIGRATED = "Config Migrated";
	public static final String CONFIG_PASSWORD_ENABLE = "Password Enable";
	public final boolean CONFIG_PASSWORD_ENABLE_DEFAULT = false;
	public static final String CONFIG_USER = "User";
	public final String CONFIG_USER_DEFAULT = "";
	public static final String CONFIG_PASSWORD = "Password";
	public final byte CONFIG_PASSWORD_DEFAULT[];
	public static final String CONFIG_PORT = "Port";
	public int CONFIG_PORT_DEFAULT;
	public static final String CONFIG_BIND_IP = "Bind IP";
	public String CONFIG_BIND_IP_DEFAULT;
	public static final String CONFIG_PROTOCOL = "Protocol";
	public final String CONFIG_PROTOCOL_DEFAULT = "HTTP";
	public static final String CONFIG_UPNP_ENABLE = "UPnP Enable";
	public final boolean CONFIG_UPNP_ENABLE_DEFAULT = true;
	public static final String CONFIG_HOME_PAGE = "Home Page";
	public final String CONFIG_HOME_PAGE_DEFAULT = "index.html";
	public static final String CONFIG_ROOT_DIR = "Root Dir";
	public final String CONFIG_ROOT_DIR_DEFAULT = "";
	public static final String CONFIG_ROOT_RESOURCE = "Root Resource";
	public String CONFIG_ROOT_RESOURCE_DEFAULT;
	public static final String CONFIG_MODE = "Mode";
	public static final String CONFIG_MODE_FULL = "full";
	public final String CONFIG_MODE_DEFAULT = "full";
	public static final String CONFIG_ACCESS = "Access";
	public final String CONFIG_ACCESS_DEFAULT = "all";
	protected static final String NL = "\r\n";
	protected static final String welcome_pages[] = {
		"index.html", "index.htm", "index.php", "index.tmpl"
	};
	protected static File welcome_files[];
	protected PluginInterface plugin_interface;
	private LoggerChannel log;
	private Tracker tracker;
	private BasicPluginViewModel view_model;
	private BasicPluginConfigModel config_model;
	private String home_page;
	private String file_root;
	private String resource_root;
	private boolean ip_range_all;
	private IPRange ip_range;
	private Properties properties;

	public WebPlugin()
	{
		CONFIG_PASSWORD_DEFAULT = new byte[0];
		CONFIG_PORT_DEFAULT = 8089;
		CONFIG_BIND_IP_DEFAULT = "";
		CONFIG_ROOT_RESOURCE_DEFAULT = "";
		ip_range_all = false;
		properties = new Properties();
	}

	public WebPlugin(Properties defaults)
	{
		CONFIG_PASSWORD_DEFAULT = new byte[0];
		CONFIG_PORT_DEFAULT = 8089;
		CONFIG_BIND_IP_DEFAULT = "";
		CONFIG_ROOT_RESOURCE_DEFAULT = "";
		ip_range_all = false;
		properties = defaults;
	}

	public void initialize(PluginInterface _plugin_interface)
		throws PluginException
	{
		Boolean pr_hide_resource_config;
		PluginConfig plugin_config;
		boolean save_needed;
		Properties props;
		File props_file;
		PrintWriter pw;
		plugin_interface = _plugin_interface;
		Integer pr_port = (Integer)properties.get("Port");
		if (pr_port != null)
			CONFIG_PORT_DEFAULT = pr_port.intValue();
		String pr_bind_ip = (String)properties.get("Bind IP");
		if (pr_bind_ip != null)
			CONFIG_BIND_IP_DEFAULT = pr_bind_ip.trim();
		String pr_root_resource = (String)properties.get("Root Resource");
		if (pr_root_resource != null)
			CONFIG_ROOT_RESOURCE_DEFAULT = pr_root_resource;
		pr_hide_resource_config = (Boolean)properties.get("DefaultHideResourceConfig");
		log = (LoggerChannel)properties.get("DefaultLoggerChannel");
		if (log == null)
			log = plugin_interface.getLogger().getChannel("WebPlugin");
		UIManager ui_manager = plugin_interface.getUIManager();
		view_model = (BasicPluginViewModel)properties.get("DefaultViewModel");
		if (view_model == null)
			view_model = ui_manager.createBasicPluginViewModel(plugin_interface.getPluginName());
		String sConfigSectionID = (new StringBuilder()).append("plugins.").append(plugin_interface.getPluginID()).toString();
		view_model.setConfigSectionID(sConfigSectionID);
		view_model.getStatus().setText("Running");
		view_model.getActivity().setVisible(false);
		view_model.getProgress().setVisible(false);
		log.addListener(new LoggerChannelListener() {

			final WebPlugin this$0;

			public void messageLogged(int type, String message)
			{
				view_model.getLogArea().appendText((new StringBuilder()).append(message).append("\n").toString());
			}

			public void messageLogged(String str, Throwable error)
			{
				view_model.getLogArea().appendText((new StringBuilder()).append(str).append("\n").toString());
				view_model.getLogArea().appendText((new StringBuilder()).append(error.toString()).append("\n").toString());
			}

			
			{
				this$0 = WebPlugin.this;
				super();
			}
		});
		plugin_config = plugin_interface.getPluginconfig();
		config_model = (BasicPluginConfigModel)properties.get("DefaultConfigModel");
		if (config_model == null)
			config_model = ui_manager.createBasicPluginConfigModel("plugins", sConfigSectionID);
		save_needed = false;
		if (!plugin_config.getPluginBooleanParameter("Config Migrated", false))
		{
			plugin_config.setPluginParameter("Config Migrated", true);
			save_needed = true;
			plugin_config.setPluginParameter("Password Enable", plugin_config.getBooleanParameter("Tracker Password Enable Web", false));
			plugin_config.setPluginParameter("User", plugin_config.getStringParameter("Tracker Username", ""));
			plugin_config.setPluginParameter("Password", plugin_config.getByteParameter("Tracker Password", CONFIG_PASSWORD_DEFAULT));
		}
		if (plugin_config.getPluginBooleanParameter("Properties Migrated", false))
			break MISSING_BLOCK_LABEL_1011;
		plugin_config.setPluginParameter("Properties Migrated", true);
		props = plugin_interface.getPluginProperties();
		if (props.getProperty("port", "").length() <= 0)
			break MISSING_BLOCK_LABEL_1011;
		save_needed = true;
		String prop_port = props.getProperty("port", (new StringBuilder()).append("").append(CONFIG_PORT_DEFAULT).toString());
		String prop_protocol = props.getProperty("protocol", "HTTP");
		String prop_home = props.getProperty("homepage", "index.html");
		String prop_rootdir = props.getProperty("rootdir", "");
		String prop_rootres = props.getProperty("rootresource", CONFIG_ROOT_RESOURCE_DEFAULT);
		String prop_mode = props.getProperty("mode", "full");
		String prop_access = props.getProperty("access", "all");
		int prop_port_int = CONFIG_PORT_DEFAULT;
		try
		{
			prop_port_int = Integer.parseInt(prop_port);
		}
		catch (Throwable e) { }
		plugin_config.setPluginParameter("Port", prop_port_int);
		plugin_config.setPluginParameter("Protocol", prop_protocol);
		plugin_config.setPluginParameter("Home Page", prop_home);
		plugin_config.setPluginParameter("Root Dir", prop_rootdir);
		plugin_config.setPluginParameter("Root Resource", prop_rootres);
		plugin_config.setPluginParameter("Mode", prop_mode);
		plugin_config.setPluginParameter("Access", prop_access);
		props_file = new File(plugin_interface.getPluginDirectoryName(), "plugin.properties");
		pw = null;
		File backup = new File(plugin_interface.getPluginDirectoryName(), "plugin.properties.bak");
		props_file.renameTo(backup);
		pw = new PrintWriter(new FileWriter(props_file));
		pw.println((new StringBuilder()).append("plugin.class=").append(props.getProperty("plugin.class")).toString());
		pw.println((new StringBuilder()).append("plugin.name=").append(props.getProperty("plugin.name")).toString());
		pw.println((new StringBuilder()).append("plugin.version=").append(props.getProperty("plugin.version")).toString());
		pw.println((new StringBuilder()).append("plugin.id=").append(props.getProperty("plugin.id")).toString());
		pw.println("");
		pw.println("# configuration has been migrated to plugin config - see view->config->plugins");
		pw.println("# in the SWT user interface");
		log.logAlert(1, (new StringBuilder()).append(plugin_interface.getPluginName()).append(" - plugin.properties settings migrated to plugin configuration.").toString());
		if (pw != null)
			pw.close();
		break MISSING_BLOCK_LABEL_1011;
		Throwable e;
		e;
		Debug.printStackTrace(e);
		log.logAlert(3, (new StringBuilder()).append(plugin_interface.getPluginName()).append(" - plugin.properties settings migration failed.").toString());
		if (pw != null)
			pw.close();
		break MISSING_BLOCK_LABEL_1011;
		Exception exception;
		exception;
		if (pw != null)
			pw.close();
		throw exception;
		if (save_needed)
			plugin_config.save();
		config_model.addLabelParameter2("webui.restart.info");
		IntParameter param_port = config_model.addIntParameter2("Port", "webui.port", CONFIG_PORT_DEFAULT);
		StringParameter param_bind = config_model.addStringParameter2("Bind IP", "webui.bindip", CONFIG_BIND_IP_DEFAULT);
		StringListParameter param_protocol = config_model.addStringListParameter2("Protocol", "webui.protocol", new String[] {
			"http", "https"
		}, "HTTP");
		final BooleanParameter upnp_enable = config_model.addBooleanParameter2("UPnP Enable", "webui.upnpenable", true);
		StringParameter param_home = config_model.addStringParameter2("Home Page", "webui.homepage", "index.html");
		StringParameter param_rootdir = config_model.addStringParameter2("Root Dir", "webui.rootdir", "");
		StringParameter param_rootres = config_model.addStringParameter2("Root Resource", "webui.rootres", CONFIG_ROOT_RESOURCE_DEFAULT);
		if (pr_hide_resource_config != null && pr_hide_resource_config.booleanValue())
		{
			param_home.setVisible(false);
			param_rootdir.setVisible(false);
			param_rootres.setVisible(false);
		}
		config_model.addLabelParameter2("webui.mode.info");
		config_model.addStringListParameter2("Mode", "webui.mode", new String[] {
			"full", "view"
		}, "full");
		config_model.addLabelParameter2("webui.access.info");
		StringParameter param_access = config_model.addStringParameter2("Access", "webui.access", "all");
		final BooleanParameter pw_enable = config_model.addBooleanParameter2("Password Enable", "webui.passwordenable", false);
		final StringParameter user_name = config_model.addStringParameter2("User", "webui.user", "");
		final PasswordParameter password = config_model.addPasswordParameter2("Password", "webui.password", 2, CONFIG_PASSWORD_DEFAULT);
		pw_enable.addEnabledOnSelection(user_name);
		pw_enable.addEnabledOnSelection(password);
		tracker = plugin_interface.getTracker();
		home_page = param_home.getValue().trim();
		if (home_page.length() == 0)
			home_page = null;
		else
		if (!home_page.startsWith("/"))
			home_page = (new StringBuilder()).append("/").append(home_page).toString();
		resource_root = param_rootres.getValue().trim();
		if (resource_root.length() == 0)
			resource_root = null;
		else
		if (resource_root.startsWith("/"))
			resource_root = resource_root.substring(1);
		String root_dir = param_rootdir.getValue().trim();
		if (root_dir.length() == 0)
		{
			file_root = plugin_interface.getPluginDirectoryName();
			if (file_root == null)

⌨️ 快捷键说明

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