Documentation ¶
Overview ¶
Example (FindProxyForURL) ¶
FindProxyForURL example.
package main import ( "fmt" "io" "os" "github.com/saucelabs/pacman" ) func main() { pacf, _ := os.Open("resources/data.pac") defer pacf.Close() data, _ := io.ReadAll(pacf) pac, _ := pacman.New(string(data)) r, _ := pac.FindProxyForURL("http://www.example.com/") fmt.Println(r) }
Output: PROXY http://4.5.6.7:8080; PROXY https://4.5.6.7:8081; PROXY socks://4.5.6.7:8082; PROXY socks5://4.5.6.7:8083; PROXY quic://4.5.6.7:8084; PROXY 4.5.6.7:8085
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EqualLocalhost ¶ added in v0.0.10
Compares if two given URIs are "localhost".
func IsLocalhost ¶ added in v0.0.10
Checks if the given URI is "localhost".
Types ¶
type Parser ¶
Parser definition.
func New ¶
New is able to load PAC from many sources: - Direct: `textOrURI` is the PAC content - Remote: `textOrURI` is an HTTP/HTTPS URI - File: `textOrURI` points to a file:
- As per PAC spec, PAC file should have the `.pac` extension
- Absolute and relative paths are supported
- `file://` scheme is supported. IT SHOULD BE AN ABSOLUTE PATH:
- SEE: https://datatracker.ietf.org/doc/html/rfc1738#section-3.10
- SEE: https://datatracker.ietf.org/doc/html/draft-ietf-appsawg-file-scheme-03#section-2
Notes:
- Optionally, credentials for each/any proxy specified in the PAC content can be set (`proxiesURIs`) using standard URI format. These credentials will be automatically set when `FindProxy` is called.
- URI is: scheme://credential@host/path` where:
- `credential` is `username:password`, and is optional
- `host` is `hostname:port`, and is optional.
func (*Parser) FindProxy ¶
FindProxy for the given `url`, returning a list of `Proxies`.
Note: If the returned proxies requires credentials, and it was set when the Parser was created (`proxiesURIs`), it will be automatically added to the `Proxy`.
func (*Parser) FindProxyForURL ¶
FindProxyForURL for the given `url`, returning as string, example: "PROXY 4.5.6.7:8080; PROXY 7.8.9.10:8080; DIRECT".
type ProxiesCredentials ¶ added in v0.0.5
type ProxiesCredentials map[string]*credential.BasicAuth
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy definition.
func ParseProxy ¶
ParseProxy parses proxy string returned by `FindProxyForURL`, and returns a list of proxies.
func (*Proxy) GetAddress ¶ added in v0.0.5
GetAddress returns the original address parsed from PAC content. If type is `DIRECT`, returns empty.
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
credential
Package credential provides different types of credentials for authentication.
|
Package credential provides different types of credentials for authentication. |
validation
Package validation provides a singleton which allows validation of data across the application.
|
Package validation provides a singleton which allows validation of data across the application. |
pkg
|
|