Documentation
¶
Index ¶
- Constants
- Variables
- func ImageBase64(image string) string
- func ImageBody(image []byte) string
- func ImageFile(path string) (string, error)
- func NormalizeProxy(proxy string) (string, string, error)
- func Taxonomy() map[string]bool
- type Client
- func (c *Client) Balance(ctx context.Context) (float64, error)
- func (c *Client) CreateTask(ctx context.Context, taskType string, task map[string]any) (int, error)
- func (c *Client) GetTaskResult(ctx context.Context, taskID int) (map[string]any, error)
- func (c *Client) ReportBad(ctx context.Context, taskID string) (bool, error)
- func (c *Client) Result(ctx context.Context, taskID string) (string, error)
- func (c *Client) Solve(ctx context.Context, method string, params map[string]any) (string, error)
- func (c *Client) SolveFunCaptcha(ctx context.Context, publickey, pageurl string, params map[string]any) (string, error)
- func (c *Client) SolveGeeTest(ctx context.Context, gt, challenge, pageurl string, params map[string]any) (string, error)
- func (c *Client) SolveHCaptcha(ctx context.Context, sitekey, pageurl string, params map[string]any) (string, error)
- func (c *Client) SolveImage(ctx context.Context, image []byte, params map[string]any) (string, error)
- func (c *Client) SolveImageBase64(ctx context.Context, image string, params map[string]any) (string, error)
- func (c *Client) SolveImageFile(ctx context.Context, path string, params map[string]any) (string, error)
- func (c *Client) SolveRecaptchaV2(ctx context.Context, sitekey, pageurl string, opts *RecaptchaV2Options) (string, error)
- func (c *Client) SolveRecaptchaV3(ctx context.Context, sitekey, pageurl, action string, opts *RecaptchaV3Options) (string, error)
- func (c *Client) SolveTurnstile(ctx context.Context, sitekey, pageurl string, params map[string]any) (string, error)
- func (c *Client) SolveWithTimeout(ctx context.Context, method string, params map[string]any, ...) (string, error)
- func (c *Client) Submit(ctx context.Context, method string, params map[string]any) (string, error)
- func (c *Client) WaitResult(ctx context.Context, taskID string, timeout time.Duration) (string, error)
- func (c *Client) WaitTaskResult(ctx context.Context, taskID int, timeout time.Duration) (map[string]any, error)
- type Config
- type Error
- type HTTPTransport
- func (t *HTTPTransport) Get(ctx context.Context, path string, query url.Values) (map[string]any, error)
- func (t *HTTPTransport) PostForm(ctx context.Context, path string, form url.Values) (map[string]any, error)
- func (t *HTTPTransport) PostJSON(ctx context.Context, path string, payload any) (map[string]any, error)
- type RecaptchaV2Options
- type RecaptchaV3Options
- type Transport
Constants ¶
const ( // NotReady is part of the wire contract — spelling included. NotReady = "CAPCHA_NOT_READY" // SoftID is sent for upstream attribution once assigned; zero omits it. SoftID = 0 )
Variables ¶
var ( ErrProcessing = errors.New("azcaptcha: processing") ErrAuth = errors.New("azcaptcha: auth") ErrBalance = errors.New("azcaptcha: balance") ErrRequest = errors.New("azcaptcha: request") ErrLimit = errors.New("azcaptcha: limit") ErrCapacity = errors.New("azcaptcha: capacity") ErrService = errors.New("azcaptcha: service") ErrResult = errors.New("azcaptcha: result") ErrProxy = errors.New("azcaptcha: proxy") ErrPingback = errors.New("azcaptcha: pingback") ErrModule = errors.New("azcaptcha: module") ErrNetwork = errors.New("azcaptcha: network") ErrUnknown = errors.New("azcaptcha: unknown") )
Category sentinels — use with errors.Is to branch without matching codes.
var DefaultTimeouts = map[string]time.Duration{ "base64": 120 * time.Second, "grid": 120 * time.Second, "userrecaptcha": 300 * time.Second, "recaptcha_v3": 300 * time.Second, "hcaptcha": 120 * time.Second, "hcaptcha_enterprise": 120 * time.Second, "turnstile": 180 * time.Second, "funcaptcha": 300 * time.Second, "geetest": 300 * time.Second, "geetest_v4": 300 * time.Second, "mtcaptcha": 300 * time.Second, "friendlycaptcha": 300 * time.Second, "altcha": 300 * time.Second, "cf_clearance": 300 * time.Second, "aws_waf": 300 * time.Second, "filecrypt": 300 * time.Second, }
DefaultTimeouts mirror the server-side expiry per method.
Functions ¶
func ImageBase64 ¶
ImageBase64 normalises a data: URI or base64 string to bare base64.
func NormalizeProxy ¶
NormalizeProxy accepts scheme://user:pass@host:port, host:port:user:pass and user:pass@host:port. The scheme is never sent in the proxy field.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the AZcaptcha API. It is safe for concurrent use.
func (*Client) CreateTask ¶
CreateTask submits a modern-API task and returns its numeric id.
func (*Client) GetTaskResult ¶
GetTaskResult polls the modern API once.
func (*Client) SolveFunCaptcha ¶
func (*Client) SolveGeeTest ¶
func (*Client) SolveHCaptcha ¶
func (*Client) SolveImage ¶
func (c *Client) SolveImage(ctx context.Context, image []byte, params map[string]any) (string, error)
SolveImage solves a raw image (PNG/JPEG bytes).
func (*Client) SolveImageBase64 ¶
func (c *Client) SolveImageBase64(ctx context.Context, image string, params map[string]any) (string, error)
SolveImageBase64 solves an already-encoded image (data: URI accepted).
func (*Client) SolveImageFile ¶
func (c *Client) SolveImageFile(ctx context.Context, path string, params map[string]any) (string, error)
SolveImageFile reads a file and solves it.
func (*Client) SolveRecaptchaV2 ¶
func (*Client) SolveRecaptchaV3 ¶
func (*Client) SolveTurnstile ¶
func (*Client) SolveWithTimeout ¶
func (c *Client) SolveWithTimeout(ctx context.Context, method string, params map[string]any, timeout time.Duration) (string, error)
SolveWithTimeout is Solve with an explicit deadline.
type Config ¶
type Config struct {
Host string
HTTPTimeout time.Duration
SoftID int
Transport Transport
Sleep func(time.Duration)
}
Config overrides defaults; the zero value is production-ready.
type HTTPTransport ¶
HTTPTransport is the default transport.
func NewHTTPTransport ¶
func NewHTTPTransport(baseURL string, timeout time.Duration) *HTTPTransport
type RecaptchaV2Options ¶
RecaptchaV2Options tunes the v2 helper.
type RecaptchaV3Options ¶
RecaptchaV3Options tunes the v3 helper.
type Transport ¶
type Transport interface {
PostForm(ctx context.Context, path string, form url.Values) (map[string]any, error)
PostJSON(ctx context.Context, path string, payload any) (map[string]any, error)
Get(ctx context.Context, path string, query url.Values) (map[string]any, error)
}
Transport is the minimal HTTP surface the client needs; tests provide a fake.