This commit is contained in:
Denys Vitali 2022-05-03 13:20:20 +00:00 committed by GitHub
commit aecd21b294
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 1 deletions

2
go.mod
View File

@ -7,6 +7,8 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/protobuf v1.5.2
github.com/jhump/protoreflect v1.10.3
github.com/mwitkow/go-http-dialer v0.0.0-20161116154839-378f744fb2b8 // indirect
golang.org/x/net v0.0.0-20200822124328-c89045814202
golang.org/x/text v0.3.7 // indirect
google.golang.org/grpc v1.44.0
google.golang.org/protobuf v1.27.1

2
go.sum
View File

@ -116,6 +116,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/mwitkow/go-http-dialer v0.0.0-20161116154839-378f744fb2b8 h1:BhQQWYKJwXPtAhm12d4gQU4LKS9Yov22yOrDc2QA7ho=
github.com/mwitkow/go-http-dialer v0.0.0-20161116154839-378f744fb2b8/go.mod h1:ntWhh7pzdiiRKBMxUB5iG+Q2gmZBxGxpX1KyK6N8kX8=
github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt3d53pc1VYcphSCIaYAJtnPYnr3Zyn8fMq2wvPGPso=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=

View File

@ -14,8 +14,11 @@ import (
"encoding/base64"
"errors"
"fmt"
http_dialer "github.com/mwitkow/go-http-dialer"
"golang.org/x/net/proxy"
"io/ioutil"
"net"
"net/url"
"os"
"regexp"
"sort"
@ -638,7 +641,23 @@ func BlockingDial(ctx context.Context, network, address string, creds credential
// handshake). And that would mean that the library would send the
// wrong ":scheme" metaheader to servers: it would send "http" instead
// of "https" because it is unaware that TLS is actually in use.
conn, err := (&net.Dialer{}).DialContext(ctx, network, address)
// Use HTTPS_PROXY if it's set up:
if os.Getenv("HTTPS_PROXY") != "" {
proxyUrl, err := url.Parse(os.Getenv("HTTPS_PROXY"))
if err != nil {
panic("Invalid HTTPS_PROXY environment variable")
}
httpTunnel := http_dialer.New(proxyUrl)
conn, err := httpTunnel.Dial(network, address)
if err != nil {
writeResult(err)
}
return conn, err
}
conn, err := proxy.Dial(ctx, network, address)
if err != nil {
writeResult(err)
}