libtorrent dht 对等请求?

发布于 2024-11-19 02:07:00 字数 156 浏览 14 评论 0原文

我一直在研究 libtorrent/rasterbar 的 python 绑定。 我想做的是生成一个新的“节点 ID”并将其重新通告给其他节点。

我读到需要创建一个“bencoded 字典”,并且我假设使用像force_dht_reannounce 这样的东西来宣布,这是正确的吗?

Ive been playing around with the python bindings for libtorrent/rasterbar.
What I wanted to do was generate a new 'node-id' and reannounce it to the other nodes.

I read that a 'bencoded dicionary' needs to be created and I assume announced using something like force_dht_reannounce, is this correct?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以为你会在 2024-11-26 02:07:00

您可以通过创建会话状态文件来强制 libtorrent 使用 DHT 的特定节点 ID,并将其提供给 session::load_state() 函数。执行此操作后,您还需要通过调用 session::stop_dht()session::start_dht() 来重新启动 DHT。

您需要制作的会话状态的相关部分具有以下格式(编码):

  {
    "dht state": {
      "node-id": "<20-byte binary node-ID>"
    }
  }

如果您想保留会话状态的其余部分,首先调用 session::save_state() 可能是个好主意/code> 然后简单地插入/覆盖 node-id 字段。

像这样的东西:

state = ses.save_state()
state["dht state"]["node-id"] = "<...>";
ses.load_state(state)
ses.stop_dht()
ses.start_dht()

You can force libtorrent to use a specific node ID for the DHT by crafting a session-state file, and feed it to the session::load_state() function. Once you do this, you also need to restart the DHT by calling session::stop_dht() followed by session::start_dht().

The relevant parts of the session state you need to craft have the following format (bencoded):

  {
    "dht state": {
      "node-id": "<20-byte binary node-ID>"
    }
  }

If you want to keep the rest of the session state, it might be a good idea to first call session::save_state() and then simply insert/overwrite the node-id field.

Something like this:

state = ses.save_state()
state["dht state"]["node-id"] = "<...>";
ses.load_state(state)
ses.stop_dht()
ses.start_dht()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文