addPeersFromTracker(
TRTrackerAnnouncerResponsePeer[] peers )
{
for (int i = 0; i < peers.length; i++){
final TRTrackerAnnouncerResponsePeer peer = peers[i];
final ArrayList peer_transports = peer_transports_cow;
boolean already_connected = false;
for( int x=0; x < peer_transports.size(); x++ ) {
final PEPeerTransport transport = (PEPeerTransport)peer_transports.get( x );
// allow loopback connects for co-located proxy-based connections and testing
if( peer.getAddress().equals( transport.getIp() )){
final boolean same_allowed = COConfigurationManager.getBooleanParameter( "Allow Same IP Peers" ) ||
transport.getIp().equals( "127.0.0.1" );
if( !same_allowed || peer.getPort() == transport.getPort() ) {
already_connected = true;
break;
}
}
}
if( already_connected ) continue;
if( peer_database != null ){
byte type = peer.getProtocol() == DownloadAnnounceResultPeer.PROTOCOL_CRYPT ? PeerItemFactory.HANDSHAKE_TYPE_CRYPTO : PeerItemFactory.HANDSHAKE_TYPE_PLAIN;
byte crypto_level = peer.getAZVersion() < TRTrackerAnnouncer.AZ_TRACKER_VERSION_3?PeerItemFactory.CRYPTO_LEVEL_1:PeerItemFactory.CRYPTO_LEVEL_2;
PeerItem item = PeerItemFactory.createPeerItem(
peer.getAddress(),
peer.getPort(),
PeerItem.convertSourceID( peer.getSource() ),
type,
peer.getUDPPort(),
crypto_level,
peer.getUploadSpeed());
peerDiscovered( null, item );
peer_database.addDiscoveredPeer( item );
}
int http_port = peer.getHTTPPort();
if ( http_port != 0 && !seeding_mode ){
adapter.addHTTPSeed( peer.getAddress(), http_port );
}
}
}