Update website
This commit is contained in:
parent
011b183e28
commit
41ce1aa076
23 changed files with 284 additions and 94 deletions
|
@ -77,9 +77,33 @@ final class NoPrivateNetworkHttpClient implements HttpClientInterface, LoggerAwa
|
|||
}
|
||||
|
||||
$subnets = $this->subnets;
|
||||
$lastUrl = '';
|
||||
$lastPrimaryIp = '';
|
||||
|
||||
$options['on_progress'] = function (int $dlNow, int $dlSize, array $info) use ($onProgress, $subnets, &$lastPrimaryIp): void {
|
||||
$options['on_progress'] = function (int $dlNow, int $dlSize, array $info, ?\Closure $resolve = null) use ($onProgress, $subnets, &$lastUrl, &$lastPrimaryIp): void {
|
||||
if ($info['url'] !== $lastUrl) {
|
||||
$host = trim(parse_url($info['url'], PHP_URL_HOST) ?: '', '[]');
|
||||
$resolve ??= static fn () => null;
|
||||
|
||||
if (($ip = $host)
|
||||
&& !filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)
|
||||
&& !filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)
|
||||
&& !$ip = $resolve($host)
|
||||
) {
|
||||
if ($ip = @(dns_get_record($host, \DNS_A)[0]['ip'] ?? null)) {
|
||||
$resolve($host, $ip);
|
||||
} elseif ($ip = @(dns_get_record($host, \DNS_AAAA)[0]['ipv6'] ?? null)) {
|
||||
$resolve($host, '['.$ip.']');
|
||||
}
|
||||
}
|
||||
|
||||
if ($ip && IpUtils::checkIp($ip, $subnets ?? self::PRIVATE_SUBNETS)) {
|
||||
throw new TransportException(sprintf('Host "%s" is blocked for "%s".', $host, $info['url']));
|
||||
}
|
||||
|
||||
$lastUrl = $info['url'];
|
||||
}
|
||||
|
||||
if ($info['primary_ip'] !== $lastPrimaryIp) {
|
||||
if ($info['primary_ip'] && IpUtils::checkIp($info['primary_ip'], $subnets ?? self::PRIVATE_SUBNETS)) {
|
||||
throw new TransportException(sprintf('IP "%s" is blocked for "%s".', $info['primary_ip'], $info['url']));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue