【发布时间】:2018-01-02 17:18:20
【问题描述】:
我有一个想法,利用现有的BitTorrent DHT实现一个基于关键字的实时种子搜索机制,我想知道它是否可行和现实。
我们有一个种子,我们希望能够仅使用 DHT 从keyword 找到它。
-
H是一个 20 字节输出的散列函数 -
infohash是种子的 info_hash(20 字节) -
sub(hash, i)返回 2 个字节的hash,从字节i开始(例如,sub(0x62616463666568676a696c6b6e6d706f72717473, 2) = 0x6463) -
announce_peer(hash, port)发布与虚假 info_hashhash关联的虚假对等点。 fake peer 的 IP 无关紧要,我们使用port数字来存储数据(2 个字节)。 -
get_peers(hash)检索与虚假 info_hashhash关联的虚假对等点。让我们考虑这个函数只返回一个端口号列表。 -
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。
那么,这个可怕的 hack 可行吗 :D ?我知道Retroshare is using BitTorrent's DHT。
【问题讨论】:
标签: bittorrent dht kademlia