[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [obfs4/master] transports/meeklite: Apply http.DefaultTransport timeouts etc
commit 5d41c674f0fef708e187311ca2c3a6deba2d6cf2
Author: Yawning Angel <yawning@xxxxxxxxxxxxxxx>
Date: Sat Jan 26 15:13:06 2019 +0000
transports/meeklite: Apply http.DefaultTransport timeouts etc
---
transports/meeklite/transport.go | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/transports/meeklite/transport.go b/transports/meeklite/transport.go
index 59000a3..a6e1734 100644
--- a/transports/meeklite/transport.go
+++ b/transports/meeklite/transport.go
@@ -83,7 +83,7 @@ func (rt *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
func (rt *roundTripper) getTransport(req *http.Request) error {
switch strings.ToLower(req.URL.Scheme) {
case "http":
- rt.transport = &http.Transport{Dial: rt.dialFn}
+ rt.transport = newHTTPTransport(rt.dialFn, nil)
return nil
case "https":
default:
@@ -145,7 +145,7 @@ func (rt *roundTripper) dialTLS(network, addr string) (net.Conn, error) {
rt.transport = &http2.Transport{DialTLS: rt.dialTLSHTTP2}
default:
// Assume the remote peer is speaking HTTP 1.x + TLS.
- rt.transport = &http.Transport{DialTLS: rt.dialTLS}
+ rt.transport = newHTTPTransport(nil, rt.dialTLS)
}
// Stash the connection just established for use servicing the
@@ -190,6 +190,21 @@ func parseClientHelloID(s string) (*utls.ClientHelloID, error) {
return nil, fmt.Errorf("invalid ClientHelloID: '%v'", s)
}
+func newHTTPTransport(dialFn, dialTLSFn base.DialFunc) *http.Transport {
+ base := (http.DefaultTransport).(*http.Transport)
+
+ return &http.Transport{
+ Dial: dialFn,
+ DialTLS: dialTLSFn,
+
+ // Use default configuration values, taken from the runtime.
+ MaxIdleConns: base.MaxIdleConns,
+ IdleConnTimeout: base.IdleConnTimeout,
+ TLSHandshakeTimeout: base.TLSHandshakeTimeout,
+ ExpectContinueTimeout: base.ExpectContinueTimeout,
+ }
+}
+
func init() {
// Attempt to increase compatibility, there's an encrypted link
// underneath, and this doesn't (shouldn't) affect the external
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits