From 74ee3746679ad796213b61b9e58c514ed90f0513 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 28 Aug 2020 21:37:49 -0700 Subject: [PATCH] net/tshttpproxy: add more winhttp logging Notably around duration of calls. --- net/tshttpproxy/tshttpproxy_windows.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/tshttpproxy/tshttpproxy_windows.go b/net/tshttpproxy/tshttpproxy_windows.go index 53df50ae6..96d2e4154 100644 --- a/net/tshttpproxy/tshttpproxy_windows.go +++ b/net/tshttpproxy/tshttpproxy_windows.go @@ -12,6 +12,7 @@ "net/url" "strings" "syscall" + "time" "unsafe" "github.com/alexbrainman/sspi/negotiate" @@ -44,14 +45,19 @@ func proxyFromWinHTTP(req *http.Request) (*url.URL, error) { } defer whi.Close() + t0 := time.Now() v, err := whi.GetProxyForURL(urlStr) + td := time.Since(t0) + if td >= 250*time.Millisecond { + log.Printf("tshttpproxy: winhttp: GetProxyForURL(%q) = len %d, %v (after %v)", urlStr, len(v), err, td.Round(time.Millisecond)) + } if err != nil { // See https://docs.microsoft.com/en-us/windows/win32/winhttp/error-messages const ERROR_WINHTTP_AUTODETECTION_FAILED = 12180 if err == syscall.Errno(ERROR_WINHTTP_AUTODETECTION_FAILED) { return nil, nil } - log.Printf("winhttp: GetProxyForURL(%q): %v (%T, %#v)", urlStr, err, err, err) + log.Printf("tshttpproxy: winhttp: GetProxyForURL(%q): %v (%T, %#v)", urlStr, err, err, err) return nil, nil } if v != "" {