Package org.gudy.azureus2.plugins.download

Examples of org.gudy.azureus2.plugins.download.DownloadAnnounceResultPeer


  protected void
  showDHTStats(
    ConsoleInput  ci )
  {
    try{
      PluginInterface  def = ci.azureus_core.getPluginManager().getDefaultPluginInterface();
     
      PluginInterface dht_pi =
        def.getPluginManager().getPluginInterfaceByClass(DHTPlugin.class );
     
      if ( dht_pi == null ){
     
        ci.out.println( "\tDHT isn't present" );
       
        return;
      }
     
      DHTPlugin  dht_plugin = (DHTPlugin)dht_pi.getPlugin();
     
      if ( dht_plugin.getStatus() != DHTPlugin.STATUS_RUNNING ){
       
        ci.out.println( "\tDHT isn't running yet (disabled or initialising)" );
       
View Full Code Here


    // Proably need to wait for core to be running to make sure dht plugin is fully avail
    AzureusCoreFactory.addCoreRunningListener(new AzureusCoreRunningListener() {
      public void azureusCoreRunning(AzureusCore core) {
        PluginManager pm = core.getPluginManager();
        connection_manager = PluginInitializer.getDefaultInterface().getConnectionManager();
        PluginInterface dht_pi = pm.getPluginInterfaceByClass(DHTPlugin.class);
        if (dht_pi != null) {
          dhtPlugin = (DHTPlugin) dht_pi.getPlugin();
        }
      }
    });
  }
View Full Code Here

                  }else{
                   
                    torrent.setAdditionalListProperty( "httpseeds", webseeds );
                  }
     
                  PluginInterface pi = AzureusCoreFactory.getSingleton().getPluginManager().getPluginInterfaceByClass(ExternalSeedPlugin.class);
                 
                  if ( pi != null ){
                   
                    ExternalSeedPlugin ext_seed_plugin = (ExternalSeedPlugin)pi.getPlugin();
                   
                    ext_seed_plugin.downloadChanged( PluginCoreUtils.wrap( dms[0] ));
                  }
           
                }catch (Throwable e){
View Full Code Here

  public MainStatusBar() {
    numberFormat = NumberFormat.getInstance();
    // Proably need to wait for core to be running to make sure dht plugin is fully avail
    AzureusCoreFactory.addCoreRunningListener(new AzureusCoreRunningListener() {
      public void azureusCoreRunning(AzureusCore core) {
        PluginManager pm = core.getPluginManager();
        connection_manager = PluginInitializer.getDefaultInterface().getConnectionManager();
        PluginInterface dht_pi = pm.getPluginInterfaceByClass(DHTPlugin.class);
        if (dht_pi != null) {
          dhtPlugin = (DHTPlugin) dht_pi.getPlugin();
        }
      }
    });
View Full Code Here

      // prevents someone without the hash from downloading the torrent
   
    try{
      byte[]  search_key = ((DDBaseKeyImpl)key).getBytes();
     
      Download   download = null;
       
      PluginInterface pi = PluginInitializer.getDefaultInterface();
                 
      String  search_sha1 = pi.getUtilities().getFormatters().encodeBytesToString( search_key );
     
      if ( ta_sha1 == null ){
       
        ta_sha1 = pi.getTorrentManager().getPluginAttribute( "DDBaseTTTorrent::sha1");
      }
       
        // gotta look for the sha1(hash)
     
      Download[]  downloads = pi.getDownloadManager().getDownloads();
     
      for (int i=0;i<downloads.length;i++){
       
        Download  dl = downloads[i];
       
        if ( dl.getTorrent() == null ){
         
          continue;
        }
       
        String  sha1 = dl.getAttribute( ta_sha1 );
       
        if ( sha1 == null ){
         
          sha1 = pi.getUtilities().getFormatters().encodeBytesToString(
                new SHA1Simple().calculateHash( dl.getTorrent().getHash()));
         
          dl.setAttribute( ta_sha1, sha1 );
        }
       
        if ( sha1.equals( search_sha1 )){
         
          download  = dl;
                   
          break;
        }
      }
       
      if ( download == null ){
       
        synchronized( this ){
         
          if ( external_downloads != null ){
           
            for (int i=0;i<external_downloads.size();i++){
             
              Download  dl = (Download)external_downloads.get(i);
             
              if ( dl.getTorrent() == null ){
               
                continue;
              }
             
              String  sha1 = dl.getAttribute( ta_sha1 );
             
              if ( sha1 == null ){
               
                sha1 = pi.getUtilities().getFormatters().encodeBytesToString(
                      new SHA1Simple().calculateHash( dl.getTorrent().getHash()));
               
                dl.setAttribute( ta_sha1, sha1 );
              }
             
              if ( sha1.equals( search_sha1 )){
               
                download  = dl;
View Full Code Here

      ShareItem  item = (ShareItem)items.get(i);
       
        try{
        Torrent  t = item.getTorrent();
                  
        Download  download = dm.getDownload( t );
       
        if ( download == null ){
                   
          continue;
        }
       
        int  dl_state = download.getState();
       
        if (   dl_state == Download.ST_ERROR ){
         
        }else if ( dl_state != Download.ST_STOPPED ){
         
View Full Code Here

          try{
            Torrent  t = item.getTorrent();
           
            TrackerTorrent  tracker_torrent = tracker.getTorrent( t );
           
            Download  download = dm.getDownload( t );
           
            if ( tracker_torrent == null || download == null ){
                             
              continue;
            }
           
            int  dl_state = download.getState();
           
            if (   dl_state == Download.ST_ERROR ){
             
            }else if ( dl_state != Download.ST_STOPPED ){
             
              if ( do_stop ){
               
                try{
                  download.stop();
                }catch( Throwable e ){
                }
               
                try{
                  tracker_torrent.stop();
                }catch( Throwable e ){
                }
              }
             
            }else{
             
              if ( !do_stop ){
               
                try{
                  download.restart();
                }catch( Throwable e ){
                }
               
                try{
                  tracker_torrent.start();
View Full Code Here

     
      TRTrackerAnnouncerResponsePeerImpl[] peers = new TRTrackerAnnouncerResponsePeerImpl[ext_peers.length];
       
      for (int i=0;i<ext_peers.length;i++){
       
        DownloadAnnounceResultPeer  ext_peer  = ext_peers[i];
       
        if (Logger.isEnabled())
          Logger.log(new LogEvent(torrent, LOGID, "EXTERNAL PEER DHT: ip="
              + ext_peer.getAddress() + ",port=" + ext_peer.getPort() +",prot=" + ext_peer.getProtocol()));

        int    http_port  = 0;
        byte  az_version   = TRTrackerAnnouncer.AZ_TRACKER_VERSION_1;
       
        peers[i] = new TRTrackerAnnouncerResponsePeerImpl(
                  ext_peer.getSource(),
                  ext_peer.getPeerID(),
                  ext_peer.getAddress(),
                  ext_peer.getPort(),
                  ext_peer.getUDPPort(),
                  http_port,
                  ext_peer.getProtocol(),
                  az_version,
                  (short)0 );
      }
     
      helper.addToTrackerCache( peers);
View Full Code Here

      boolean ps_enabled =   announce_data_provider != null &&
                  announce_data_provider.isPeerSourceEnabled( PEPeerSource.PS_BT_TRACKER );
           
      for (int i=0;i<ext_peers.length;i++){
       
        DownloadAnnounceResultPeer  ext_peer = ext_peers[i];
       
        String  ps = ext_peer.getSource();
       
          // filter out any disabled peers
       
        if ( !ps_enabled && ps.equals( PEPeerSource.PS_BT_TRACKER )){
                   
          continue;
         
        }else{
         
          int    http_port  = 0;
          byte  az_version   = TRTrackerAnnouncer.AZ_TRACKER_VERSION_1;
         
          TRTrackerAnnouncerResponsePeerImpl p =
            new TRTrackerAnnouncerResponsePeerImpl(
                  ext_peer.getSource(),
                  ext_peer.getPeerID(),
                  ext_peer.getAddress(),
                  ext_peer.getPort(),
                  ext_peer.getUDPPort(),
                  http_port,
                  ext_peer.getProtocol(),
                  az_version,
                  (short)0 );
         
          l_peers.add( p );
       
View Full Code Here

                }
               
                final int f_i = i;
               
                peers_for_announce.add(
                  new DownloadAnnounceResultPeer()
                  {
                    public String
                    getSource()
                    {
                      return( PEPeerSource.PS_DHT );
                    }
                   
                    public String
                    getAddress()
                    {
                      return((String)addresses.get(f_i));
                    }
                   
                    public int
                    getPort()
                    {
                      return(((Integer)ports.get(f_i)).intValue());
                    }
                   
                    public int
                    getUDPPort()
                    {
                      return(((Integer)udp_ports.get(f_i)).intValue());
                    }
                   
                    public byte[]
                    getPeerID()
                    {
                      return( null );
                    }
                   
                    public short
                    getProtocol()
                    {
                      String  flag = (String)flags.get(f_i);
                     
                      short protocol;
                     
                      if ( flag != null && flag.indexOf("C") != -1 ){
                       
                        protocol = PROTOCOL_CRYPT;
                       
                      }else{
                       
                        protocol = PROTOCOL_NORMAL;
                      }
                     
                      return( protocol );
                    }
                  });
               
              }
               
              if ( target.getType() == REG_TYPE_DERIVED && peers_for_announce.size() > 0 ){
               
                PeerManager pm = download.getPeerManager();
               
                if ( pm != null ){
                   
                    // try some limited direct injection
                 
                  List<DownloadAnnounceResultPeer>  temp = new ArrayList<DownloadAnnounceResultPeer>( peers_for_announce );
                 
                  Random rand = new Random();
                 
                  for (int i=0;i<DIRECT_INJECT_PEER_MAX && temp.size() > 0; i++ ){
                   
                    DownloadAnnounceResultPeer peer = temp.remove( rand.nextInt( temp.size()));
                   
                    log( download, "Injecting derived peer " + peer.getAddress() + " into " + download.getName());
                   
                    Map<Object,Object>  user_data = new HashMap<Object,Object>();
                                       
                    user_data.put( Peer.PR_PRIORITY_CONNECTION, new Boolean( true ));

                    pm.addPeer(
                        peer.getAddress(),
                        peer.getPort(),
                        peer.getUDPPort(),
                        peer.getProtocol() == DownloadAnnounceResultPeer.PROTOCOL_CRYPT,
                        user_data );
                  }
                }
              }
             
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.plugins.download.DownloadAnnounceResultPeer

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.