def test_udp(self): torrent = Torrent('torrents/archlinux-2013.12.01-dual.iso.torrent') tracker = Tracker('udp://tracker.openbittorrent.com:80/announce', torrent) response = yield tracker.announce(utils.peer_id(), 6881) self.assertIsInstance(response, TrackerResponse)
def test_http(self): torrent = Torrent('torrents/archlinux-2013.12.01-dual.iso.torrent') tracker = Tracker('http://tracker.archlinux.org:6969/announce', torrent) response = yield tracker.announce(utils.peer_id(), 6881) self.assertIsInstance(response, TrackerResponse)
def __init__(self, torrent, max_peers=50, download_path='downloads', peer_id=peer_id(), storage_class=DiskStorage): TCPServer.__init__(self) self.peer_id = peer_id self.torrent = torrent self.max_peers = max_peers self.connected_peers = set() self.connecting_peers = set() self.unconnected_peers = set() self.storage = storage_class.from_torrent(torrent, base_path=download_path)
def __init__(self, torrent, max_peers=50, download_path='downloads', peer_id=peer_id(), storage_class=DiskStorage): TCPServer.__init__(self) self.peer_id = peer_id self.torrent = torrent self.max_peers = max_peers self.connected_peers = set() self.connecting_peers = set() self.unconnected_peers = set() self.storage = storage_class.from_torrent(torrent, base_path=download_path)
if __name__ == '__main__': parse_command_line() enable_pretty_logging() if not options.torrent: logging.error('Required argument <torrent> not provided') print print_help() sys.exit(1) torrent = Torrent(options.torrent) server = Server( torrent=torrent, download_path=options.path, storage_class=DiskStorage, peer_id=peer_id(), max_peers=options.max_peers ) server.listen(options.port) server.start() if options.peer_ip and options.peer_port: server.connect(Peer(options.peer_ip, options.peer_port)) IOLoop.instance().start()