我有一个想法,用现有的BitTorrent DHT来实现一个基于关键字的实时种子搜索机制,我想知道它是否可行和现实。
我们有一个 torrent,我们希望能够keyword
仅使用 DHT 找到它。
H
是一个 20 字节输出的散列函数infohash
是种子的 info_hash(20 字节)sub(hash, i)
返回hash
从 byte 开始的 2 个字节i
(例如,sub(0x62616463666568676a696c6b6e6d706f72717473, 2) = 0x6463
)announce_peer(hash, port)
发布与虚假 info_hash 关联的虚假对等点hash
。fake peer 的 IP 无关紧要,我们使用该port
数字来存储数据(2 个字节)。get_peers(hash)
检索与假 info_hash 关联的假对等点hash
。让我们考虑这个函数只返回一个端口号列表。a ++ b
表示连接a
和b
(例如,0x01 ++ 0x0203 = 0x010203
)
出版物
id <- sub(infohash, 0)
announce_peer( H( 0x0000 ++ 0x00 ++ keyword ), id )
announce_peer( H( id ++ 0x01 ++ keyword ), sub(infohash, 2 ))
announce_peer( H( id ++ 0x02 ++ keyword ), sub(infohash, 4 ))
announce_peer( H( id ++ 0x03 ++ keyword ), sub(infohash, 6 ))
announce_peer( H( id ++ 0x04 ++ keyword ), sub(infohash, 8 ))
announce_peer( H( id ++ 0x05 ++ keyword ), sub(infohash, 10))
announce_peer( H( id ++ 0x06 ++ keyword ), sub(infohash, 12))
announce_peer( H( id ++ 0x07 ++ keyword ), sub(infohash, 14))
announce_peer( H( id ++ 0x08 ++ keyword ), sub(infohash, 16))
announce_peer( H( id ++ 0x09 ++ keyword ), sub(infohash, 18))
搜索
ids <- get_peers(H( 0x0000 ++ 0x00 ++ keyword ))
foreach (id : ids)
{
part1 <- get_peers(H( id ++ 0x01 ++ keyword ))[0]
part2 <- get_peers(H( id ++ 0x02 ++ keyword ))[0]
part3 <- get_peers(H( id ++ 0x03 ++ keyword ))[0]
part4 <- get_peers(H( id ++ 0x04 ++ keyword ))[0]
part5 <- get_peers(H( id ++ 0x05 ++ keyword ))[0]
part6 <- get_peers(H( id ++ 0x06 ++ keyword ))[0]
part7 <- get_peers(H( id ++ 0x07 ++ keyword ))[0]
part8 <- get_peers(H( id ++ 0x08 ++ keyword ))[0]
part9 <- get_peers(H( id ++ 0x09 ++ keyword ))[0]
result_infohash <- id ++ part1 ++ part2 ++ ... ++ part9
print("search result:" ++ result_infohash)
}
我知道会与id
(仅 2 个字节)发生冲突,但是对于相对特定的关键字,它应该可以工作......
我们还可以通过按字母数字顺序连接多个单词来构建更具体的关键字。例如,如果我们有单词A
,B
并且C
与种子相关联,我们可以发布关键字A
、B
、C
、A ++ B
、A ++ C
和。B ++ C
A ++ B ++ C
那么,这个可怕的黑客是否可行:D?我知道Retroshare 正在使用 BitTorrent 的 DHT。