protocolstate

package
v3.6.2 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 34 Imported by: 107

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrURLDenied  = errkit.New("headless: url dropped by rule")
	ErrHostDenied = errorTemplate{/* contains filtered or unexported fields */}
)
View Source
var (
	MaxThreadsOnLowMemory          = env.GetEnvOrDefault("MEMGUARDIAN_THREADS", 0)
	MaxBytesBufferAllocOnLowMemory = env.GetEnvOrDefault("MEMGUARDIAN_ALLOC", 0)
)
View Source
var (
	// LfaAllowed means local file access is allowed
	LfaAllowed *mapsutil.SyncLockMap[string, bool]
)
View Source
var Memoizer *memoize.Memoizer

Functions

func Close

func Close(executionId string)

Close closes the global shared fastdialer

func FailWithReason

func FailWithReason(page *rod.Page, e *proto.FetchRequestPaused) error

FailWithReason fails request with AccessDenied reason

func GetLfaAllowed added in v3.4.8

func GetLfaAllowed(options *types.Options) bool

func GetNetworkPolicy added in v3.4.8

func GetNetworkPolicy(ctx context.Context) *networkpolicy.NetworkPolicy

func GlobalGuardBytesBufferAlloc added in v3.2.1

func GlobalGuardBytesBufferAlloc() error

Global setting

func GlobalRestoreBytesBufferAlloc added in v3.2.1

func GlobalRestoreBytesBufferAlloc()

Global setting

func GuardThreadsOrDefault added in v3.2.1

func GuardThreadsOrDefault(current int) int

GuardThreads on caller

func HasExecutionContext added in v3.4.8

func HasExecutionContext(ctx context.Context) bool

HasExecutionID checks if the context has an execution ID

func Init

func Init(options *types.Options) error

Init creates the Dialers instance based on user configuration

func InitHeadless

func InitHeadless(options *types.Options)

InitHeadless initializes headless protocol state

func IsHostAllowed

func IsHostAllowed(executionId string, targetUrl string) bool

IsHostAllowed checks if the host is allowed by network policy

func IsLfaAllowed added in v3.4.8

func IsLfaAllowed(options *types.Options) bool

IsLfaAllowed returns whether local file access is allowed

func IsLowOnMemory added in v3.2.1

func IsLowOnMemory() bool

func IsRestrictLocalNetworkAccess added in v3.4.8

func IsRestrictLocalNetworkAccess(options *types.Options) bool

func NewJSRuntime

func NewJSRuntime() *goja.Runtime

NewJSRuntime returns a new javascript runtime with defaults set i.e sourcemap parsing is disabled by default

func NormalizePath

func NormalizePath(options *types.Options, filePath string) (string, error)

Normalizepath normalizes path and returns absolute path it returns error if path is not allowed this respects the sandbox rules and only loads files from allowed directories

func NormalizePathWithExecutionId added in v3.4.8

func NormalizePathWithExecutionId(executionId string, filePath string) (string, error)

func SetLfaAllowed added in v3.4.8

func SetLfaAllowed(options *types.Options)

func ShouldInit added in v3.2.9

func ShouldInit(id string) bool

func StartActiveMemGuardian added in v3.2.1

func StartActiveMemGuardian(ctx context.Context)

func StopActiveMemGuardian added in v3.2.1

func StopActiveMemGuardian()

func ValidateNFailRequest

func ValidateNFailRequest(options *types.Options, page *rod.Page, e *proto.FetchRequestPaused) error

ValidateNFailRequest validates and fails request if the request does not respect the rules, it will be canceled with reason

func WithAutoExecutionContext added in v3.4.8

func WithAutoExecutionContext(ctx context.Context) context.Context

WithAutoExecutionContext creates a new context with an automatically generated execution ID If the input context already has an execution ID, it will be preserved

func WithExecutionID added in v3.4.8

func WithExecutionID(ctx context.Context, executionContext *ExecutionContext) context.Context

WithExecutionID adds an execution ID to the context

Types

type ContextKey added in v3.4.8

type ContextKey string

contextKey is a type for context keys

type Dialers added in v3.4.8

type Dialers struct {
	Fastdialer                 *fastdialer.Dialer
	RawHTTPClient              *rawhttp.Client
	DefaultHTTPClient          *retryablehttp.Client
	HTTPClientPool             *mapsutil.SyncLockMap[string, *retryablehttp.Client]
	NetworkPolicy              *networkpolicy.NetworkPolicy
	LocalFileAccessAllowed     bool
	RestrictLocalNetworkAccess bool

	sync.Mutex
}

func GetDialers added in v3.4.8

func GetDialers(ctx context.Context) *Dialers

func GetDialersWithId added in v3.4.8

func GetDialersWithId(id string) *Dialers

type ExecutionContext added in v3.4.8

type ExecutionContext struct {
	ExecutionID string
}

func GetExecutionContext added in v3.4.8

func GetExecutionContext(ctx context.Context) *ExecutionContext

GetExecutionID retrieves the execution ID from the context Returns empty string if no execution ID is set

Jump to

Keyboard shortcuts

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