首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何与蟒蛇结籽?

如何与蟒蛇结籽?
EN

Stack Overflow用户
提问于 2019-09-11 19:43:04
回答 1查看 1.1K关注 0票数 0

我有Ubuntu服务器与libtorrent,和本地pc Win10与uTorrent。

On Server I want create 1.torrent and start seeding it on server

On PC I want load 1.torrent to uTorrent and download it using DHT

我创建了脚本:creation1.torrent文件,并将其添加到DHT中。

代码语言:javascript
复制
import libtorrent as lt
import sys, time


videoFile = "/tmp/1/1.mp4.gpg"
workingPath = "/tmp/1"

#Create torrent

f = lt.file_storage()
lt.add_files(f, videoFile)
t = lt.create_torrent(f)
t.add_node("router.utorrent.com", 6881)
t.add_node("dht.transmissionbt.com", 6881)
lt.set_piece_hashes(t, workingPath)
torrent = t.generate()
f = open("/tmp/1/1.torrent", "wb")
f.write(lt.bencode(torrent))
f.close()

#Seeding

PORT_RANGE = (6881,6891)
s = lt.session()
s.listen_on(PORT_RANGE[0],PORT_RANGE[1])
s.add_dht_router('router.utorrent.com',6881)
s.start_dht()
print "DHT start: ", s.is_dht_running()
print "DHT state: ", s.dht_state()


params = {
            'save_path': workingPath,
            'storage_mode': lt.storage_mode_t.storage_mode_sparse,
            'ti': lt.torrent_info(torrent),
            'seed_mode': True,
            'paused': False,
            'upload_mode':True,
            'super_seeding':True
        }
h = s.add_torrent(params)
print("Total size: " + str(h.status().total_wanted))
print("Name: " + h.name())
while True:
    s = h.status()
    msg = '\r%.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d) %s'
    print(msg % (s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, s.num_peers, s.state))
    sys.stdout.flush()
    time.sleep(1)

输出量

代码语言:javascript
复制
# python 1.py
DHT start:  True
DHT state:  {'node-id': 'HgH\xcd\xe3\xbc\x9b\xa9\x9b\xf6\xbf\xe7E\xd9\x1d.\xd9<\x838'}
Total size: 82500767
Name: 1.mp4.gpg
100.00% complete (down: 0.0 kb/s up: 0.0 kB/s peers: 0) seeding
0.00% complete (down: 0.0 kb/s up: 0.0 kB/s peers: 0) checking_resume_data
0.00% complete (down: 0.0 kb/s up: 0.0 kB/s peers: 0) checking_resume_data
0.00% complete (down: 0.0 kb/s up: 0.0 kB/s peers: 0) checking_resume_data
....
....
....
0.00% complete (down: 0.0 kb/s up: 0.0 kB/s peers: 0) checking_resume_data

windows pc上的Utorrent状态正在“连接到对等端”

为什么我不能在山洪中播种?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-09-13 18:44:59

您正在将seed_mode设置为True。这将使libtorrent假设您拥有该流的所有文件,因此状态为“种子”。

一旦您得到一个对等程序,并且它请求了一个块,libtorrent实际上就会打开该文件,并且它实际上也会验证段散列(以避免上传损坏的数据)。但是,如果文件不存在,洪流将转换为检查模式,在这种模式下,它不能再信任它正在播种。它会检查所有的文件。

检查这些文件的第一步是检查简历数据(您可以转换到这些数据)。然而,这通常是非常快的,然后是转换为检查-文件状态。

这似乎并不是因为某种原因。为了解决拍摄问题,您应该使用pop_alerts()并将它们打印到日志中,并可能启用更多的警报,比如torrent_log警报。

但是,您遇到的第一个问题似乎是您没有要种子的文件。但是,如果没有警报日志,就很难诊断这一点。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57895821

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档