protocolstate

package
v3.7.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 34 Imported by: 0

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

func GetLfaAllowed(options *types.Options) bool

func GetNetworkPolicy

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

func GlobalGuardBytesBufferAlloc

func GlobalGuardBytesBufferAlloc() error

Global setting

func GlobalRestoreBytesBufferAlloc

func GlobalRestoreBytesBufferAlloc()

Global setting

func GuardThreadsOrDefault

func GuardThreadsOrDefault(current int) int

GuardThreads on caller

func HasExecutionContext

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

func IsLfaAllowed(options *types.Options) bool

IsLfaAllowed returns whether local file access is allowed

func IsLowOnMemory

func IsLowOnMemory() bool

func IsRestrictLocalNetworkAccess

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

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

func SetLfaAllowed

func SetLfaAllowed(options *types.Options)

func ShouldInit

func ShouldInit(id string) bool

func StartActiveMemGuardian

func StartActiveMemGuardian(ctx context.Context)

func StopActiveMemGuardian

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

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

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

WithExecutionID adds an execution ID to the context

Types

type ContextKey

type ContextKey string

contextKey is a type for context keys

type Dialers

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

func GetDialers(ctx context.Context) *Dialers

func GetDialersWithId

func GetDialersWithId(id string) *Dialers

type ExecutionContext

type ExecutionContext struct {
	ExecutionID string
}

func GetExecutionContext

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