Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrURLParse = errors.New("cannot parse url") ErrHostModuleInit = errors.New("cannot instantiate the host module") ErrWASIModuleInit = errors.New("cannot instantiate the WASI module") ErrPACModuleInit = errors.New("cannot instantiate the PAC module") ErrPACEvaluation = errors.New("cannot evaluate the PAC script") )
Functions ¶
func DNSResolver ¶ added in v0.3.0
DNSResolver resolves a given hostname to the corresponding IP address. Adapted from https://github.com/darren/gpac/blob/master/builtin_natives.go
func EvalPAC ¶
EvalPAC evaluates a given PAC script for the given url, and returns the output string. The evaluation is done in the Boa JavaScript engine, which itself is compiled into a WASM module and run by the Wazero WASM engine. Note that stdin, stdout and stderr are not connected to the wasm module, therefore console commands will not work inside the PAC scripts.
func MyIPAddr ¶ added in v0.3.0
MyIPAddr returns the ip address of the machine. The meaning of this is vague for machines with multiple NICs and even in the presence of IPv6; so the usage of this function is generally discouraged in PAC files. See: https://findproxyforurl.com/pac-functions/ Adapted from https://github.com/darren/gpac/blob/master/builtin_natives.go
Types ¶
type DNSResolverFn ¶ added in v0.3.0
type Evaluator ¶ added in v0.3.0
type Evaluator struct {
// Logger can be nil, to disable logging from the Evaluator altogether.
// Default value is slog.Default().
Logger *slog.Logger
// host functions
DNSResolver DNSResolverFn
MyIPAddr MyIPAddrFn
RandSource io.Reader
Nanosleep sys.Nanosleep
Nanotime sys.Nanotime
NanotimeResolution sys.ClockResolution
Walltime sys.Walltime
WalltimeResolution sys.ClockResolution
}