FileDocCategorySizeDatePackage
IPFilterImpl.javaAPI DocAzureus 3.0.3.44504Thu Feb 01 09:44:14 GMT 2007org.gudy.azureus2.pluginsimpl.local.ipfilter

IPFilterImpl

public class IPFilterImpl extends Object implements IPFilter
author
parg

Fields Summary
protected IpFilter
filter
Constructors Summary
public IPFilterImpl()

		filter = IpFilterManagerFactory.getSingleton().getIPFilter();
	
Methods Summary
public voidaddRange(IPRange range)

		if ( !(range instanceof IPRangeImpl )){
			
			throw( new RuntimeException( "range must be created by createRange"));
		}
		
		filter.addRange(((IPRangeImpl)range).getRange());
	
public voidban(java.lang.String IPAddress, java.lang.String text)

		filter.ban( IPAddress, text, false );
	
public voidblock(java.lang.String IPAddress)

		filter.ban( IPAddress, "<plugin>", false );
	
public IPRangecreateAndAddRange(java.lang.String description, java.lang.String start_ip, java.lang.String end_ip, boolean this_session_only)

		IPRange	range = createRange( this_session_only );
		
		range.setDescription( description );
		
		range.setStartIP( start_ip );
		
		range.setEndIP( end_ip );
		
		range.checkValid();
		
		if ( range.isValid()){
			
			addRange( range );
			
			return( range );
		}
		
		return( null );
	
public IPRangecreateRange(boolean this_session_only)

		return( new IPRangeImpl( this, filter.createRange( this_session_only )));
	
public IPBanned[]getBannedIPs()

 		BannedIp[]	l = filter.getBannedIps();
 		
 		IPBanned[]	res = new IPBanned[l.length];
 		
 		for (int i=0;i<l.length;i++){
 			
 			res[i] = new IPBannedImpl(l[i]);
 		}
 		
 		return( res );
 	
public IPBlocked[]getBlockedIPs()

		BlockedIp[]	l = filter.getBlockedIps();
		
		IPBlocked[]	res = new IPBlocked[l.length];
		
		for (int i=0;i<l.length;i++){
			
			res[i] = new IPBlockedImpl(this,l[i]);
		}
		
		return( res );
	
public java.io.FilegetFile()

		return( filter.getFile());
	
public booleangetInRangeAddressesAreAllowed()

		return( filter.getInRangeAddressesAreAllowed());
	
public longgetLastUpdateTime()

		return( filter.getLastUpdateTime());
	
public intgetNumberOfBannedIPs()

		return( filter.getNbBannedIps());
	
public intgetNumberOfBlockedIPs()

		return( filter.getNbIpsBlocked());
	
public intgetNumberOfRanges()

		return( filter.getNbRanges());
	
public IPRange[]getRanges()

		IpRange[] l = filter.getRanges();
		
		IPRange[]	res = new IPRange[l.length];
		
		for (int i=0;i<l.length;i++){
			
			res[i] = new IPRangeImpl(this, l[i]);
		}
		
		return( res );
	
public booleanisEnabled()

		return( filter.isEnabled());
	
public booleanisInRange(java.lang.String IPAddress)

		return( filter.isInRange(IPAddress));
	
public voidmarkAsUpToDate()

		filter.markAsUpToDate();
	
public voidreload()

		try{
			filter.reload();
			
		}catch( Throwable e ){
			
			throw( new IPFilterException( "IPFilter::reload fails", e ));
		}
	
public voidremoveRange(IPRange range)

		if ( !(range instanceof IPRangeImpl )){
			
			throw( new RuntimeException( "range must be created by createRange"));
		}
		
		filter.removeRange(((IPRangeImpl)range).getRange());
	
public voidsave()

		try{
			filter.save();
			
		}catch( Throwable e ){
			
			throw( new IPFilterException( "IPFilter::reload fails", e ));
		}
	
public voidsetEnabled(boolean enabled)

		filter.setEnabled( enabled );
	
public voidsetInRangeAddressesAreAllowed(boolean b)

		filter.setInRangeAddressesAreAllowed( b );
	
public voidunban(java.lang.String IPAddress)

		filter.unban( IPAddress );