uTorrent 的结构 uTorrentPartFile.dat

The structure of the uTorrent's uTorrentPartFile.dat

我正在尝试制作一个小型实用程序来自动执行 uTerrent 种子池的一些维护任务。为了验证部分下载共享的哈希值,我必须从 uTorrent 保存它们的 ~uTorrentPartFile_XXX.dat 文件中检索未完全包含在下载文件中的部分。这就提出了两个问题:

  1. 给定某个 .torrent 文件,我如何计算相应 ~uTorrentPartFile_XXX.dat 文件的名称(即 uTorrent 使用的十六进制字符串而不是我的 XXX)
  2. 在哪里可以找到有关文件内部结构的信息,以便从中检索所需数据? Google未能提供帮助。

BiglyBT 团队在创建迁移插件时对 ~uTorrentPartFile_XXXX.dat 格式进行了逆向工程。
https://www.biglybt.com/download/utMigrate
https://github.com/BiglySoftware/BiglyBT-plugin-migratetorrentapp

发件人:https://github.com/BiglySoftware/BiglyBT-plugin-migratetorrentapp/blob/master/src/com/biglybt/plugins/migratetorrentapp/utorrent/PartFile.java

/**
 * uTorrent partfile
 * Basically, torrent data is split into 64k parts.  Header has 4 byte index for
 * each part, pointing to data if index is > 0.  
 * After the header is the 64k data chunks, first data chunk is 1, second is 2, etc. 
 * Last data chunk may be smaller than 64k.
 * 
 * ~uTorrentPartFile_*<hexsize>*.dat
 *   <Header>, <data>
 *   
 * hexsize
 *   torrent data length in bytes in hex with no leading 0
 *
 * Header
 *   <DataIndex>[<Num64kParts>]
 *   Raw header length = <Num64kParts> * 4
 *
 * Num64kParts
 *   How many parts is required if you split torrent data length into 64k sections. 
 *   ie. Math.ceil(torrent data length in bytes / 64k)
 *
 * DataIndex
 *   4 byte little endian integer.  Values:
 *      0 
 *        No data for this 64k part
 *      1..<num64Parts>
 *        1-based positional index in <data>
 *        Location in part file can be calculated with
 *          (Header Size) + ((value - 1) * 64k)
 *   
 * data
 *   <DataPart>[up to <num64kParts>]
 *   
 * DataPart
 *   64k byte array containing torrent data.  
 *   Bytes in <DataPart> that are stored elsewhere in real files will be 0x00. 
 *   ie. non-skipped files sharing the 64k part will be 0x00. 
 *   Last <DataPart> may be less than 64k, which means the rest of the 64k would
 *   be 0x00 (and part of a non-skipped file)
 *     
 */

奖金

代码注释中resume.datsettings.dat中的内容也有一些有用的信息这里:

https://github.com/BiglySoftware/BiglyBT-plugin-migratetorrentapp/blob/master/src/com/biglybt/plugins/migratetorrentapp/utorrent/ResumeConstants.java
https://github.com/BiglySoftware/BiglyBT-plugin-migratetorrentapp/blob/master/src/com/biglybt/plugins/migratetorrentapp/utorrent/SettingsConstants.java