小编Oli*_*hou的帖子

如何获得对ut_metadata piece请求的响应?(node.js Bit Torrent BEP 0009)

我正在使用Node.js构建一个Bittorrent客户端,并且无法通过PWP元数据扩展(BEP 0009)从对等方获得答案

我从DHT(BEP 0005)(我宣布的地方)获得同行,然后使用网络套接字在PWP上发送握手和扩展握手.

buildHandshake = (torrent, ext) => { // torrent contains mainly infoHash
    const buf = Buffer.alloc(68)
    buf.writeUInt8(19, 0)
    buf.write('BitTorrent protocol', 1)
    if (ext) {
        const big = new Uint64BE(1048576)
        big.toBuffer().copy(buf, 20)
    } else {
        buf.writeUInt32BE(0, 20)
        buf.writeUInt32BE(0, 24)
    }
    torrent.infoHashBuffer.copy(buf, 28)
    anon.nodeId().copy(buf, 48) // tool that generates a nodeId once.
    return buf
}

buildExtRequest = (id, msg) => {
    const size = msg.length + 1
    const buf = Buffer.alloc(size + 5)
    buf.writeUInt32BE(size, 0) …
Run Code Online (Sandbox Code Playgroud)

javascript bittorrent protocols node.js torrent

5
推荐指数
1
解决办法
307
查看次数

标签 统计

bittorrent ×1

javascript ×1

node.js ×1

protocols ×1

torrent ×1