vendor: update all dependencies

This commit is contained in:
Nick Craig-Wood 2019-08-26 18:00:17 +01:00
parent d1a39dcc4b
commit af192d2507
232 changed files with 15744 additions and 1710 deletions

1
vendor/github.com/mattn/go-ieproxy/.gitignore generated vendored Normal file
View file

@ -0,0 +1 @@
.idea/*

11
vendor/github.com/mattn/go-ieproxy/GetProxyFunc.go generated vendored Normal file
View file

@ -0,0 +1,11 @@
package ieproxy
import (
"net/http"
"net/url"
)
// GetProxyFunc is a forwarder for the OS-Exclusive proxyMiddleman_os.go files
func GetProxyFunc() func(*http.Request) (*url.URL, error) {
return proxyMiddleman()
}

23
vendor/github.com/mattn/go-ieproxy/LICENSE generated vendored Normal file
View file

@ -0,0 +1,23 @@
MIT License
Copyright (c) 2014 mattn
Copyright (c) 2017 oliverpool
Copyright (c) 2019 Adele Reed
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

49
vendor/github.com/mattn/go-ieproxy/README.md generated vendored Normal file
View file

@ -0,0 +1,49 @@
# ieproxy
Go package to detect the proxy settings on Windows platform.
The settings are initially attempted to be read from the [`WinHttpGetIEProxyConfigForCurrentUser` DLL call](https://docs.microsoft.com/en-us/windows/desktop/api/winhttp/nf-winhttp-winhttpgetieproxyconfigforcurrentuser), but falls back to the registry (`CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings`) in the event the DLL call fails.
For more information, take a look at the [documentation](https://godoc.org/github.com/mattn/go-ieproxy)
## Methods
You can either obtain a `net/http` compatible proxy function using `ieproxy.GetProxyFunc()`, set environment variables using `ieproxy.OverrideEnvWithStaticProxy()` (though no automatic configuration is available this way), or obtain the proxy settings via `ieproxy.GetConf()`.
| Method | Supported configuration options: |
|----------------------------------------|-----------------------------------------------|
| `ieproxy.GetProxyFunc()` | Static, Specified script, and fully automatic |
| `ieproxy.OverrideEnvWithStaticProxy()` | Static |
| `ieproxy.GetConf()` | Depends on how you use it |
## Examples
### Using GetProxyFunc():
```go
func init() {
http.DefaultTransport.(*http.Transport).Proxy = ieproxy.GetProxyFunc()
}
```
GetProxyFunc acts as a middleman between `net/http` and `mattn/go-ieproxy` in order to select the correct proxy configuration based off the details supplied in the config.
### Using OverrideEnvWithStaticProxy():
```go
func init() {
ieproxy.OverrideEnvWithStaticProxy()
http.DefaultTransport.(*http.Transport).Proxy = http.ProxyFromEnvironment
}
```
OverrideEnvWithStaticProxy overrides the relevant environment variables (`HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY`) with the **static, manually configured** proxy details typically found in the registry.
### Using GetConf():
```go
func main() {
conf := ieproxy.GetConf()
//Handle proxies how you want to.
}
```

51
vendor/github.com/mattn/go-ieproxy/ieproxy.go generated vendored Normal file
View file

@ -0,0 +1,51 @@
// Package ieproxy is a utility to retrieve the proxy parameters (especially of Internet Explorer on windows)
//
// On windows, it gathers the parameters from the registry (regedit), while it uses env variable on other platforms
package ieproxy
import "os"
// ProxyConf gathers the configuration for proxy
type ProxyConf struct {
Static StaticProxyConf // static configuration
Automatic ProxyScriptConf // script configuration
}
// StaticProxyConf contains the configuration for static proxy
type StaticProxyConf struct {
// Is the proxy active?
Active bool
// Proxy address for each scheme (http, https)
// "" (empty string) is the fallback proxy
Protocols map[string]string
// Addresses not to be browsed via the proxy (comma-separated, linux-like)
NoProxy string
}
// ProxyScriptConf contains the configuration for automatic proxy
type ProxyScriptConf struct {
// Is the proxy active?
Active bool
// PreConfiguredURL of the .pac file.
// If this is empty and Active is true, auto-configuration should be assumed.
PreConfiguredURL string
}
// GetConf retrieves the proxy configuration from the Windows Regedit
func GetConf() ProxyConf {
return getConf()
}
// OverrideEnvWithStaticProxy writes new values to the
// `http_proxy`, `https_proxy` and `no_proxy` environment variables.
// The values are taken from the Windows Regedit (should be called in `init()` function - see example)
func OverrideEnvWithStaticProxy() {
overrideEnvWithStaticProxy(GetConf(), os.Setenv)
}
// FindProxyForURL computes the proxy for a given URL according to the pac file
func (psc *ProxyScriptConf) FindProxyForURL(URL string) string {
return psc.findProxyForURL(URL)
}
type envSetter func(string, string) error

10
vendor/github.com/mattn/go-ieproxy/ieproxy_unix.go generated vendored Normal file
View file

@ -0,0 +1,10 @@
// +build !windows
package ieproxy
func getConf() ProxyConf {
return ProxyConf{}
}
func overrideEnvWithStaticProxy(pc ProxyConf, setenv envSetter) {
}

164
vendor/github.com/mattn/go-ieproxy/ieproxy_windows.go generated vendored Normal file
View file

@ -0,0 +1,164 @@
package ieproxy
import (
"strings"
"sync"
"unsafe"
"golang.org/x/sys/windows/registry"
)
type regeditValues struct {
ProxyServer string
ProxyOverride string
ProxyEnable uint64
AutoConfigURL string
}
var once sync.Once
var windowsProxyConf ProxyConf
// GetConf retrieves the proxy configuration from the Windows Regedit
func getConf() ProxyConf {
once.Do(writeConf)
return windowsProxyConf
}
func writeConf() {
var (
cfg *tWINHTTP_CURRENT_USER_IE_PROXY_CONFIG
err error
)
if cfg, err = getUserConfigFromWindowsSyscall(); err != nil {
regedit, _ := readRegedit() // If the syscall fails, backup to manual detection.
windowsProxyConf = parseRegedit(regedit)
return
}
defer globalFreeWrapper(cfg.lpszProxy)
defer globalFreeWrapper(cfg.lpszProxyBypass)
defer globalFreeWrapper(cfg.lpszAutoConfigUrl)
windowsProxyConf = ProxyConf{
Static: StaticProxyConf{
Active: cfg.lpszProxy != nil,
},
Automatic: ProxyScriptConf{
Active: cfg.lpszAutoConfigUrl != nil || cfg.fAutoDetect,
},
}
if windowsProxyConf.Static.Active {
protocol := make(map[string]string)
for _, s := range strings.Split(StringFromUTF16Ptr(cfg.lpszProxy), ";") {
s = strings.TrimSpace(s)
if s == "" {
continue
}
pair := strings.SplitN(s, "=", 2)
if len(pair) > 1 {
protocol[pair[0]] = pair[1]
} else {
protocol[""] = pair[0]
}
}
windowsProxyConf.Static.Protocols = protocol
if cfg.lpszProxyBypass != nil {
windowsProxyConf.Static.NoProxy = strings.Replace(StringFromUTF16Ptr(cfg.lpszProxyBypass), ";", ",", -1)
}
}
if windowsProxyConf.Automatic.Active {
windowsProxyConf.Automatic.PreConfiguredURL = StringFromUTF16Ptr(cfg.lpszAutoConfigUrl)
}
}
func getUserConfigFromWindowsSyscall() (*tWINHTTP_CURRENT_USER_IE_PROXY_CONFIG, error) {
handle, _, err := winHttpOpen.Call(0, 0, 0, 0, 0)
if handle == 0 {
return &tWINHTTP_CURRENT_USER_IE_PROXY_CONFIG{}, err
}
defer winHttpCloseHandle.Call(handle)
config := new(tWINHTTP_CURRENT_USER_IE_PROXY_CONFIG)
ret, _, err := winHttpGetIEProxyConfigForCurrentUser.Call(uintptr(unsafe.Pointer(config)))
if ret > 0 {
err = nil
}
return config, err
}
// OverrideEnvWithStaticProxy writes new values to the
// http_proxy, https_proxy and no_proxy environment variables.
// The values are taken from the Windows Regedit (should be called in init() function)
func overrideEnvWithStaticProxy(conf ProxyConf, setenv envSetter) {
if conf.Static.Active {
for _, scheme := range []string{"http", "https"} {
url := mapFallback(scheme, "", conf.Static.Protocols)
setenv(scheme+"_proxy", url)
}
if conf.Static.NoProxy != "" {
setenv("no_proxy", conf.Static.NoProxy)
}
}
}
func parseRegedit(regedit regeditValues) ProxyConf {
protocol := make(map[string]string)
for _, s := range strings.Split(regedit.ProxyServer, ";") {
if s == "" {
continue
}
pair := strings.SplitN(s, "=", 2)
if len(pair) > 1 {
protocol[pair[0]] = pair[1]
} else {
protocol[""] = pair[0]
}
}
return ProxyConf{
Static: StaticProxyConf{
Active: regedit.ProxyEnable > 0,
Protocols: protocol,
NoProxy: strings.Replace(regedit.ProxyOverride, ";", ",", -1), // to match linux style
},
Automatic: ProxyScriptConf{
Active: regedit.AutoConfigURL != "",
PreConfiguredURL: regedit.AutoConfigURL,
},
}
}
func readRegedit() (values regeditValues, err error) {
k, err := registry.OpenKey(registry.CURRENT_USER, `Software\Microsoft\Windows\CurrentVersion\Internet Settings`, registry.QUERY_VALUE)
if err != nil {
return
}
defer k.Close()
values.ProxyServer, _, err = k.GetStringValue("ProxyServer")
if err != nil && err != registry.ErrNotExist {
return
}
values.ProxyOverride, _, err = k.GetStringValue("ProxyOverride")
if err != nil && err != registry.ErrNotExist {
return
}
values.ProxyEnable, _, err = k.GetIntegerValue("ProxyEnable")
if err != nil && err != registry.ErrNotExist {
return
}
values.AutoConfigURL, _, err = k.GetStringValue("AutoConfigURL")
if err != nil && err != registry.ErrNotExist {
return
}
err = nil
return
}

View file

@ -0,0 +1,15 @@
package ieproxy
import (
"golang.org/x/sys/windows"
"unsafe"
)
var kernel32 = windows.NewLazySystemDLL("kernel32.dll")
var globalFree = kernel32.NewProc("GlobalFree")
func globalFreeWrapper(ptr *uint16) {
if ptr != nil {
_, _, _ = globalFree.Call(uintptr(unsafe.Pointer(ptr)))
}
}

7
vendor/github.com/mattn/go-ieproxy/pac_unix.go generated vendored Normal file
View file

@ -0,0 +1,7 @@
// +build !windows
package ieproxy
func (psc *ProxyScriptConf) findProxyForURL(URL string) string {
return ""
}

72
vendor/github.com/mattn/go-ieproxy/pac_windows.go generated vendored Normal file
View file

@ -0,0 +1,72 @@
package ieproxy
import (
"strings"
"syscall"
"unsafe"
)
func (psc *ProxyScriptConf) findProxyForURL(URL string) string {
if !psc.Active {
return ""
}
proxy, _ := getProxyForURL(psc.PreConfiguredURL, URL)
i := strings.Index(proxy, ";")
if i >= 0 {
return proxy[:i]
}
return proxy
}
func getProxyForURL(pacfileURL, URL string) (string, error) {
pacfileURLPtr, err := syscall.UTF16PtrFromString(pacfileURL)
if err != nil {
return "", err
}
URLPtr, err := syscall.UTF16PtrFromString(URL)
if err != nil {
return "", err
}
handle, _, err := winHttpOpen.Call(0, 0, 0, 0, 0)
if handle == 0 {
return "", err
}
defer winHttpCloseHandle.Call(handle)
dwFlags := fWINHTTP_AUTOPROXY_CONFIG_URL
dwAutoDetectFlags := autoDetectFlag(0)
pfURLptr := pacfileURLPtr
if pacfileURL == "" {
dwFlags = fWINHTTP_AUTOPROXY_AUTO_DETECT
dwAutoDetectFlags = fWINHTTP_AUTO_DETECT_TYPE_DNS_A | fWINHTTP_AUTO_DETECT_TYPE_DHCP
pfURLptr = nil
}
options := tWINHTTP_AUTOPROXY_OPTIONS{
dwFlags: dwFlags, // adding cache might cause issues: https://github.com/mattn/go-ieproxy/issues/6
dwAutoDetectFlags: dwAutoDetectFlags,
lpszAutoConfigUrl: pfURLptr,
lpvReserved: nil,
dwReserved: 0,
fAutoLogonIfChallenged: true, // may not be optimal https://msdn.microsoft.com/en-us/library/windows/desktop/aa383153(v=vs.85).aspx
} // lpszProxyBypass isn't used as this only executes in cases where there (may) be a pac file (autodetect can fail), where lpszProxyBypass couldn't be returned.
// in the case that autodetect fails and no pre-specified pacfile is present, no proxy is returned.
info := new(tWINHTTP_PROXY_INFO)
ret, _, err := winHttpGetProxyForURL.Call(
handle,
uintptr(unsafe.Pointer(URLPtr)),
uintptr(unsafe.Pointer(&options)),
uintptr(unsafe.Pointer(info)),
)
if ret > 0 {
err = nil
}
defer globalFreeWrapper(info.lpszProxyBypass)
defer globalFreeWrapper(info.lpszProxy)
return StringFromUTF16Ptr(info.lpszProxy), err
}

View file

@ -0,0 +1,13 @@
// +build !windows
package ieproxy
import (
"net/http"
"net/url"
)
func proxyMiddleman() func(req *http.Request) (i *url.URL, e error) {
// Fallthrough to ProxyFromEnvironment on all other OSes.
return http.ProxyFromEnvironment
}

View file

@ -0,0 +1,52 @@
package ieproxy
import (
"net/http"
"net/url"
"golang.org/x/net/http/httpproxy"
)
func proxyMiddleman() func(req *http.Request) (i *url.URL, e error) {
// Get the proxy configuration
conf := GetConf()
envcfg := httpproxy.FromEnvironment()
if envcfg.HTTPProxy != "" || envcfg.HTTPSProxy != "" {
// If the user manually specifies environment variables, prefer those over the Windows config.
return http.ProxyFromEnvironment
}
return func(req *http.Request) (i *url.URL, e error) {
if conf.Automatic.Active {
host := conf.Automatic.FindProxyForURL(req.URL.String())
if host != "" {
return &url.URL{Host: host}, nil
}
}
if conf.Static.Active {
return staticProxy(conf, req)
}
// Should return no proxy; fallthrough.
return http.ProxyFromEnvironment(req)
}
}
func staticProxy(conf ProxyConf, req *http.Request) (i *url.URL, e error) {
// If static proxy obtaining is specified
prox := httpproxy.Config{
HTTPSProxy: mapFallback("https", "", conf.Static.Protocols),
HTTPProxy: mapFallback("http", "", conf.Static.Protocols),
NoProxy: conf.Static.NoProxy,
}
return prox.ProxyFunc()(req.URL)
}
// Return oKey or fbKey if oKey doesn't exist in the map.
func mapFallback(oKey, fbKey string, m map[string]string) string {
if v, ok := m[oKey]; ok {
return v
} else {
return m[fbKey]
}
}

23
vendor/github.com/mattn/go-ieproxy/utils.go generated vendored Normal file
View file

@ -0,0 +1,23 @@
package ieproxy
import (
"unicode/utf16"
"unsafe"
)
// StringFromUTF16Ptr converts a *uint16 C string to a Go String
func StringFromUTF16Ptr(s *uint16) string {
if s == nil {
return ""
}
p := (*[1<<30 - 1]uint16)(unsafe.Pointer(s))
// find the string length
sz := 0
for p[sz] != 0 {
sz++
}
return string(utf16.Decode(p[:sz:sz]))
}

View file

@ -0,0 +1,50 @@
package ieproxy
import "golang.org/x/sys/windows"
var winHttp = windows.NewLazySystemDLL("winhttp.dll")
var winHttpGetProxyForURL = winHttp.NewProc("WinHttpGetProxyForUrl")
var winHttpOpen = winHttp.NewProc("WinHttpOpen")
var winHttpCloseHandle = winHttp.NewProc("WinHttpCloseHandle")
var winHttpGetIEProxyConfigForCurrentUser = winHttp.NewProc("WinHttpGetIEProxyConfigForCurrentUser")
type tWINHTTP_AUTOPROXY_OPTIONS struct {
dwFlags autoProxyFlag
dwAutoDetectFlags autoDetectFlag
lpszAutoConfigUrl *uint16
lpvReserved *uint16
dwReserved uint32
fAutoLogonIfChallenged bool
}
type autoProxyFlag uint32
const (
fWINHTTP_AUTOPROXY_AUTO_DETECT = autoProxyFlag(0x00000001)
fWINHTTP_AUTOPROXY_CONFIG_URL = autoProxyFlag(0x00000002)
fWINHTTP_AUTOPROXY_NO_CACHE_CLIENT = autoProxyFlag(0x00080000)
fWINHTTP_AUTOPROXY_NO_CACHE_SVC = autoProxyFlag(0x00100000)
fWINHTTP_AUTOPROXY_NO_DIRECTACCESS = autoProxyFlag(0x00040000)
fWINHTTP_AUTOPROXY_RUN_INPROCESS = autoProxyFlag(0x00010000)
fWINHTTP_AUTOPROXY_RUN_OUTPROCESS_ONLY = autoProxyFlag(0x00020000)
fWINHTTP_AUTOPROXY_SORT_RESULTS = autoProxyFlag(0x00400000)
)
type autoDetectFlag uint32
const (
fWINHTTP_AUTO_DETECT_TYPE_DHCP = autoDetectFlag(0x00000001)
fWINHTTP_AUTO_DETECT_TYPE_DNS_A = autoDetectFlag(0x00000002)
)
type tWINHTTP_PROXY_INFO struct {
dwAccessType uint32
lpszProxy *uint16
lpszProxyBypass *uint16
}
type tWINHTTP_CURRENT_USER_IE_PROXY_CONFIG struct {
fAutoDetect bool
lpszAutoConfigUrl *uint16
lpszProxy *uint16
lpszProxyBypass *uint16
}