Skip to content

darren/gpac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

b56d652 · Jun 9, 2021

History

37 Commits
Jan 24, 2019
Jan 24, 2019
Jan 24, 2019
Jan 24, 2019
Dec 9, 2020
Jan 24, 2019
Jul 2, 2020
Jun 9, 2021
Jun 9, 2021
Jun 9, 2021
Jul 2, 2020
Jun 9, 2021
Feb 2, 2019
Feb 1, 2019

Repository files navigation

gpac

PkgGoDev

This package provides a pure Go pac parser based on otto

Example usage

package main

import (
	"fmt"

	"github.com/darren/gpac"
)

var scripts = `
  function FindProxyForURL(url, host) {
    if (isPlainHostName(host)) return DIRECT;
    else return "PROXY 127.0.0.1:8080; PROXY 127.0.0.1:8081; DIRECT";
  }
`

func main() {
	pac, _ := gpac.New(scripts)

	r, _ := pac.FindProxyForURL("http://www.example.com/")
	fmt.Println(r) // returns PROXY 127.0.0.1:8080; PROXY 127.0.0.1:8081; DIRECT

	// Get issues request via a list of proxies and returns at the first request that succeeds
	resp, _ := pac.Get("http://www.example.com/")
	fmt.Println(resp.Status)
}

Simple wrapper for curl and wget

There's a simple tool that wraps curl and wget for pac file support.

Install

go get  github.com/darren/gpac/gpacw

Usage

gpacw wpad.dat curl -v http://example.com
gpacw http://wpad/wpad.dat wget -O /dev/null http://example.com

note url should be the last argument of the command or it will fail.

About

golang parser for pac file

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages