No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Emmanuel Briney 9bf2ab8214
Merge pull request #1 from ebriney/fix-myipaddress-udp-dial
udp dial to non-existing external IP to find myIPAddress
2026-07-10 10:53:53 +02:00
gpacw add a simple wrapper for curl and wget 2019-01-24 21:19:31 +08:00
testdata first commit 2019-01-24 17:44:35 +08:00
.editorconfig use 4 space indentation 2019-01-25 01:10:59 +08:00
builtin_functions.go first commit 2019-01-24 17:44:35 +08:00
builtin_natives.go udp dial to non-existing external IP to find myIPAddress 2026-07-09 16:58:02 +02:00
go.mod upgrade goja 2021-06-09 15:22:16 +08:00
go.sum upgrade goja 2021-06-09 15:22:16 +08:00
LICENSE first commit 2019-01-24 17:44:35 +08:00
parser.go auth support 2021-06-09 16:28:04 +08:00
parser_test.go use runtime from arguments 2020-07-02 10:08:54 +08:00
proxy.go auth support 2021-06-09 16:28:04 +08:00
proxy_test.go adding a test for socks5 proxy 2019-02-02 10:07:19 +08:00
Readme.md fix badge 2020-12-09 12:04:25 +08:00
socks.go Added Dialer and supports socks5 2019-02-02 04:36:21 +08:00

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.