1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-26 18:21:01 +00:00

feat: implement proxy URL per feed

This commit is contained in:
Frédéric Guillot 2025-04-06 18:04:50 -07:00
parent c45b51d1f8
commit d17f8a7bfa
48 changed files with 333 additions and 192 deletions

View file

@ -70,6 +70,7 @@ func (h *handler) showEditFeedPage(w http.ResponseWriter, r *http.Request) {
NtfyTopic: feed.NtfyTopic,
PushoverEnabled: feed.PushoverEnabled,
PushoverPriority: feed.PushoverPriority,
ProxyURL: feed.ProxyURL,
}
sess := session.New(h.store, request.SessionID(r))

View file

@ -64,6 +64,7 @@ func (h *handler) updateFeed(w http.ResponseWriter, r *http.Request) {
BlocklistRules: model.OptionalString(feedForm.BlocklistRules),
KeeplistRules: model.OptionalString(feedForm.KeeplistRules),
UrlRewriteRules: model.OptionalString(feedForm.UrlRewriteRules),
ProxyURL: model.OptionalString(feedForm.ProxyURL),
}
if validationErr := validator.ValidateFeedModification(h.store, loggedUser.ID, feed.ID, feedModificationRequest); validationErr != nil {

View file

@ -42,6 +42,7 @@ type FeedForm struct {
NtfyTopic string
PushoverEnabled bool
PushoverPriority int
ProxyURL string
}
// Merge updates the fields of the given feed.
@ -77,6 +78,7 @@ func (f FeedForm) Merge(feed *model.Feed) *model.Feed {
feed.NtfyTopic = f.NtfyTopic
feed.PushoverEnabled = f.PushoverEnabled
feed.PushoverPriority = f.PushoverPriority
feed.ProxyURL = f.ProxyURL
return feed
}
@ -86,6 +88,7 @@ func NewFeedForm(r *http.Request) *FeedForm {
if err != nil {
categoryID = 0
}
ntfyPriority, err := strconv.Atoi(r.FormValue("ntfy_priority"))
if err != nil {
ntfyPriority = 0
@ -126,5 +129,6 @@ func NewFeedForm(r *http.Request) *FeedForm {
NtfyTopic: r.FormValue("ntfy_topic"),
PushoverEnabled: r.FormValue("pushover_enabled") == "1",
PushoverPriority: pushoverPriority,
ProxyURL: r.FormValue("proxy_url"),
}
}

View file

@ -28,6 +28,7 @@ type SubscriptionForm struct {
KeeplistRules string
UrlRewriteRules string
DisableHTTP2 bool
ProxyURL string
}
// Validate makes sure the form values locale.are valid.
@ -52,6 +53,10 @@ func (s *SubscriptionForm) Validate() *locale.LocalizedError {
return locale.NewLocalizedError("error.feed_invalid_urlrewrite_rule")
}
if s.ProxyURL != "" && !validator.IsValidURL(s.ProxyURL) {
return locale.NewLocalizedError("error.invalid_feed_proxy_url")
}
return nil
}
@ -78,5 +83,6 @@ func NewSubscriptionForm(r *http.Request) *SubscriptionForm {
KeeplistRules: r.FormValue("keeplist_rules"),
UrlRewriteRules: r.FormValue("urlrewrite_rules"),
DisableHTTP2: r.FormValue("disable_http2") == "1",
ProxyURL: r.FormValue("proxy_url"),
}
}

View file

@ -97,7 +97,6 @@ func (h *handler) fetchOPML(w http.ResponseWriter, r *http.Request) {
requestBuilder := fetcher.NewRequestBuilder()
requestBuilder.WithTimeout(config.Opts.HTTPClientTimeout())
requestBuilder.WithProxyRotator(proxyrotator.ProxyRotatorInstance)
requestBuilder.WithCustomApplicationProxyURL(config.Opts.HTTPClientProxyURL())
responseHandler := fetcher.NewResponseHandler(requestBuilder.ExecuteRequest(opmlFileURL))
defer responseHandler.Close()

View file

@ -63,6 +63,7 @@ func (h *handler) showChooseSubscriptionPage(w http.ResponseWriter, r *http.Requ
UrlRewriteRules: subscriptionForm.UrlRewriteRules,
FetchViaProxy: subscriptionForm.FetchViaProxy,
DisableHTTP2: subscriptionForm.DisableHTTP2,
ProxyURL: subscriptionForm.ProxyURL,
})
if localizedError != nil {
view.Set("form", subscriptionForm)

View file

@ -60,6 +60,7 @@ func (h *handler) submitSubscription(w http.ResponseWriter, r *http.Request) {
requestBuilder := fetcher.NewRequestBuilder()
requestBuilder.WithTimeout(config.Opts.HTTPClientTimeout())
requestBuilder.WithProxyRotator(proxyrotator.ProxyRotatorInstance)
requestBuilder.WithCustomFeedProxyURL(subscriptionForm.ProxyURL)
requestBuilder.WithCustomApplicationProxyURL(config.Opts.HTTPClientProxyURL())
requestBuilder.UseCustomApplicationProxyURL(subscriptionForm.FetchViaProxy)
requestBuilder.WithUserAgent(subscriptionForm.UserAgent, config.Opts.HTTPClientUserAgent())
@ -107,6 +108,7 @@ func (h *handler) submitSubscription(w http.ResponseWriter, r *http.Request) {
UrlRewriteRules: subscriptionForm.UrlRewriteRules,
FetchViaProxy: subscriptionForm.FetchViaProxy,
DisableHTTP2: subscriptionForm.DisableHTTP2,
ProxyURL: subscriptionForm.ProxyURL,
},
})
if localizedError != nil {
@ -134,6 +136,7 @@ func (h *handler) submitSubscription(w http.ResponseWriter, r *http.Request) {
UrlRewriteRules: subscriptionForm.UrlRewriteRules,
FetchViaProxy: subscriptionForm.FetchViaProxy,
DisableHTTP2: subscriptionForm.DisableHTTP2,
ProxyURL: subscriptionForm.ProxyURL,
})
if localizedError != nil {
v.Set("form", subscriptionForm)