cfsolve

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCFChallenge

func IsCFChallenge(statusCode int, headers map[string]string, body []byte) bool

IsCFChallenge returns true if the response looks like a Cloudflare challenge page. It requires all three conditions: status 403/503, a CF header, and a body marker.

Types

type SolveResult

type SolveResult struct {
	Solved  bool
	Cookies []*http.Cookie
	Err     error
}

SolveResult holds the outcome of a Cloudflare challenge solve attempt.

type Solver

type Solver struct {
	// contains filtered or unexported fields
}

Solver resolves Cloudflare challenges via headless Chrome with stealth. It deduplicates concurrent solves per host and shares cookies via a jar.

func New

func New(userAgent string, jar *cookiejar.Jar, solveTimeout time.Duration) *Solver

New creates a Solver. The jar must be the same one used by the Fetcher.

func (*Solver) Close

func (s *Solver) Close()

Close shuts down the browser if it was started.

func (*Solver) Solve

func (s *Solver) Solve(ctx context.Context, challengeURL string) *SolveResult

Solve navigates to the challenge URL in headless Chrome, waits for cf_clearance to appear, and injects the cookies into the shared jar. Concurrent calls for the same host block on the first solve.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL