@@ -36,6 +36,8 @@ import (
36
36
"github.com/google/fleetspeak/fleetspeak/src/client/comms"
37
37
"github.com/google/fleetspeak/fleetspeak/src/client/stats"
38
38
"github.com/google/fleetspeak/fleetspeak/src/common"
39
+
40
+ "golang.org/x/net/http2"
39
41
)
40
42
41
43
const (
@@ -92,7 +94,17 @@ func makeTransport(cctx comms.Context, dc func(ctx context.Context, network, add
92
94
proxy = http .ProxyURL (si .Proxy )
93
95
}
94
96
95
- return ci .ID , & http.Transport {
97
+ // We'll make the Transport configurable so we can be both backwards compatible but also forward looking
98
+ nextProtos := []string {"http/1.1" }
99
+ preferHttp2 := false
100
+ if cctx .CommunicatorConfig () != nil {
101
+ preferHttp2 = cctx .CommunicatorConfig ().PreferHttp2
102
+ }
103
+ if preferHttp2 {
104
+ nextProtos = []string {"h2" , "http/1.1" }
105
+ }
106
+
107
+ tr := & http.Transport {
96
108
Proxy : proxy ,
97
109
TLSClientConfig : & tls.Config {
98
110
RootCAs : si .TrustedCerts ,
@@ -110,12 +122,18 @@ func makeTransport(cctx comms.Context, dc func(ctx context.Context, network, add
110
122
tls .TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 },
111
123
VerifyPeerCertificate : cv ,
112
124
ServerName : si .ServerName ,
125
+ NextProtos : nextProtos ,
113
126
},
114
127
MaxIdleConns : 10 ,
115
128
DialContext : dc ,
116
129
TLSHandshakeTimeout : 10 * time .Second ,
117
130
ExpectContinueTimeout : 1 * time .Second ,
118
- }, certBytes , nil
131
+ }
132
+
133
+ if preferHttp2 {
134
+ err = http2 .ConfigureTransport (tr )
135
+ }
136
+ return ci .ID , tr , certBytes , err
119
137
}
120
138
121
139
// jitter adds up to 50% random jitter, and converts to time.Duration.
0 commit comments