mirror of
https://github.com/miniflux/v2.git
synced 2025-07-22 17:18:37 +00:00
feat: implement proxy URL per feed
This commit is contained in:
parent
7b344de846
commit
ef22e95f8b
48 changed files with 333 additions and 192 deletions
|
@ -6,6 +6,7 @@ package fetcher // import "miniflux.app/v2/internal/reader/fetcher"
|
|||
import (
|
||||
"crypto/tls"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net"
|
||||
"net/http"
|
||||
|
@ -30,6 +31,7 @@ type RequestBuilder struct {
|
|||
ignoreTLSErrors bool
|
||||
disableHTTP2 bool
|
||||
proxyRotator *proxyrotator.ProxyRotator
|
||||
feedProxyURL string
|
||||
}
|
||||
|
||||
func NewRequestBuilder() *RequestBuilder {
|
||||
|
@ -96,6 +98,11 @@ func (r *RequestBuilder) UseCustomApplicationProxyURL(value bool) *RequestBuilde
|
|||
return r
|
||||
}
|
||||
|
||||
func (r *RequestBuilder) WithCustomFeedProxyURL(proxyURL string) *RequestBuilder {
|
||||
r.feedProxyURL = proxyURL
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *RequestBuilder) WithTimeout(timeout int) *RequestBuilder {
|
||||
r.clientTimeout = timeout
|
||||
return r
|
||||
|
@ -160,9 +167,17 @@ func (r *RequestBuilder) ExecuteRequest(requestURL string) (*http.Response, erro
|
|||
}
|
||||
|
||||
var clientProxyURL *url.URL
|
||||
if r.useClientProxy && r.clientProxyURL != nil {
|
||||
|
||||
switch {
|
||||
case r.feedProxyURL != "":
|
||||
var err error
|
||||
clientProxyURL, err = url.Parse(r.feedProxyURL)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(`fetcher: invalid feed proxy URL %q: %w`, r.feedProxyURL, err)
|
||||
}
|
||||
case r.useClientProxy && r.clientProxyURL != nil:
|
||||
clientProxyURL = r.clientProxyURL
|
||||
} else if r.proxyRotator != nil && r.proxyRotator.HasProxies() {
|
||||
case r.proxyRotator != nil && r.proxyRotator.HasProxies():
|
||||
clientProxyURL = r.proxyRotator.GetNextProxy()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue