1 /* 2 * File : IpFilter.java 3 * Created : 1 oct. 2003 12:27:26 4 * By : Olivier 5 * 6 * Azureus - a Java Bittorrent client 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details ( see the LICENSE file ). 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 */ 22 23 package org.gudy.azureus2.core3.ipfilter; 24 25 26 27 /** 28 * @author Olivier 29 * 30 */ 31 32 import java.util.List; 33 import java.io.File; 34 import java.net.InetAddress; 35 36 37 public interface 38 IpFilter 39 { getFile()40 public File getFile(); 41 save()42 public void save() throws Exception; 43 44 public void reload()45 reload() 46 47 throws Exception; 48 49 /** 50 * deprecated and to be removed after 2.0.8.0. Left in to support old SafePeer plugin 51 * version that uses this stuff directly... 52 * @deprecated 53 * @return 54 */ 55 public List getIpRanges()56 getIpRanges(); 57 58 public IpRange[] getRanges()59 getRanges(); 60 61 public boolean isInRange( String ipAddress)62 isInRange( 63 String ipAddress); 64 65 public boolean isInRange( String ipAddress, String torrent_name, byte[] torrent_hash )66 isInRange( 67 String ipAddress, 68 String torrent_name, 69 byte[] torrent_hash ); 70 71 public boolean isInRange( String ipAddress, String torrent_name, byte[] torrent_hash, boolean loggable )72 isInRange( 73 String ipAddress, 74 String torrent_name, 75 byte[] torrent_hash, 76 boolean loggable ); 77 78 public boolean isInRange( InetAddress ipAddress, String torrent_name, byte[] torrent_hash, boolean loggable )79 isInRange( 80 InetAddress ipAddress, 81 String torrent_name, 82 byte[] torrent_hash, 83 boolean loggable ); 84 85 public IpRange createRange( boolean sessionOnly)86 createRange( 87 boolean sessionOnly); 88 89 public void addRange( IpRange range )90 addRange( 91 IpRange range ); 92 93 public void removeRange( IpRange range )94 removeRange( 95 IpRange range ); 96 97 public int getNbRanges()98 getNbRanges(); 99 100 public int getNbIpsBlocked()101 getNbIpsBlocked(); 102 103 public int getNbIpsBlockedAndLoggable()104 getNbIpsBlockedAndLoggable(); 105 106 public BlockedIp[] getBlockedIps()107 getBlockedIps(); 108 109 public void clearBlockedIPs()110 clearBlockedIPs(); 111 112 public boolean ban( String ipAddress, String torrent_name, boolean manual )113 ban( 114 String ipAddress, 115 String torrent_name, 116 boolean manual ); 117 118 public boolean ban( String ipAddress, String torrent_name, boolean manual, int ban_for_mins )119 ban( 120 String ipAddress, 121 String torrent_name, 122 boolean manual, 123 int ban_for_mins ); 124 125 public void unban(String ipAddress)126 unban(String ipAddress); 127 128 public void unban(String ipAddress, boolean block)129 unban(String ipAddress, boolean block); 130 131 public int getNbBannedIps()132 getNbBannedIps(); 133 134 public BannedIp[] getBannedIps()135 getBannedIps(); 136 137 public void clearBannedIps()138 clearBannedIps(); 139 140 public void addExcludedHash( byte[] hash )141 addExcludedHash( 142 byte[] hash ); 143 144 public void removeExcludedHash( byte[] hash )145 removeExcludedHash( 146 byte[] hash ); 147 148 public boolean isEnabled()149 isEnabled(); 150 151 public void setEnabled( boolean enabled )152 setEnabled( 153 boolean enabled ); 154 155 public boolean getInRangeAddressesAreAllowed()156 getInRangeAddressesAreAllowed(); 157 158 public void setInRangeAddressesAreAllowed( boolean b )159 setInRangeAddressesAreAllowed( 160 boolean b ); 161 162 public void markAsUpToDate()163 markAsUpToDate(); 164 165 public long getLastUpdateTime()166 getLastUpdateTime(); 167 168 public long getTotalAddressesInRange()169 getTotalAddressesInRange(); 170 171 public void addListener( IPFilterListener l )172 addListener( 173 IPFilterListener l ); 174 175 public void removeListener( IPFilterListener l )176 removeListener( 177 IPFilterListener l ); 178 179 public void addExternalHandler( IpFilterExternalHandler handler )180 addExternalHandler( 181 IpFilterExternalHandler handler ); 182 183 public void removeExternalHandler( IpFilterExternalHandler handler )184 removeExternalHandler( 185 IpFilterExternalHandler handler ); 186 reloadSync()187 void reloadSync() 188 throws Exception; 189 } 190