From 20c559870ac6a97835b5d45255206e1d04e98954 Mon Sep 17 00:00:00 2001 From: fatedier Date: Mon, 8 Jul 2024 17:50:36 +0800 Subject: [PATCH] Disable HTTP/2 by default for the plugins https2http and https2https, and make it configurable. --- Release.md | 4 ++++ pkg/config/v1/plugin.go | 2 ++ pkg/plugin/client/https2http.go | 3 +++ pkg/plugin/client/https2https.go | 3 +++ pkg/util/version/version.go | 2 +- 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Release.md b/Release.md index 2dcfc566..7bde55c6 100644 --- a/Release.md +++ b/Release.md @@ -1,3 +1,7 @@ ### Features * Added a new plugin "http2http" which allows forwarding HTTP requests to another HTTP server, supporting options like local address binding, host header rewrite, and custom request headers. + +### Changes + +* Disable HTTP/2 by default for the plugins https2http and https2https, and make it configurable. diff --git a/pkg/config/v1/plugin.go b/pkg/config/v1/plugin.go index 333b020a..d3c2ec69 100644 --- a/pkg/config/v1/plugin.go +++ b/pkg/config/v1/plugin.go @@ -108,6 +108,7 @@ type HTTPS2HTTPPluginOptions struct { LocalAddr string `json:"localAddr,omitempty"` HostHeaderRewrite string `json:"hostHeaderRewrite,omitempty"` RequestHeaders HeaderOperations `json:"requestHeaders,omitempty"` + EnableHTTP2 bool `json:"enableHTTP2,omitempty"` CrtPath string `json:"crtPath,omitempty"` KeyPath string `json:"keyPath,omitempty"` } @@ -117,6 +118,7 @@ type HTTPS2HTTPSPluginOptions struct { LocalAddr string `json:"localAddr,omitempty"` HostHeaderRewrite string `json:"hostHeaderRewrite,omitempty"` RequestHeaders HeaderOperations `json:"requestHeaders,omitempty"` + EnableHTTP2 bool `json:"enableHTTP2,omitempty"` CrtPath string `json:"crtPath,omitempty"` KeyPath string `json:"keyPath,omitempty"` } diff --git a/pkg/plugin/client/https2http.go b/pkg/plugin/client/https2http.go index 6d686361..d2e2be17 100644 --- a/pkg/plugin/client/https2http.go +++ b/pkg/plugin/client/https2http.go @@ -91,6 +91,9 @@ func NewHTTPS2HTTPPlugin(options v1.ClientPluginOptions) (Plugin, error) { ReadHeaderTimeout: 60 * time.Second, TLSConfig: tlsConfig, } + if !opts.EnableHTTP2 { + p.s.TLSNextProto = make(map[string]func(*http.Server, *tls.Conn, http.Handler)) + } go func() { _ = p.s.ServeTLS(listener, "", "") diff --git a/pkg/plugin/client/https2https.go b/pkg/plugin/client/https2https.go index 5ddd4dd6..785a13d6 100644 --- a/pkg/plugin/client/https2https.go +++ b/pkg/plugin/client/https2https.go @@ -97,6 +97,9 @@ func NewHTTPS2HTTPSPlugin(options v1.ClientPluginOptions) (Plugin, error) { ReadHeaderTimeout: 60 * time.Second, TLSConfig: tlsConfig, } + if !opts.EnableHTTP2 { + p.s.TLSNextProto = make(map[string]func(*http.Server, *tls.Conn, http.Handler)) + } go func() { _ = p.s.ServeTLS(listener, "", "") diff --git a/pkg/util/version/version.go b/pkg/util/version/version.go index 11d140eb..561a52e7 100644 --- a/pkg/util/version/version.go +++ b/pkg/util/version/version.go @@ -14,7 +14,7 @@ package version -var version = "0.58.1" +var version = "0.59.0" func Full() string { return version