anacrolix / torrent

Full-featured BitTorrent client package and utilities
Mozilla Public License 2.0
5.39k stars 615 forks source link

Clean up ClientConfig HTTP options #864

Open anacrolix opened 10 months ago

anacrolix commented 10 months ago

There are a proliferation of HTTP related options in ClientConfig. I believe it might be possible to converge on just exposing http.Client for each use case. http.Client handles having custom proxies, TLS settings, redirect handling, timeouts etc.

The use cases for HTTP in anacrolix/torrent are:

One strong holdout against this I think is the websocket library in use for webtorrent trackers. It only takes a proxy option. However the nyooyr.io/websocket module takes *http.Client, so this could be upgraded.

Another place is resolving IPs for trackers. This is currently done manually to check against blocklists before issuing HTTP requests. I think this is still doable, but some APIs might change.

anacrolix commented 10 months ago

I wonder if you might chime in with your thoughts @ccampbell, @yangrq1018.

veshij commented 4 months ago

I can try to work on this issue. I suppose it'll require backward-incompatible changes of ClientConfig (deprecating existing fields). Should we support both options for a while?

anacrolix commented 4 months ago

I can try to work on this issue. I suppose it'll require backward-incompatible changes of ClientConfig (deprecating existing fields). Should we support both options for a while?

I think examining all the places that could be affected, determining that it could work then rolling it out subsystem by subsystem should work fine if it is indeed the right abstraction for this.