Documentation
¶
Overview ¶
Package cloakdriver provides Go bindings for CloakBrowser-Manager REST API and CDP automation. The package is the v2.0 fallback transport for sites where cookie-only HTTP probing is blocked by Cloudflare/ja3 fingerprinting.
Index ¶
- Variables
- type CDPSession
- func (s *CDPSession) Close()
- func (s *CDPSession) GetCookies(ctx context.Context, urls ...string) ([]*network.Cookie, error)
- func (s *CDPSession) InjectCookies(ctx context.Context, _ string, cookies []*http.Cookie) error
- func (s *CDPSession) LoadPageAndExtract(ctx context.Context, targetURL string, waitForSelector string, ...) error
- func (s *CDPSession) TaskContext() context.Context
- type ManagerClient
- type ManagerStatusInfo
- type ProfileLaunchResult
- type ProfileStatus
Constants ¶
This section is empty.
Variables ¶
var ( ErrManagerNotFound = errors.New("cloakbrowser-manager: profile not found") ErrManagerAuthFailed = errors.New("cloakbrowser-manager: auth failed (check token)") ErrManagerServerError = errors.New("cloakbrowser-manager: 5xx server error") ErrManagerDNSFailed = errors.New("cloakbrowser-manager: DNS resolution failed") ErrManagerConnRefused = errors.New("cloakbrowser-manager: connection refused") ErrManagerTimeout = errors.New("cloakbrowser-manager: timeout") ErrManagerProtocolError = errors.New("cloakbrowser-manager: protocol/parse error") )
Sentinel errors classify Manager failures (R19).
Functions ¶
This section is empty.
Types ¶
type CDPSession ¶
type CDPSession struct {
// contains filtered or unexported fields
}
CDPSession wraps a chromedp browser context bound to a CloakBrowser profile's CDP WebSocket URL (returned by Manager's POST /api/profiles/{id}/launch). Sessions are stateful; callers must Close() to release allocator and task goroutines.
func NewCDPSession ¶
func NewCDPSession(parent context.Context, cdpURL string) (*CDPSession, error)
NewCDPSession opens a chromedp NewRemoteAllocator connection to cdpURL and verifies the connection with a no-op chromedp.Run within a 5s timeout. The returned session must be Close()d.
func (*CDPSession) Close ¶
func (s *CDPSession) Close()
Close releases allocator and task contexts. Safe to call multiple times.
func (*CDPSession) GetCookies ¶
GetCookies returns all cookies currently in the browser for the given URLs.
func (*CDPSession) InjectCookies ¶
InjectCookies enforces R35: clear all browser cookies first, then set the supplied cookies. This prevents stale-cookie pollution from prior sessions in the persistent CloakBrowser profile.
func (*CDPSession) LoadPageAndExtract ¶
func (s *CDPSession) LoadPageAndExtract( ctx context.Context, targetURL string, waitForSelector string, extract func(htmlOuter string) error, ) error
LoadPageAndExtract navigates to targetURL, waits for waitForSelector to become visible, and runs extract with the rendered page's outer HTML. Used by schema-specific drivers (T11-T14) to parse user/profile pages.
func (*CDPSession) TaskContext ¶
func (s *CDPSession) TaskContext() context.Context
TaskContext returns the underlying chromedp task context for advanced callers (T11-T14 schema drivers may need direct chromedp.Run access).
type ManagerClient ¶
type ManagerClient interface {
LaunchProfile(ctx context.Context, profileID string) (*ProfileLaunchResult, error)
GetProfileStatus(ctx context.Context, profileID string) (*ProfileStatus, error)
StopProfile(ctx context.Context, profileID string) error
DeleteProfile(ctx context.Context, profileID string) error
ManagerStatus(ctx context.Context) error // GET /api/status — used by test-connection
ManagerStatusFull(ctx context.Context) (*ManagerStatusInfo, error)
}
ManagerClient is the abstraction over CloakBrowser-Manager REST. Implementations: real HTTP client (manager_client.go), httptest mock (tests).
func NewManagerClient ¶
func NewManagerClient(baseURL, token string, timeout time.Duration) ManagerClient
NewManagerClient builds a ManagerClient bound to the given Manager base URL. A zero timeout uses defaultManagerTimeout (10s).
type ManagerStatusInfo ¶
type ManagerStatusInfo struct {
Status string `json:"status,omitempty"`
Version string `json:"version,omitempty"`
}
ManagerStatusInfo is the Manager-level status payload returned by GET /api/status. Used by the test-connection endpoint to report Manager version on success.
type ProfileLaunchResult ¶
type ProfileLaunchResult struct {
ProfileID string `json:"profile_id"`
CdpURL string `json:"cdp_url"`
VncURL string `json:"vnc_url,omitempty"`
StartedAt time.Time `json:"started_at"`
}
ProfileLaunchResult is what Manager returns after POST /api/profiles/{id}/launch.
type ProfileStatus ¶
type ProfileStatus struct {
ProfileID string `json:"profile_id"`
Running bool `json:"running"`
CdpURL string `json:"cdp_url,omitempty"`
}
ProfileStatus is what Manager returns from GET /api/profiles/{id}/status.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package gazelle implements the Gazelle-schema CloakBrowser driver (T13).
|
Package gazelle implements the Gazelle-schema CloakBrowser driver (T13). |
|
Package mtorrent implements the mTorrent (M-Team) CloakBrowser driver.
|
Package mtorrent implements the mTorrent (M-Team) CloakBrowser driver. |
|
Package nexusphp implements the NexusPHP-schema CloakBrowser driver.
|
Package nexusphp implements the NexusPHP-schema CloakBrowser driver. |
|
Package unit3d implements the Unit3D-schema CloakBrowser driver.
|
Package unit3d implements the Unit3D-schema CloakBrowser driver. |