Ejemplo n.º 1
0
    def __init__(self):
        self.torrent = torrent.Torrent().load_from_path("torrent.torrent")
        self.tracker = tracker.Tracker(self.torrent)

        self.pieces_manager = pieces_manager.PiecesManager(self.torrent)
        self.peers_manager = peers_manager.PeersManager(self.torrent, self.pieces_manager)

        self.peers_manager.start()
        logging.info("PeersManager Started")
        logging.info("PiecesManager Started")
Ejemplo n.º 2
0
    def __init__(self):
        movie = ''
        self.torrent = torrent.Torrent().open_from_file(movie)
        self.tracker = tracker.Tracker(self.torrent)

        self.pieces_manager = pieces_manager.PiecesManager(self.torrent)
        self.peers_manager = peers_manager.PeersManager(
            self.torrent, self.pieces_manager)

        self.peers_manager.start()
        logging.info("PeersManager Started")
        logging.info("PiecesManager Started")
Ejemplo n.º 3
0
    def __init__(self):
        if len(sys.argv) <= 2 and len(sys.argv) > 1:
            self.torrent = torrent.Torrent().load_from_path(sys.argv[1])
        else:
            print("Usage : python3 main.py <path_to_torrent_file> \n")
            sys.exit(1)

        self.tracker = tracker.Tracker(self.torrent)

        self.pieces_manager = pieces_manager.PiecesManager(self.torrent)
        self.peers_manager = peers_manager.PeersManager(
            self.torrent, self.pieces_manager)

        self.peers_manager.start()
        logging.info("PeersManager Started")
        logging.info("PiecesManager Started")
Ejemplo n.º 4
0
Archivo: main.py Proyecto: GurovNik/tor
import time
import peers_manager
import pieces_manager
import torrent
import tracker
import os
import message

torrent = torrent.Torrent().load_from_path("sintel.torrent")
tracker = tracker.Tracker(torrent)
pieces_manager = pieces_manager.PiecesManager(torrent)
peers_manager = peers_manager.PeersManager(torrent, pieces_manager)
peers_manager.start()

peers_dict = tracker.get_peers_from_trackers()
peers_manager.add_peers(peers_dict.values())

while not pieces_manager.all_pieces_completed():
    if not peers_manager.has_unchoked_peers():
        time.sleep(1)
        continue

    for piece in pieces_manager.pieces:
        index = piece.piece_index

        if pieces_manager.pieces[index].is_full:
            continue

        peer = peers_manager.get_random_peer_having_piece(index)
        if not peer:
            continue