Skip to content

v1.61.0: TrackerDialContext (HTTP CONNECT proxy) broken by client-trackers refactor #1038

@ybmeng

Description

@ybmeng

Summary

After upgrading from v1.60.0 to v1.61.0, torrents added via AddTorrentSpec never receive metadata when TrackerDialContext is configured to route tracker connections through an HTTP CONNECT proxy. The torrent sits at 0 peers for the entire duration until timeout. Downgrading back to v1.60.0 (via replace directive) immediately fixes the issue — same magnets, same proxy, same config.

Environment

  • Go 1.24.5, macOS (darwin)
  • HTTP CONNECT proxy (NordVPN HTTPS proxy on port 89)
  • TrackerDialContext set to a custom proxy dialer
  • DHT disabled (NoDHT: true), uTP disabled (DisableUTP: true), PEX disabled (DisablePEX: true)
  • Only TCP peer connections through proxy dialer (client.AddDialer)

Client Config

cfg := torrent.NewDefaultClientConfig()
cfg.Seed = true
cfg.DisableIPv6 = true
cfg.TrackerDialContext = proxyDialer.DialContext
cfg.HTTPDialContext = proxyDialer.DialContext
cfg.DialForPeerConns = false
cfg.NoDHT = true
cfg.DisableUTP = true
cfg.DisablePEX = true
cfg.AcceptPeerConnections = false
cfg.NoDefaultPortForwarding = true
cfg.DisableAcceptRateLimiting = true
cfg.DisableTCP = false

client.AddDialer(dialer.WithNetwork{
    Network: "tcp4",
    Dialer:  proxyDialer,
})

Reproduction

  1. Create a torrent client with the config above (proxy + disabled UDP/DHT/PEX)
  2. Add a well-seeded torrent via AddTorrentSpec
  3. Wait for GotInfo()v1.60.0: resolves in ~2s with peers. v1.61.0: never resolves, 0 peers throughout

Observed Behavior

  • t.Stats() shows TotalPeers=0, ActivePeers=0, ConnectedSeeders=0 for the entire 60s wait
  • The torrent has standard UDP trackers (e.g., udp://tracker.opentrackr.org:1337/announce)
  • These same magnets with the same proxy config download successfully on v1.60.0

Root Cause (suspected)

The client-trackers branch merged in v1.61.0 replaced per-torrent trackerScraper goroutines with a centralized regularTrackerAnnounceDispatcher. The old trackerScraper.Run() would immediately start announcing to trackers using TrackerDialContext. The new dispatcher uses timer-based scheduling that appears to either:

  1. Not trigger the first announce quickly enough (or at all) for proxy-routed connections
  2. Have an issue with the announce dispatch loop when TrackerDialContext is set

The TrackerDialContext config field is still passed through to initTrackerClienttracker.NewClientOpts, so the plumbing exists — but the scheduling/dispatch layer seems to not actually fire announces in time.

Workaround

Pin to v1.60.0 via replace directive in go.mod:

replace github.com/anacrolix/torrent => github.com/anacrolix/torrent v1.60.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions