次のコードを使用して新しいトレットを作成して共有していますが、シードしないため何か問題があります。
import sys
import time
import libtorrent as lt
#Create torrent
fs = lt.file_storage()
lt.add_files(fs, "./test.txt")
t = lt.create_torrent(fs)
t.add_tracker("udp://tracker.openbittorrent.com:80/announce", 0)
t.set_creator('libtorrent %s' % lt.version)
t.set_comment("Test")
lt.set_piece_hashes(t, ".")
torrent = t.generate()
f = open("mytorrent.torrent", "wb")
f.write(lt.bencode(torrent))
f.close()
#Seed torrent
ses = lt.session()
ses.listen_on(6881, 6891)
h = ses.add_torrent({'ti': lt.torrent_info('mytorrent.torrent'), 'save_path': '.', 'seed_mode': True})
print "Total size: " + str(h.status().total_wanted)
print "Name: " + h.name()
while True:
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)
順番にテスト:
- スクリプトを実行します
- mytorrent.torrent が正しく作成されました
- 「Total size:」と「Name:」を印刷してOK
- 順番に印刷をループします。
100.00% 完了 (ダウン: 0.0 kb/s アップ: 0.0 kB/s ピア: 0) シード (8 回)
100.00% 完了 (ダウン: 0.0 kb/s アップ: 0.0 kB/s ピア: 1) シード (11 回) (トレント クライアントを実行していなくても、これは常に発生します。)
100.00% 完了 (ダウン: 0.0 kb/s アップ: 0.0 kB/s ピア: 0) シード (無限回)
- トレント クライアントでトレント ファイルを実行しましたが、何も起こりません。
- 上記のように商用ソフトで torrent をダウンロードしてみる以外に、 libtorrent ライブラリでもダウンロードしてみました。常に 0 ピアを表示します。
同じ結果のテストのバリエーション:
私は別のトラッカーを使用しようとしました:
trackerList = ['udp://tracker.istole.it:80/announce', 'udp://tracker.ccc.de:80/announce', 'http://tracker.torrentbay.to:6969/announce', 'udp://fr33domtracker.h33t.com:3310/announce', 'udp://tracker.publicbt.com:80/announce', 'udp://tracker.openbittorrent.com:80/announce', 'udp://11.rarbg.com/announce' 'udp://tracker.istole.it:80/announce'] for tracker in trackerList: t.add_tracker(tracker, 0)
スクリプトを実行した直後と後でクライアントで torrent ファイルを実行しました。
- lt.torrent_info('mytorrent.torrent') は lt.torrent_info(torrent) に置き換えられました
追加情報:
- テストのために、それぞれが異なるネットワークに接続された 2 台の Windows コンピュータを使用しています。各ネットワークで、必要なポートが開いています。
- 各テストの実行時間は、少なくとも 1:20 時間です。
その他のテスト:
以前共有していたコンピューターで、他の人が作成した torrent を共有しようとしました。「#Seed torrent」でマークされたコードを実行しました。
100.00% 完了 (ダウン: 2.0 kB/秒 アップ: 45.0 kB/秒 ピア: 13) シード
トレントをダウンロードするために使用するコンピューターで、他の誰かによって既に作成されたトレント (libtorrent を使用) をダウンロードしましたが、正しく動作しました。
したがって、「#create torrent」コードに問題があるとしか思えません。あたかもトラッカーが情報セットを保存しないかのように。