Add response header timeouts to broker transports

The client and proxy use the net/http default transport to make round
trip connecitons to the broker. These by default don't time out and can
wait indefinitely for the broker to respond if the broker hangs and
doesn't terminate the connection.
This commit is contained in:
Cecylia Bocovich 2020-07-30 16:34:34 -04:00
parent 82031289a3
commit d5ae7562ac
2 changed files with 3 additions and 0 deletions

View file

@ -17,6 +17,7 @@ import (
"net/http"
"net/url"
"sync"
"time"
"git.torproject.org/pluggable-transports/snowflake.git/common/nat"
"git.torproject.org/pluggable-transports/snowflake.git/common/util"
@ -48,6 +49,7 @@ type BrokerChannel struct {
func CreateBrokerTransport() http.RoundTripper {
transport := http.DefaultTransport.(*http.Transport)
transport.Proxy = nil
transport.ResponseHeaderTimeout = 15 * time.Second
return transport
}