diff options
| author | 2025-11-04 12:48:31 +0100 | |
|---|---|---|
| committer | 2025-11-04 12:48:31 +0100 | |
| commit | 7d4854a0a4f5665db599f18c34035786465639f3 (patch) | |
| tree | ed69305612249a91080d42e3fe39021cab15dda2 /app/Models | |
| parent | 5535067f64fe4285b414a48ae6d16b85fb26f97f (diff) | |
Create separate `Retry-After` files for proxies (#8029)
* Create separate `Retry-After` files for proxies
Bad proxies are able to send a false `Retry-After` header and affect the availability of feeds (domain-wide) for other users.
This PR starts including the address of the proxy if present in filenames for `Retry-After` to mitigate the issue.
* Reduce code changes
* Sync SimplePie fork
https://github.com/FreshRSS/simplepie/pull/62
---------
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'app/Models')
| -rw-r--r-- | app/Models/Feed.php | 2 | ||||
| -rw-r--r-- | app/Models/SimplePieResponse.php | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/app/Models/Feed.php b/app/Models/Feed.php index fd9177d4e..2a1ec3f63 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -552,7 +552,7 @@ class FreshRSS_Feed extends Minz_Model { Minz_Exception::ERROR ); } else { - if (($retryAfter = FreshRSS_http_Util::getRetryAfter($this->url)) > 0) { + if (($retryAfter = FreshRSS_http_Util::getRetryAfter($this->url, $this->proxyParam())) > 0) { throw new FreshRSS_Feed_Exception('For that domain, will first retry after ' . date('c', $retryAfter) . '. ' . $this->url(includeCredentials: false), code: 503); } diff --git a/app/Models/SimplePieResponse.php b/app/Models/SimplePieResponse.php index 6e15da24a..27dc41b74 100644 --- a/app/Models/SimplePieResponse.php +++ b/app/Models/SimplePieResponse.php @@ -4,7 +4,7 @@ declare(strict_types=1); final class FreshRSS_SimplePieResponse extends \SimplePie\File { #[\Override] - protected function on_http_response($response): void { + protected function on_http_response($response, array $curl_options = []): void { syslog(LOG_INFO, 'FreshRSS SimplePie GET ' . $this->get_status_code() . ' ' . \SimplePie\Misc::url_remove_credentials($this->get_final_requested_uri())); if (in_array($this->get_status_code(), [429, 503], true)) { @@ -15,7 +15,8 @@ final class FreshRSS_SimplePieResponse extends \SimplePie\File $headers = []; } - $retryAfter = FreshRSS_http_Util::setRetryAfter($this->get_final_requested_uri(), $headers['retry-after'] ?? ''); + $proxy = is_string($curl_options[CURLOPT_PROXY] ?? null) ? $curl_options[CURLOPT_PROXY] : ''; + $retryAfter = FreshRSS_http_Util::setRetryAfter($this->get_final_requested_uri(), $proxy, $headers['retry-after'] ?? ''); if ($retryAfter > 0) { $domain = parse_url($this->get_final_requested_uri(), PHP_URL_HOST); if (is_string($domain) && $domain !== '') { |
