]> Sergey Matveev's repositories - godlighty.git/commitdiff
Ability to disable HTTP/2
authorSergey Matveev <stargrave@stargrave.org>
Wed, 8 Oct 2025 08:40:02 +0000 (11:40 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 8 Oct 2025 08:40:12 +0000 (11:40 +0300)
cmd/godlighty/main.go
godlighty.go
tls.go

index 5ca038034f3369e278534acbced0d342ca3429eb..6cbba08be95038cbd6840c442c6817e1db88c5ab 100644 (file)
@@ -46,6 +46,7 @@ var (
 func main() {
        bind := flag.String("bind", "[::]:80", "Address to bind and listen on")
        doTLS := flag.Bool("tls", false, "Enable TLS")
+       noH2 := flag.Bool("no-h2", false, "Disable HTTP/2")
        doSetUID := flag.Int("setuid", 0, "Set that UID after binding the socket")
        doSetGID := flag.Int("setgid", 0, "Set that GID after binding the socket")
        doSetGIDs := flag.String("setgids", "", "Comma-separated GIDs to set")
@@ -108,6 +109,15 @@ func main() {
                Handler:           godlighty.MainHandler,
                ReadHeaderTimeout: RWTimeout,
                IdleTimeout:       time.Minute,
+               Protocols:         &http.Protocols{},
+       }
+       srv.Protocols.SetHTTP1(true)
+       if *noH2 {
+               godlighty.NextProtos = []string{"http/1.1"}
+       } else {
+               godlighty.NextProtos = []string{"h2", "http/1.1"}
+               srv.Protocols.SetHTTP2(true)
+               srv.Protocols.SetUnencryptedHTTP2(true)
        }
        go func() {
                <-shutdown
index 895b10cb4d7223cbb4b8c8a371fe9834e4750269..834266e3dd9cbad9fcee1728483bb3cef0717bf7 100644 (file)
@@ -1,6 +1,6 @@
 // Highly-customizable HTTP, HTTP/2, HTTPS server
 package godlighty
 
-const Version = "godlighty/0.9.0"
+const Version = "godlighty/0.10.0"
 
 var BindAddr string
diff --git a/tls.go b/tls.go
index 7ccc8f7664656914ca68e7b414a0345c2115cf1b..e42b06f3d21f308e110a2aeb76e7d4975453fee2 100644 (file)
--- a/tls.go
+++ b/tls.go
@@ -27,7 +27,7 @@ import (
 )
 
 var (
-       NextProtos = []string{"h2", "http/1.1"}
+       NextProtos []string
 
        HostToECDSACertificate map[string]*tls.Certificate
        HostECDSAClientAuth    map[string]*x509.CertPool