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

📄 ipfiltermanagerimpl.java

📁 java 文件下载器。可自定义
💻 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:   IpFilterManagerImpl.java

package org.gudy.azureus2.core3.ipfilter.impl;

import java.io.*;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.config.ParameterListener;
import org.gudy.azureus2.core3.ipfilter.*;
import org.gudy.azureus2.core3.util.FileUtil;

// Referenced classes of package org.gudy.azureus2.core3.ipfilter.impl:
//			BadIpsImpl, IpFilterImpl, IpRangeImpl

public class IpFilterManagerImpl
	implements IpFilterManager, ParameterListener
{

	protected static IpFilterManagerImpl singleton = new IpFilterManagerImpl();
	private RandomAccessFile rafDescriptions;

	public IpFilterManagerImpl()
	{
		rafDescriptions = null;
		COConfigurationManager.addAndFireParameterListener("Ip Filter Enable Description Cache", this);
	}

	public Object addDescription(IpRange range, byte description[])
	{
		if (rafDescriptions == null)
			return null;
		if (description == null || description.length == 0)
			return null;
		int start;
		int len;
		start = (int)rafDescriptions.getFilePointer();
		len = (int)rafDescriptions.length();
		if (len + 61 >= 0x1ffffff)
			return null;
		int info;
		if (start != len)
		{
			rafDescriptions.seek(len);
			start = (int)rafDescriptions.getFilePointer();
		}
		if (description.length <= 61)
			rafDescriptions.write(description);
		else
			rafDescriptions.write(description, 0, 61);
		int end = (int)rafDescriptions.getFilePointer();
		info = start + (end - start << 25);
		return new Integer(info);
		Exception e;
		e;
		e.printStackTrace();
		return null;
	}

	public byte[] getDescription(Object info)
	{
		if (info instanceof Object[])
			return (byte[])(byte[])((Object[])(Object[])info)[0];
		if (rafDescriptions == null || !(info instanceof Integer))
			return "".getBytes();
		byte bytes[];
		int posInfo = ((Integer)info).intValue();
		int pos = posInfo & 0x1ffffff;
		int len = posInfo >> 25;
		if (len < 0)
			throw new IllegalArgumentException((new StringBuilder()).append(getClass().getName()).append(": invalid posInfo [").append(posInfo).append("], pos [").append(pos).append("], len [").append(len).append("]").toString());
		if (rafDescriptions.getFilePointer() != (long)pos)
			rafDescriptions.seek(pos);
		bytes = new byte[len];
		rafDescriptions.read(bytes);
		return bytes;
		IOException e;
		e;
		return "".getBytes();
	}

	public void cacheAllDescriptions()
	{
		IpRange ranges[] = getIPFilter().getRanges();
		for (int i = 0; i < ranges.length; i++)
		{
			Object info = ((IpRangeImpl)ranges[i]).getDescRef();
			if (info instanceof Integer)
			{
				byte desc[] = getDescription(info);
				Object data[] = {
					desc, info
				};
				((IpRangeImpl)ranges[i]).setDescRef(((Object) (data)));
			}
		}

	}

	public void clearDescriptionCache()
	{
		IpRange ranges[] = getIPFilter().getRanges();
		for (int i = 0; i < ranges.length; i++)
		{
			Object info = ((IpRangeImpl)ranges[i]).getDescRef();
			if (info instanceof Object[])
			{
				Integer data = (Integer)((Object[])(Object[])info)[1];
				((IpRangeImpl)ranges[i]).setDescRef(data);
			}
		}

	}

	public void deleteAllDescriptions()
	{
		if (rafDescriptions != null)
		{
			try
			{
				rafDescriptions.close();
			}
			catch (IOException e) { }
			rafDescriptions = null;
		}
		parameterChanged(null);
	}

	public static IpFilterManager getSingleton()
	{
		return singleton;
	}

	public IpFilter getIPFilter()
	{
		return IpFilterImpl.getInstance();
	}

	public BadIps getBadIps()
	{
		return BadIpsImpl.getInstance();
	}

	public void parameterChanged(String parameterName)
	{
		boolean enable = COConfigurationManager.getBooleanParameter("Ip Filter Enable Description Cache");
		if (enable && rafDescriptions == null)
		{
			File fDescriptions = FileUtil.getUserFile("ipfilter.cache");
			try
			{
				if (fDescriptions.exists())
					fDescriptions.delete();
				rafDescriptions = new RandomAccessFile(fDescriptions, "rw");
			}
			catch (FileNotFoundException e)
			{
				e.printStackTrace();
			}
		} else
		if (!enable && rafDescriptions != null)
		{
			try
			{
				rafDescriptions.close();
			}
			catch (IOException e) { }
			rafDescriptions = null;
		}
	}

}

⌨️ 快捷键说明

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