protocolstate

package
v3.0.0-...-7b6adf0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrURLDenied  = errorutil.NewWithFmt("headless: url %v dropped by rule: %v")
	ErrHostDenied = errorutil.NewWithFmt("host %v dropped by network policy")
	NetworkPolicy *networkpolicy.NetworkPolicy
)
View Source
var (
	MaxThreadsOnLowMemory          = env.GetEnvOrDefault("MEMGUARDIAN_THREADS", 0)
	MaxBytesBufferAllocOnLowMemory = env.GetEnvOrDefault("MEMGUARDIAN_ALLOC", 0)
)
View Source
var (
	Dialer *fastdialer.Dialer
)

Dialer is a shared fastdialer instance for host DNS resolution

View Source
var Memoizer *memoize.Memoizer

Functions

func Close

func Close()

Close closes the global shared fastdialer

func FailWithReason

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

FailWithReason fails request with AccessDenied reason

func GetDialer

func GetDialer() *fastdialer.Dialer

func GlobalGuardBytesBufferAlloc

func GlobalGuardBytesBufferAlloc() error

Global setting

func GlobalRestoreBytesBufferAlloc

func GlobalRestoreBytesBufferAlloc()

Global setting

func GuardThreadsOrDefault

func GuardThreadsOrDefault(current int) int

GuardThreads on caller

func Init

func Init(options *types.Options) error

Init creates the Dialer instance based on user configuration

func InitHeadless

func InitHeadless(localFileAccess bool, np *networkpolicy.NetworkPolicy)

InitHeadless initializes headless protocol state

func IsHostAllowed

func IsHostAllowed(targetUrl string) bool

IsHostAllowed checks if the host is allowed by network policy

func IsLFAAllowed

func IsLFAAllowed() bool

IsLFAAllowed returns true if local file access is allowed

func IsLowOnMemory

func IsLowOnMemory() 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(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 ShouldInit

func ShouldInit() bool

func StartActiveMemGuardian

func StartActiveMemGuardian(ctx context.Context)

func StopActiveMemGuardian

func StopActiveMemGuardian()

func ValidateNFailRequest

func ValidateNFailRequest(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

Types

This section is empty.

Jump to

Keyboard shortcuts

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