Skip to content

Commit

Permalink
Merge remote-tracking branch 'feature/feature/add-https-proxy'
Browse files Browse the repository at this point in the history
# Conflicts:
#	go.mod
#	go.sum
  • Loading branch information
Savely Krasovsky committed Sep 20, 2022
2 parents 8d60b61 + ea55023 commit 3698dc7
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion grpcurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 3698dc7

Please sign in to comment.