我有大文件移动到很多服务器.现在我们使用rsync,但我想尝试使用bittorent.
我正在研究Deluge的代码,这是一个Python bittorent客户端,但它使用扭曲并且非常复杂.你知道什么高水平吗?
编辑:我刚刚看到Facebook使用Bittorent进行代码部署.也许他们为此发布了他们的lib,但我找不到它.听说过吗?
我绝对推荐libtorrent-rasterbar.它是一个带有Python绑定的C++库.同样为Deluge,Transmission,Miro和许多其他bittorrent客户提供动力.
与其他libtorrent(属于rTorrent项目的一部分)相比,这个正在积极开发并支持所有现代协议扩展,如DHT,元数据传输甚至一些专有的uTorrent扩展,如对等交换(PEX).
API有很好的文档记录.
从下面的全功能简单客户端示例中可以看出,您不需要了解底层协议的每一部分(当然,当您这样做时,它会有很多帮助):
#!/bin/python
# Copyright Arvid Norberg 2008. Use, modification and distribution is
# subject to the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
import libtorrent as lt
import time
import sys
ses = lt.session()
ses.listen_on(6881, 6891)
info = lt.torrent_info(sys.argv[1])
h = ses.add_torrent({'ti': info, 'save_path': './'})
print 'starting', h.name()
while (not h.is_seed()):
s = h.status()
state_str = ['queued', 'checking', 'downloading metadata', 'downloading', \
'finished', 'seeding', 'allocating', 'checking fastresume']
print '\r%.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d) %s' % \
(s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, \
s.num_peers, state_str[s.state]),
sys.stdout.flush()
time.sleep(1)
print h.name(), 'complete'
Run Code Online (Sandbox Code Playgroud)
PS Facebook在http://developers.facebook.com/opensource/上有一个专门用于开源项目的页面.没有列出的bittorrent实现.