Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions src/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,25 +160,23 @@ public function __construct(string $url, int $timeout = 10, int $redirects = 5,
}
$proxy = preg_replace('#^.*://#i', '', $proxy); // Strip any scheme already present in CURLOPT_PROXY
$proxy_url = "$proxy_scheme://$proxy"; // CURLOPT_PROXY ($proxy) is formatted as user:pass@hostname:port, with the part before @ being optional
if ($proxy_type === CURLPROXY_SOCKS4A || $proxy_type === CURLPROXY_SOCKS5_HOSTNAME) {
$resolve = [];
} else {
$resolve = $this->get_curl_resolve_info($proxy_url);
if ($resolve === null) {
$this->error = 'Failed to fetch this URL, because the proxy’s IP is not in the allowlist [' .
\SimplePie\Misc::url_remove_credentials($url) . '] [' .
\SimplePie\Misc::url_remove_credentials($proxy_url) . ']';
$this->success = false;
return;
} elseif ($resolve === false) {
$this->error = 'Failed to resolve proxy hostname: ' . \SimplePie\Misc::url_remove_credentials($proxy_url);
$this->success = false;
return;
}
if (!empty($resolve)) {
// For the other proxy protocols, note that IPs for internal domains can be leaked, since the domain is resolved outside of the proxy
$curl_options[CURLOPT_RESOLVE] = $resolve;
}
$resolve = $this->get_curl_resolve_info($proxy_url);
if ($resolve === null) {
$this->error = 'Failed to fetch this URL, because the proxy’s IP is not in the allowlist [' .
\SimplePie\Misc::url_remove_credentials($url) . '] [' .
\SimplePie\Misc::url_remove_credentials($proxy_url) . ']';
$this->success = false;
return;
} elseif ($resolve === false) {
$this->error = 'Failed to resolve proxy hostname: ' . \SimplePie\Misc::url_remove_credentials($proxy_url);
$this->success = false;
return;
}
if (!empty($resolve)) {
// Only for the proxy domain, socks4a and socks5h DNS queries will be passed through the proxy.
// For the other proxy protocols, note that IPs for internal domains can be leaked,
// since the domain is resolved outside of the proxy.
$curl_options[CURLOPT_RESOLVE] = $resolve;
}
}
$this->method = \SimplePie\SimplePie::FILE_SOURCE_REMOTE | \SimplePie\SimplePie::FILE_SOURCE_CURL;
Expand Down
Loading