anacrolix / anacrolix/torrent

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

Đang mở
#1,097 1 bình luận 1 reaction 2 người được giao Được @anacrolix nhận Xem trên GitHub
Ngôn ngữ chính
Go
Star
6.1k
Fork
690
Merge trung bình
3 ngày 10 giờ
Pull request đã merge (30 ngày)
12

Mô tả

## 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`.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
git, go
Lĩnh vực
release
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.