CoreFiles by mySites.guru
AmpResolverV5.php64 lines, 1,630 bytes, from Joomla_6.2.0-beta2-Beta-Full_Package.zip
Raw History Compare with 6.2.0-beta1
md5
5cc2ec35713402740460e87968d5e832
sha1
59892f8d4044387b16eb6cedde1d26df80f9872c
sha256
9b1108e8256e376f9f58173a06de3edc3be7cb4a60bfb4b44b425385ed1e8631
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\HttpClient\Internal;

use Amp\Cancellation;
use Amp\Dns;
use Amp\Dns\DnsRecord;
use Amp\Dns\DnsResolver;

/**
 * Handles local overrides for the DNS resolver.
 *
 * @author Nicolas Grekas <[email protected]>
 *
 * @internal
 */
class AmpResolverV5 implements DnsResolver
{
    public function __construct(
        private array &$dnsMap,
    ) {
    }

    public function resolve(string $name, ?int $typeRestriction = null, ?Cancellation $cancellation = null): array
    {
        $recordType = DnsRecord::A;
        $ip = $this->dnsMap[$name] ?? null;

        if (null !== $ip && str_contains($ip, ':')) {
            $recordType = DnsRecord::AAAA;
        }

        if (null === $ip || $recordType !== ($typeRestriction ?? $recordType)) {
            return Dns\resolve($name, $typeRestriction, $cancellation);
        }

        return [new DnsRecord($ip, $recordType, null)];
    }

    public function query(string $name, int $type, ?Cancellation $cancellation = null): array
    {
        $recordType = DnsRecord::A;
        $ip = $this->dnsMap[$name] ?? null;

        if (null !== $ip && str_contains($ip, ':')) {
            $recordType = DnsRecord::AAAA;
        }

        if (null !== $ip || $recordType !== $type) {
            return Dns\resolve($name, $type, $cancellation);
        }

        return [new DnsRecord($ip, $recordType, null)];
    }
}

The same content is in 49 releases, Joomla 6.0.0-beta1 to 6.3.0-alpha1. See them all, or every version of this file.