Methods Summary |
---|
private static boolean | canBan(java.lang.String ip)
if ( cache_ips.contains( ip )){
return( false );
}
try{
InetAddress address = HostNameToIPResolver.syncResolve( ip );
final String host_address = address.getHostAddress();
if ( cache_ips.contains( host_address )){
return( false );
}
// reverse lookups can be very slow
IPToHostNameResolver.addResolverRequest(
ip,
new IPToHostNameResolverListener()
{
public void
IPResolutionComplete(
String result,
boolean succeeded )
{
String[] ok_domains = Constants.AZUREUS_DOMAINS;
for (int i=0;i<ok_domains.length;i++){
if ( result.endsWith( "." + ok_domains[i] )){
cache_ips.add( host_address );
ip_filter.unban( host_address, true );
}
}
}
});
return( true );
}catch( Throwable e ){
Debug.printStackTrace( e );
return( true );
}
|
public static CachePeer | categorisePeer(byte[] peer_id, java.net.InetAddress ip, int port)
for (int i=0;i<discoverers.length;i++){
CachePeer cp = discoverers[i].lookup( peer_id, ip, port );
if ( cp != null ){
return( cp );
}
}
return( new CachePeerImpl( CachePeer.PT_NONE, ip, port ));
|
public static void | initialise(com.aelitis.azureus.core.download.DownloadManagerEnhancer dme)
ip_filter.addListener(
new IPFilterListener()
{
public boolean
canIPBeBanned(
String ip )
{
return( canBan( ip ));
}
public void
IPBanned(
BannedIp ip )
{
}
public void
IPBlockedListChanged(
IpFilter filter)
{
}
public boolean
canIPBeBlocked(
String ip,
byte[] torrent_hash)
{
EnhancedDownloadManager dm = dme.getEnhancedDownload( torrent_hash );
if ( dm == null ){
return( true );
}
if ( dm.isPlatform()){
return( canBan( ip ));
}
return( true );
}
});
new AEThread( "CacheDiscovery:ban checker", true )
{
public void
runSupport()
{
BannedIp[] bans = ip_filter.getBannedIps();
for (int i=0;i<bans.length;i++){
String ip = bans[i].getIp();
if ( !canBan( ip )){
ip_filter.unban( ip );
}
}
}
}.start();
|
public static CachePeer[] | lookup(org.gudy.azureus2.core3.torrent.TOTorrent torrent)
CachePeer[] res;
if ( discoverers.length == 1 ){
res = discoverers[0].lookup( torrent );
}else{
List result = new ArrayList();
for (int i=0;i<discoverers.length;i++){
CachePeer[] peers = discoverers[i].lookup( torrent );
for (int j=0;j<peers.length;j++){
result.add( peers[i] );
}
}
res = (CachePeer[])result.toArray( new CachePeer[result.size()]);
}
for (int i=0;i<res.length;i++){
String ip = res[i].getAddress().getHostAddress();
cache_ips.add( ip );
ip_filter.unban( ip );
}
return( res );
|