[关闭]
@zhongdao 2020-08-24T20:29:43.000000Z 字数 4664 阅读 1520

bittorrent 客户端 rain

未分类


前言

概念与常识

How to generate a Torrent Magnet URI from a directory?
https://stackoverflow.com/questions/30294387/how-to-generate-a-torrent-magnet-uri-from-a-directory

There's no method exposed to create a magnet URI directly because such a link would be unusable!

Magnet links are hash identifiers that allow clients to retrieve a torrent file from the BitTorrent DHT network. However, they can only do so if there's at least one other client online (and with DHT enabled) that's downloading or seeding that torrent. If you generated a torrent within your application and generated a magnet link from that directly, nobody would ever have that torrent file, so it wouldn't be downloadable.

Long story short: Magnet links only really work for torrents that are created and seeded on a peer-to-peer basis. If you want to use a web seed, you'll need to offer the full torrent file for download by users.

What is “web seed”?
https://askubuntu.com/questions/313107/what-is-web-seed#:~:text=%5BWeb%20Seeds%20are%20the%5D%20location,contents%2C%20or%20existing%20web%20locations.

magnet协议

The purpose of this extension is to allow clients to join a swarm and complete a download without the need of downloading a .torrent file first. This extension instead allows clients to download the metadata from peers. It makes it possible to support magnet links, a link on a web page only containing enough information to join the swarm (the info hash).

magnet URI format
The magnet URI format is:

  1. v1: magnet:?xt=urn:btih:<info-hash>&dn=<name>&tr=<tracker-url>&x.pe=<peer-address>
  2. v2: magnet:?xt=urn:btmh:<tagged-info-hash>&dn=<name>&tr=<tracker-url>&x.pe=<peer-address>
  3. <peer-address>
  4. A peer address expressed as hostname:port, ipv4-literal:port or [ipv6-literal]:port. This parameter can be included to initiate a direct metadata transfer between two clients while reducing the need for external peer sources. It should only be included if the client can discover its public IP address and determine its reachability. Note: Since no URI scheme identifier has been allocated for bittorrent xs= is not used for this purpose.
  5. **If no tracker is specified, the client SHOULD use the DHT (BEP 0005) to acquire peers.**

webseed 协议

Abstract
Using HTTP or FTP servers as seeds for BitTorrent downloads.

Rationale
Many websites that list a BitTorrent download also provide a HTTP or FTP URL for the same file. The files are identical. A WebSeeding BitTorrent client can download from either source, putting all the parts together into one complete file.

The HTTP or FTP server acts as a permanently unchoked seed.

使用命令

rain torrent create

  1. rain torrent create
  2. NAME:
  3. rain torrent create - create new torrent file
  4. USAGE:
  5. rain torrent create [command options] [arguments...]
  6. OPTIONS:
  7. --file value, -f value include this file or directory in torrent
  8. --out FILE, -o FILE save generated torrent to this FILE
  9. --private, -p create torrent for private trackers
  10. --piece-length value, -l value override default piece length. by default, piece length calculated automatically based on the total size of files. given in KB. must be multiple of 16. (default: 0)
  11. --comment COMMENT, -c COMMENT add COMMENT to torrent
  12. --tracker URL, -t URL add tracker URL
  13. --webseed URL, -w URL add webseed URL

rain torrent create

  1. rain torrent create
  2. NAME:
  3. rain torrent create - create new torrent file
  4. USAGE:
  5. rain torrent create [command options] [arguments...]
  6. OPTIONS:
  7. --file value, -f value include this file or directory in torrent
  8. --out FILE, -o FILE save generated torrent to this FILE
  9. --private, -p create torrent for private trackers
  10. --piece-length value, -l value override default piece length. by default, piece length calculated automatically based on the total size of files. given in KB. must be multiple of 16. (default: 0)
  11. --comment COMMENT, -c COMMENT add COMMENT to torrent
  12. --tracker URL, -t URL add tracker URL
  13. --webseed URL, -w URL add webseed URL

rain client

  1. NAME:
  2. rain client - send rpc request to server
  3. USAGE:
  4. rain client command [command options] [arguments...]
  5. COMMANDS:
  6. Actions:
  7. add add torrent or magnet
  8. remove remove torrent
  9. clean-database clean session database
  10. add-peer add peer to torrent
  11. add-tracker add tracker to torrent
  12. announce announce to tracker
  13. verify verify files
  14. start start torrent
  15. stop stop torrent
  16. start-all start all torrents
  17. stop-all stop all torrents
  18. move move torrent to another server
  19. Getters:
  20. version server version
  21. list list torrents
  22. stats get stats of torrent
  23. session-stats get stats of session
  24. trackers get trackers of torrent
  25. webseeds get webseed sources of torrent
  26. peers get peers of torrent
  27. torrent save torrent file
  28. magnet get magnet link
  29. Other:
  30. console show client console
  31. OPTIONS:
  32. --url value URL of RPC server (default: "http://127.0.0.1:7246")
  33. --timeout value request timeout (default: 10s)
  34. --help, -h show help

创建种子

  1. rain torrent create -t http://bttracker.top:6969/announce -f tests -o tests.torrent

注意:

  1. ll /data/dcp/tstdir5/gnome-software-0J8ZXZ/debconf.socket
  2. srwxrwxrwx 1 tms tms 0 2 25 2019 /data/dcp/tstdir5/gnome-software-0J8ZXZ/debconf.socket=

s文件会停止并提示:

  1. rain torrent create -t http://bttracker.top:6969/announce -f /data/dcp/tstdir5 -o tstdir5.torrent
  2. 2020-08-23 18:54:21 CRITICAL [rain] main.go:482 open /data/dcp/tstdir5/gnome-software-0J8ZXZ/debconf.socket: no such device or address

查看种子

  1. rain torrent show -f tests.torrent

添加种子到rpc server

  1. rain client add -t testonly_dirsend.torrent

注意确保 原文件路径 在位置上。

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注