1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

Add feed option to disable HTTP/2 to avoid fingerprinting

This commit is contained in:
Frédéric Guillot 2024-02-24 22:08:23 -08:00
parent 420a3d4d95
commit eae4cb1417
36 changed files with 90 additions and 10 deletions

View file

@ -26,6 +26,7 @@ type RequestBuilder struct {
clientTimeout int
withoutRedirects bool
ignoreTLSErrors bool
disableHTTP2 bool
}
func NewRequestBuilder() *RequestBuilder {
@ -97,6 +98,11 @@ func (r *RequestBuilder) WithoutRedirects() *RequestBuilder {
return r
}
func (r *RequestBuilder) DisableHTTP2(value bool) *RequestBuilder {
r.disableHTTP2 = value
return r
}
func (r *RequestBuilder) IgnoreTLSErrors(value bool) *RequestBuilder {
r.ignoreTLSErrors = value
return r
@ -126,6 +132,14 @@ func (r *RequestBuilder) ExecuteRequest(requestURL string) (*http.Response, erro
},
}
if r.disableHTTP2 {
transport.ForceAttemptHTTP2 = false
// https://pkg.go.dev/net/http#hdr-HTTP_2
// Programs that must disable HTTP/2 can do so by setting [Transport.TLSNextProto] (for clients) or [Server.TLSNextProto] (for servers) to a non-nil, empty map.
transport.TLSNextProto = map[string]func(string, *tls.Conn) http.RoundTripper{}
}
if r.useClientProxy && r.clientProxyURL != "" {
if proxyURL, err := url.Parse(r.clientProxyURL); err != nil {
slog.Warn("Unable to parse proxy URL",
@ -165,6 +179,8 @@ func (r *RequestBuilder) ExecuteRequest(requestURL string) (*http.Response, erro
slog.Bool("without_redirects", r.withoutRedirects),
slog.Bool("with_proxy", r.useClientProxy),
slog.String("proxy_url", r.clientProxyURL),
slog.Bool("ignore_tls_errors", r.ignoreTLSErrors),
slog.Bool("disable_http2", r.disableHTTP2),
))
return client.Do(req)