@Override
    ImmutableSortedSet<Endpoint> onDnsRecords(List<DnsRecord> records, int ttl) throws Exception {
        final ImmutableSortedSet.Builder<Endpoint> builder = ImmutableSortedSet.naturalOrder();
        final boolean hasLoopbackARecords =
                records.stream()
                       .filter(ByteArrayDnsRecord.class::isInstance)
                       .map(ByteArrayDnsRecord.class::cast)
                       .anyMatch(r -> {
                           final byte[] content = r.content();
                           return r.type() == DnsRecordType.A && content.length > 0 && content[0] == 127;
                       });

        for (DnsRecord r : records) {
            if (!(r instanceof ByteArrayDnsRecord)) {
                continue;
            }

            final byte[] addrBytes = extractAddressBytes(r, logger(), logPrefix());
            if (addrBytes == null) {
                continue;
            }

            final String ipAddr;
            final int contentLen = addrBytes.length;

            if (contentLen == 16) {
                // Convert some IPv6 addresses into IPv4 addresses to remove duplicate endpoints.
                if (addrBytes[0] == 0x00 && addrBytes[1] == 0x00 &&
                    addrBytes[2] == 0x00 && addrBytes[3] == 0x00 &&
                    addrBytes[4] == 0x00 && addrBytes[5] == 0x00 &&
                    addrBytes[6] == 0x00 && addrBytes[7] == 0x00 &&
                    addrBytes[8] == 0x00 && addrBytes[9] == 0x00) {

                    if (addrBytes[10] == 0x00 && addrBytes[11] == 0x00) {
                        if (addrBytes[12] == 0x00 && addrBytes[13] == 0x00 &&
                            addrBytes[14] == 0x00 && addrBytes[15] == 0x01) {
                            // Loopback address (::1)
                            if (hasLoopbackARecords) {
                                // Contains an IPv4 loopback address already; skip.
                                continue;
                            } else {
                                ipAddr = "::1";
                            }
                        } else {
                            // IPv4-compatible address.
                            ipAddr = NetUtil.bytesToIpAddress(addrBytes, 12, 4);
                        }
                    } else if (addrBytes[10] == -1 && addrBytes[11] == -1) {
                        // IPv4-mapped address.
                        ipAddr = NetUtil.bytesToIpAddress(addrBytes, 12, 4);
                    } else {
                        ipAddr = NetUtil.bytesToIpAddress(addrBytes);
                    }
                } else {
                    ipAddr = NetUtil.bytesToIpAddress(addrBytes);
                }
            } else {
                ipAddr = NetUtil.bytesToIpAddress(addrBytes);
            }

            final Endpoint endpoint = Endpoint.unsafeCreate(hostname, port);
            builder.add(endpoint.withIpAddr(ipAddr));
        }

        final ImmutableSortedSet<Endpoint> endpoints = builder.build();
        logDnsResolutionResult(endpoints, ttl);
        return endpoints;
    }
Returns a new {@link DnsAddressEndpointGroupBuilder} with the specified hostname.

@param hostname the hostname to query DNS queries for
core/src/main/java/com/linecorp/armeria/client/endpoint/dns/DnsAddressEndpointGroup.java