Documentation
¶
Overview ¶
Example ¶
package main
import (
"fmt"
"io/ioutil"
"os"
"github.com/kdanielm/gpac"
)
func main() {
pacf, _ := os.Open("testdata/wpad.dat")
defer pacf.Close()
data, _ := ioutil.ReadAll(pacf)
pac, _ := gpac.New(string(data))
r, _ := pac.FindProxyForURL("http://www.example.com/")
fmt.Println(r)
}
Output: PROXY 4.5.6.7:8080; PROXY 7.8.9.10:8080
Index ¶
- type Parser
- type Proxy
- func (p *Proxy) Client() *http.Client
- func (p *Proxy) Dialer() func(ctx context.Context, network, addr string) (net.Conn, error)
- func (p *Proxy) Do(req *http.Request) (*http.Response, error)
- func (p *Proxy) Get(urlstr string) (*http.Response, error)
- func (p *Proxy) Init()
- func (p *Proxy) IsDirect() bool
- func (p *Proxy) IsSOCKS() bool
- func (p *Proxy) Proxy() func(*http.Request) (*url.URL, error)
- func (p *Proxy) String() string
- func (p *Proxy) Transport() *http.Transport
- func (p *Proxy) URL() string
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Parser ¶
Parser the parsed pac instance
func (*Parser) Do ¶
Do sends an HTTP request via a list of proxies found it returns first HTTP response that succeeds
func (*Parser) FindProxyForURL ¶
FindProxyForURL finding proxy for url returns string like: PROXY 4.5.6.7:8080; PROXY 7.8.9.10:8080; DIRECT
type Proxy ¶
type Proxy struct {
Type string // Proxy type: PROXY HTTP HTTPS SOCKS DIRECT etc.
Address string // Proxy address
Username string // Proxy username
Password string // Proxy password
// contains filtered or unexported fields
}
Proxy is proxy type defined in pac file like PROXY 127.0.0.1:8080 SOCKS 127.0.0.1:1080
func ParseProxy ¶
ParseProxy parses proxy string returned by FindProxyForURL and returns a slice of proxies
Source Files
¶
Click to show internal directories.
Click to hide internal directories.