1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-15 18:57:04 +00:00

feat: add proxy rotation functionality

This commit is contained in:
Frédéric Guillot 2025-04-06 14:45:56 -07:00
parent d20e8a4e2c
commit 535fd050b7
22 changed files with 351 additions and 56 deletions

View file

@ -12,6 +12,7 @@ import (
"miniflux.app/v2/internal/http/route"
"miniflux.app/v2/internal/locale"
"miniflux.app/v2/internal/model"
"miniflux.app/v2/internal/proxyrotator"
"miniflux.app/v2/internal/reader/fetcher"
feedHandler "miniflux.app/v2/internal/reader/handler"
"miniflux.app/v2/internal/reader/subscription"
@ -41,7 +42,7 @@ func (h *handler) submitSubscription(w http.ResponseWriter, r *http.Request) {
v.Set("countUnread", h.store.CountUnreadEntries(user.ID))
v.Set("countErrorFeeds", h.store.CountUserFeedsWithErrors(user.ID))
v.Set("defaultUserAgent", config.Opts.HTTPClientUserAgent())
v.Set("hasProxyConfigured", config.Opts.HasHTTPClientProxyConfigured())
v.Set("hasProxyConfigured", config.Opts.HasHTTPClientProxyURLConfigured())
subscriptionForm := form.NewSubscriptionForm(r)
if validationErr := subscriptionForm.Validate(); validationErr != nil {
@ -58,11 +59,12 @@ func (h *handler) submitSubscription(w http.ResponseWriter, r *http.Request) {
requestBuilder := fetcher.NewRequestBuilder()
requestBuilder.WithTimeout(config.Opts.HTTPClientTimeout())
requestBuilder.WithProxy(config.Opts.HTTPClientProxy())
requestBuilder.WithProxyRotator(proxyrotator.ProxyRotatorInstance)
requestBuilder.WithCustomApplicationProxyURL(config.Opts.HTTPClientProxyURL())
requestBuilder.UseCustomApplicationProxyURL(subscriptionForm.FetchViaProxy)
requestBuilder.WithUserAgent(subscriptionForm.UserAgent, config.Opts.HTTPClientUserAgent())
requestBuilder.WithCookie(subscriptionForm.Cookie)
requestBuilder.WithUsernameAndPassword(subscriptionForm.Username, subscriptionForm.Password)
requestBuilder.UseProxy(subscriptionForm.FetchViaProxy)
requestBuilder.IgnoreTLSErrors(subscriptionForm.AllowSelfSignedCertificates)
requestBuilder.DisableHTTP2(subscriptionForm.DisableHTTP2)
@ -149,7 +151,7 @@ func (h *handler) submitSubscription(w http.ResponseWriter, r *http.Request) {
view.Set("user", user)
view.Set("countUnread", h.store.CountUnreadEntries(user.ID))
view.Set("countErrorFeeds", h.store.CountUserFeedsWithErrors(user.ID))
view.Set("hasProxyConfigured", config.Opts.HasHTTPClientProxyConfigured())
view.Set("hasProxyConfigured", config.Opts.HasHTTPClientProxyURLConfigured())
html.OK(w, r, view.Render("choose_subscription"))
}