Package org.gudy.azureus2.plugins.peers

Examples of org.gudy.azureus2.plugins.peers.Peer


      Peer[] peers = pm.getPeers();
     
      for (int i=0;i<peers.length;i++){
       
        Peer  peer = peers[i];
       
        unmarkBuddyPeer( peer );
      }
    }
  }
View Full Code Here


                    long  total_sent    = 0;
                    long  total_received  = 0;
                   
                    while( it.hasNext()){
                     
                      Peer  p = (Peer)it.next();
                     
                      PeerStats ps = p.getStats();
                     
                      long sent    = ps.getTotalSent();
                      long received   = ps.getTotalReceived();
                     
                      long[]  last = (long[])p.getUserData( PEER_STATS_KEY );
                     
                      if ( last != null ){
                       
                        total_sent     += sent - last[0];
                        total_received  += received - last[1];
                      }
                     
                      p.setUserData( PEER_STATS_KEY, new long[]{ sent, received });
                    }
                   
                    buddy_receive_speed.addValue( total_received );
                    buddy_send_speed.addValue( total_sent );
                  }
View Full Code Here

      Iterator  it = buddy_peers.iterator();
     
      while( it.hasNext()){
       
        Peer  peer = (Peer)it.next();
       
        if ( peer.getState() == Peer.CLOSING || peer.getState() == Peer.DISCONNECTED ){
         
          to_unmark.add( peer );
        }
      }
    }
View Full Code Here

                 
                  Peer[]  dl_peers = pm.getPeers();
                 
                  for (int i=0;i<dl_peers.length;i++){
                   
                    Peer  dl_peer = dl_peers[i];
                   
                    if ( dl_peer.getPercentDoneInThousandNotation() == 1000 ){
                     
                      local_seeds++;
                     
                    }else{
                      local_leechers++;
View Full Code Here

           
            Peer[]   peers = pm.getPeers();
           
            for (int j=0;j<peers.length;j++){
             
              Peer  p = peers[j];
             
              int  peer_udp_port = p.getUDPNonDataListenPort();
             
              if ( peer_udp_port != 0 ){
                           
                if ( importSeed( p.getIp(), peer_udp_port ) != null ){
                 
                  peers_imported++;
                               
                  if ( peers_imported > seed_limit ){
                   
View Full Code Here

                     
                      Peer[] peers = pm.getPeers();
                     
                      for ( int i=0;i<peers.length;i++){
                       
                        Peer peer = peers[i];
                       
                          // use the IP as the key so we don't count reconnects multiple times
                       
                        String  key = peer.getIp();
                       
                        connected_peers.add( key );
                       
                        if ( !peer.isChoked()){
                         
                          not_choked_peers.add( key );
                        }
                       
                        if ( !peer.isChoking()){
                         
                          not_choking_peers.add( key );
                        }
                      }
                    }
View Full Code Here

           
            final List  to_check = new ArrayList();
           
            for (int i=0;i<peers.length;i++){
             
              Peer  peer = peers[i];
             
              byte[]  peer_key = getKey( peer );
             
              if ( peer_key != null ){
               
View Full Code Here

       
        String  peer_str = "";
       
        for (int i=0;i<peers.size() && i < MAX_PEERS_PER_QUERY; i++ ){
         
          Peer  peer = (Peer)peers.get(i);
         
          List  peer_data = new ArrayList();
         
          peer_data.add( download.getTorrent().getHash());
          peer_data.add( peer.getId());
          peer_data.add( peer.getIp());
         
          map.put( "peer" + i, peer_data );
         
          peer_str += (i==0?"":",") + peer.getIp();
        }

        log( "Checking " + url_str + " : peers=" + peer_str );
       

        byte[]  encoded = BEncoder.encode( map, true );       

        HttpURLConnection connection = (HttpURLConnection)target.openConnection();
       
          String data = "authpeers=" + new String(encoded, "ISO-8859-1" );
         
          System.out.println( "sending '" + data + "'" );
         
          connection.setDoOutput(true);
         
          connection.setRequestMethod("POST");
         
          connection.setRequestProperty("User-Agent", Constants.AZUREUS_NAME + " " + Constants.AZUREUS_VERSION);    
         
          connection.setRequestProperty( "Connection", "close" );

          connection.addRequestProperty( "Accept-Encoding", "gzip" );

          out = new OutputStreamWriter(connection.getOutputStream());
         
          out.write(data);
         
          out.flush();
         
          in = new BufferedInputStream(connection.getInputStream());

          Map  result_map = BDecoder.decode( in );
         
        for (int i=0;i<peers.size() && i < MAX_PEERS_PER_QUERY; i++ ){

          Peer  peer = (Peer)peers.get(i);

          Long  enabled = (Long)result_map.get( "peer" + i );
         
          if ( enabled == null ){
           
            log( "No response for peer '" + peer.getIp() + "'" );
           
          }else{
           
            boolean  ok = enabled.longValue() != 0;
           
            recordPeer( "auth check", peer.getId(), peer.getIp(), peer.getPort(), ok );
       
            if ( !ok ){
             
              removePeer( peer );
            }
View Full Code Here

       
        return( null );
       
      }
     
      Torrent  torrent = download.getTorrent();
     
      if ( torrent.isPrivate()){
       
        Debug.out( "Attempt to download private torrent" );
       
        ddb.log( "TorrentDownload: request from " + originator + "  for '" + download.getName() + "' denied as it is private" );
       
          // should never happen as private torrents are not tracked so they can't be found for
          // download
       
        return( null );
      }
     
      String  msg = "TorrentDownload: request from " + originator + "  for '" + download.getName() + "' OK";   

      if ( TRACE ){
       
        System.out.println( msg );
      }
     
      ddb.log( msg );
     
      HashWrapper  hw = new HashWrapper( torrent.getHash());
     
      synchronized( data_cache ){
       
        Object[]  data = (Object[])data_cache.get( hw );
       
        if ( data != null ){
                   
          data[1] = new Long( SystemTime.getCurrentTime());
         
          return( ddb.createValue((byte[])data[0]));
        }
      }
     
     
      torrent = torrent.removeAdditionalProperties();
     
        // when clients get a torrent from the DHT they take on
        // responsibility for tracking it too
     
      torrent.setDecentralisedBackupRequested( true );
     
      byte[] data = torrent.writeToBEncodedData();
             
      data = encrypt( torrent.getHash(), data );
       
      if ( data == null ){
         
        return( null );
      }
View Full Code Here

      for (int i=0; i < items.size(); i++){       
      
      ShareItem  item = (ShareItem)items.get(i);
       
        try{
        Torrent  t = item.getTorrent();
                  
        Download  download = dm.getDownload( t );
       
        if ( download == null ){
                   
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.plugins.peers.Peer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.