Disable HTTP/2 by default, do not use keepalive without http/2
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
DataHoarder 2022-01-18 10:16:11 +01:00
parent f73903d216
commit 307cc934bc

View file

@ -772,6 +772,8 @@ func main() {
debugOption := flag.Bool("debug", false, "Output debug information.") debugOption := flag.Bool("debug", false, "Output debug information.")
http2Option := flag.Bool("http3", false, "Enable HTTP/2")
http3Option := flag.Bool("http3", false, "Enable HTTP/3") http3Option := flag.Bool("http3", false, "Enable HTTP/3")
signatureCacheLimitOption := flag.Int("siglimit", 4096, "Maximum number of lingering valid signature cache results.") signatureCacheLimitOption := flag.Int("siglimit", 4096, "Maximum number of lingering valid signature cache results.")
@ -872,7 +874,6 @@ func main() {
SessionTicketsDisabled: false, SessionTicketsDisabled: false,
Renegotiation: tls.RenegotiateFreelyAsClient, Renegotiation: tls.RenegotiateFreelyAsClient,
NextProtos: []string{ NextProtos: []string{
"h2",
"http/1.1", "http/1.1",
}, },
GetCertificate: func(info *tls.ClientHelloInfo) (*tls.Certificate, error) { GetCertificate: func(info *tls.ClientHelloInfo) (*tls.Certificate, error) {
@ -883,6 +884,15 @@ func main() {
}, },
} }
if *http2Option {
tlsConfig.NextProtos = []string{
"h2",
"http/1.1",
}
} else {
extraHeaders["Connection"] = "Close"
}
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(1) wg.Add(1)
@ -897,14 +907,16 @@ func main() {
}, },
NoDefaultServerHeader: true, NoDefaultServerHeader: true,
NoDefaultDate: true, NoDefaultDate: true,
DisableKeepalive: false, DisableKeepalive: !*http2Option,
TCPKeepalive: true, TCPKeepalive: *http2Option,
TLSConfig: tlsConfig, TLSConfig: tlsConfig,
} }
http2.ConfigureServer(server, http2.ServerConfig{ if *http2Option {
Debug: false, http2.ConfigureServer(server, http2.ServerConfig{
}) Debug: false,
})
}
log.Printf("Serving TCP on %s", *listenAddress) log.Printf("Serving TCP on %s", *listenAddress)
ln, err := net.Listen("tcp", *listenAddress) ln, err := net.Listen("tcp", *listenAddress)