anacrolix / anacrolix/torrent

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

Offen
#1,097 1 Kommentar 1 Reaktion 2 zugewiesene Personen Beansprucht von @anacrolix Auf GitHub ansehen
Vorherrschende Sprache
Go
Sterne
6.1k
Forks
690
Ø Merge
3 T. 10 Std.
Gemergte PRs (30 T.)
12

Beschreibung

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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.