Skip to content

Commit

Permalink
rr_dns
Browse files Browse the repository at this point in the history
rr_dns
  • Loading branch information
jiuker committed Jul 7, 2024
1 parent 55054df commit f8e52c9
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,12 @@ func newProxyDialContext(dialTimeout time.Duration) DialContext {
// tlsClientSessionCacheSize is the cache size for TLS client sessions.
const tlsClientSessionCacheSize = 100

func clientTransport(ctx *cli.Context, enableTLS bool) http.RoundTripper {
type RoundTripperWrapper struct {

Check failure on line 638 in main.go

View workflow job for this annotation

GitHub Actions / Test on Go 1.22.x and ubuntu-latest

exported: exported type RoundTripperWrapper should have comment or be unexported (revive)
enableTLS bool
ctx *cli.Context
}

func (rtw *RoundTripperWrapper) RoundTrip(req *http.Request) (*http.Response, error) {

Check failure on line 643 in main.go

View workflow job for this annotation

GitHub Actions / Test on Go 1.22.x and ubuntu-latest

exported: exported method RoundTripperWrapper.RoundTrip should have comment or be unexported (revive)
tr := &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: dialContextWithDNSCache(dnsCache, newProxyDialContext(10*time.Second)),
Expand All @@ -654,12 +659,12 @@ func clientTransport(ctx *cli.Context, enableTLS bool) http.RoundTripper {
DisableCompression: true,
}

if enableTLS {
if rtw.enableTLS {
// Keep TLS config.
tr.TLSClientConfig = &tls.Config{
RootCAs: getCertPool(ctx.GlobalString("cacert")),
Certificates: getCertKeyPair(ctx.GlobalString("client-cert"), ctx.GlobalString("client-key")),
InsecureSkipVerify: ctx.GlobalBool("insecure"),
RootCAs: getCertPool(rtw.ctx.GlobalString("cacert")),
Certificates: getCertKeyPair(rtw.ctx.GlobalString("client-cert"), rtw.ctx.GlobalString("client-key")),
InsecureSkipVerify: rtw.ctx.GlobalBool("insecure"),
// Can't use SSLv3 because of POODLE and BEAST
// Can't use TLSv1.0 because of POODLE and BEAST using CBC cipher
// Can't use TLSv1.1 because of RC4 cipher usage
Expand All @@ -668,8 +673,11 @@ func clientTransport(ctx *cli.Context, enableTLS bool) http.RoundTripper {
ClientSessionCache: tls.NewLRUClientSessionCache(tlsClientSessionCacheSize),
}
}
return tr.RoundTrip(req)
}

return tr
func clientTransport(ctx *cli.Context, enableTLS bool) http.RoundTripper {
return &RoundTripperWrapper{ctx: ctx, enableTLS: enableTLS}
}

func checkMain(ctx *cli.Context) {
Expand Down

0 comments on commit f8e52c9

Please sign in to comment.