anacrolix / anacrolix/torrent

Release request: include the merged BEP 52 v2-only fixes (#1089, #1090, #1091)

オープン
#1,097 コメント 1 件 リアクション 1 件 担当者 2 名 @anacrolix が担当を希望しています GitHub で見る
主要言語
Go
スター
6.1k
フォーク
690
平均マージ
3日 10時間
マージ済み PR(30日)
12

説明

## Request

Could you publish a tagged release containing the BEP 52 v2-only fixes from #1090 and #1091, or a maintenance backport if that is more practical?

This is a **release-availability follow-up**, not a duplicate report of #1089 or a claim that the same panic remains on `master`. As of 2026-09-06, the latest published Git tag is still `v1.61.0`. #1090 was merged on August 30 and #1091 on August 31.

Applications consuming tagged versions therefore still encounter the v2-only panic and need to reject otherwise-valid v2-only input as a workaround.

## Minimal offline reproduction on v1.61.0

Environment: Go 1.26.5, Linux/amd64, `github.com/anacrolix/torrent v1.61.0`.

Save as `v2_test.go` in a Go module requiring that version, then run:

```sh
go test -run '^TestV2OnlyMagnetCanBeAdded$' -count=1 -timeout=20s
```

```go
package upstream_test

import (
"strings"
"testing"

"github.com/anacrolix/torrent"
)

func TestV2OnlyMagnetCanBeAdded(t *testing.T) {
cfg := torrent.NewDefaultClientConfig()
cfg.DataDir = t.TempDir()
cfg.DisableTCP = true
cfg.DisableUTP = true
cfg.NoDHT = true
cfg.DisableTrackers = true
cfg.DisableWebtorrent = true
cfg.NoDefaultPortForwarding = true

client, err := torrent.NewClient(cfg)
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { client.Close() })

// Synthetic SHA-256 digest; no real torrent, tracker, or peer.
uri := "magnet:?xt=urn:btmh:1220" + strings.Repeat("1", 64)
if _, err := client.AddMagnet(uri); err != nil {
t.Fatal(err)
}
}
```

Observed locally:

```text
panic: is zero
github.com/anacrolix/torrent.(*Client).AddTorrentOpt
client.go:1514
github.com/anacrolix/torrent.(*Client).AddTorrentSpec
client.go:1566
github.com/anacrolix/torrent.(*Client).AddMagnet
client.go:1669
```

The URI parses successfully, but [`AddTorrentOpt` in v1.61.0](https://github.com/anacrolix/torrent/blob/v1.61.0/client.go#L1512-L1536) unconditionally asserts a nonzero v1 hash before considering the v2 hash.

## Suggested resolution

Release the complete merged v2 fix, rather than only removing the assertion:

1. Allow an absent v1 hash when `InfoHashV2` is present.
2. Skip the v1 lookup when that hash is absent.
3. Register every available short infohash so v2 lookup/deduplication and removal remain consistent.
4. Include the piece-layer initialization ordering fix from #1091; an assertion-only change was not sufficient for the pure-v2 torrent tests.

The existing implementation is in #1091 (merge commit `9accffaf1f38ec74109a849cc26c92e592a41b95`), together with the pure-v2 fixture regression introduced by this work. For a backport, it would also be useful to cover adding the same v2-only magnet twice, dropping and re-adding it, and preserving hybrid/v1 behavior.

I have reproduced the failure on `v1.61.0` and inspected the merged changes; I am not claiming a new end-to-end validation of v2 downloading on `master`.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Review the merged implementation in #1091 and the open PR #1101, then compare it with the v1.61.0 client.go path and the pure-v2 fixture regression mentioned in the issue. Run the supplied offline Go test against v1.61.0 and the candidate release; done means a tagged release or documented maintenance backport includes #1090 and #1091 with the listed pure-v2 coverage.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
git, go
領域
release
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。