Repository navigation
v0.2.0
This release moves cloudfetch to an API modelled on net/http. It has breaking changes; see the upgrade notes below.
go get github.com/luinor223/cloudfetch@v0.2.0Breaking changes
Dotakes an*http.Request. Its context and headers apply to the whole call, including challenge solving, andreqis not modified.DoContextis removed: usehttp.NewRequestWithContextinstead.Posttakes a content type, likenet/http:Post(url, contentType, body).WithBrowsertakes aBrowser(Chrome,Firefox,Safari,Edge) instead of autls.ClientHelloID. Each preset pins a TLS fingerprint and headers for the same version: Chrome 133, Firefox 120, Safari 16.0 and Edge 85.MaxChallengeRetriesis replaced byWithMaxRetries(n). The default is 3; 0 disables solving.- Unsolvable challenges return sentinel errors you can check with
errors.Is:ErrManagedChallenge,ErrCaptchaandErrChallengeFailed. Running out of retries now returnsErrChallengeFailedinstead of the challenge page. - Header precedence: headers set on the request now override
WithHeader, which overrides the browser defaults.
Upgrading
// v0.1.0
resp, err := client.DoContext(ctx, "POST", url, body)
client := cloudfetch.New(cloudfetch.WithBrowser(utls.HelloFirefox_120))
// v0.2.0
req, _ := http.NewRequestWithContext(ctx, http.MethodPost, url, body)
resp, err := client.Do(req)
client := cloudfetch.New(cloudfetch.WithBrowser(cloudfetch.Firefox))New
Client.CloseIdleConnections(), whichhttp.Client.CloseIdleConnections()also reaches.- Runnable programs in
examples/.
Fixes
- The IUAM solver handles real Cloudflare pages. It is tested against challenge pages captured by cloudscraper, including pages with decoy inputs,
setIntervaland answers read from hidden elements. - Concurrent first requests to one host no longer leak a connection, and HTTP/2 connections that get replaced now close once they are idle.
- Bare IPv6 hosts such as
https://[::1]/get the default port. - Non-Cloudflare 403, 429 and 503 responses are no longer read into memory just to check for a challenge.
Full changelog: v0.1.0...v0.2.0