Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
feat: add proxy info in script context
Browse files Browse the repository at this point in the history
  • Loading branch information
dl0im committed Jul 31, 2022
1 parent be9b1b5 commit df62024
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ func VMNew() *goja.Runtime {
func VMNewWithVendor(p interfaces.Vendor, network interfaces.RequestOptionsNetwork) *goja.Runtime {
vm := VMNew()

if p != nil {
pi := p.ProxyInfo()
vm.Set("proxy", vm.ToValue(pi.Map()))
} else {
vm.Set("proxy", nil)
}

vm.Set("fetch", factory.FetchFactory(vm, p, network))
vm.Set("netcat", factory.NetCatFactory(vm, p, network))

Expand Down
8 changes: 8 additions & 0 deletions interfaces/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,11 @@ type ProxyInfo struct {
Address string
Type ProxyType
}

func (pi *ProxyInfo) Map() map[string]string {
return map[string]string{
"Name": pi.Name,
"Address": pi.Address,
"Type": string(pi.Type),
}
}

0 comments on commit df62024

Please sign in to comment.