def retrieve(self):
        """
        Start retrieving the metainfo

        Returns True when attempting to obtain the metainfo, in this
        case CALLBACK will always be called.  Otherwise False is
        returned, in this case CALLBACK will not be called.
        """
        if self._info_hash:
            # todo: catch the result from get_peers and call its stop
            # method.  note that this object does not yet contain a
            # stop method...
            dht = mainlineDHT.dht
            dht.get_peers(self._info_hash, Id(self._info_hash), self.potential_peers_from_dht, 0)

            try:
                if self._trackers and any(tracker.startswith("http") for tracker in self._trackers):
                    MiniTracker(self._swarm, self._trackers)
            except:
                print_exc()

            return True
        else:
            print >> sys.stderr, "No Infohash"
            return False
Example #2
0
 def dht_lookup(self, info_hash, cb):
     if self.trsession:
         self.trsession.lm.mainline_dht.get_peers(info_hash, Id(info_hash),
                                                  cb)
     else:
         self.tunnel_logger.error(
             "Need a Tribler session to lookup to the DHT")
Example #3
0
    def announce(self, info_hash):
        def cb(info_hash, peers, source):
            self.logger.info("Announced %s to the DHT",
                             info_hash.encode('hex'))

        self.mainline_dht.get_peers(info_hash,
                                    Id(info_hash),
                                    cb,
                                    bt_port=self.bt_port)
    def dht_announce(self, info_hash):
        if self.tribler_session:
            def cb(info_hash, peers, source):
                self.tunnel_logger.info("Announced %s to the DHT", info_hash.encode('hex'))

            port = self.tribler_session.config.get_dispersy_port()
            self.tribler_session.lm.mainline_dht.get_peers(info_hash, Id(info_hash), cb, bt_port=port)
        else:
            self.tunnel_logger.error("Need a Tribler session to announce to the DHT")
Example #5
0
        def dht_announce(info_hash, community):
            def cb_dht(info_hash, peers, source):
                self._logger.debug("announced %s to the DHT",
                                   info_hash.encode('hex'))
                self.dht_deferred.callback(None)

            port = community.trsession.get_dispersy_port()
            community.trsession.lm.mainline_dht.get_peers(info_hash,
                                                          Id(info_hash),
                                                          cb_dht,
                                                          bt_port=port)
Example #6
0
    def lookup(self,infohash):
        if DEBUG:
            print >>sys.stderr,"mainlineDHTChecker: Lookup",`infohash`

        if self.dht is not None:
            from Tribler.Core.DecentralizedTracking.pymdht.core.identifier import Id, IdError
            try:
                infohash_id = Id(infohash)
                self.dht.get_peers(infohash, infohash_id, self.got_peers_callback)
            except (IdError):
                print >>sys.stderr,"Rerequester: _dht_rerequest: self.info_hash is not a valid identifier"
                return
        elif DEBUG:
            print >>sys.stderr,"mainlineDHTChecker: No lookup, no DHT support loaded"
    def _dht_rerequest(self):
        if DEBUG_DHT:
            print >> sys.stderr, "Rerequester: _dht_rerequest", ` self.infohash `
        try:
            info_hash_id = Id(self.infohash)
        except (IdError):
            print >> sys.stderr, "Rerequester: _dht_rerequest: self.info_hash is not a valid identifier"
            return

        if 'dialback' in self.config and self.config['dialback']:
            # Niels: at startup we are always not connectable, changed behaviour into always announce,
            # sorry raul...

            #raul: I added this return so when the peer is NOT connectable
            # it does a get_peers lookup but it does not announce
            if DEBUG_DHT:
                print >> sys.stderr, "Rerequester: _dht_rerequest: get_peers AND announce"
            self.dht.get_peers(self.infohash, info_hash_id,
                               self._dht_got_peers, self.port)
            return

        if DEBUG_DHT:
            print >> sys.stderr, "Rerequester: _dht_rerequest: JUST get_peers, DO NOT announce"
        self.dht.get_peers(self.infohash, info_hash_id, self._dht_got_peers)
Example #8
0
 def lookup(self, info_hash, cb):
     self.mainline_dht.get_peers(info_hash, Id(info_hash), cb)