Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a88fea2 authored by Chiachang Wang's avatar Chiachang Wang Committed by android-build-merger
Browse files

Merge "Fix a bug where private DNS to v4-only servers don't validate." am:...

Merge "Fix a bug where private DNS to v4-only servers don't validate." am: b8467591 am: 5f7aee00
am: 4b5f3a31

Change-Id: I1bbbe225935a1267d6f6d17b1651392d8be3bd87
parents 4ee521b0 4b5f3a31
Loading
Loading
Loading
Loading
+17 −6
Original line number Original line Diff line number Diff line
@@ -55,12 +55,23 @@ public class DnsUtils {
            throws UnknownHostException {
            throws UnknownHostException {
        final List<InetAddress> result = new ArrayList<InetAddress>();
        final List<InetAddress> result = new ArrayList<InetAddress>();


        try {
            result.addAll(Arrays.asList(
            result.addAll(Arrays.asList(
                    getAllByName(dnsResolver, network, host, TYPE_AAAA, FLAG_NO_CACHE_LOOKUP,
                    getAllByName(dnsResolver, network, host, TYPE_AAAA, FLAG_NO_CACHE_LOOKUP,
                    timeout)));
                    timeout)));
        } catch (UnknownHostException e) {
            // Might happen if the host is v4-only, still need to query TYPE_A
        }
        try {
            result.addAll(Arrays.asList(
            result.addAll(Arrays.asList(
                    getAllByName(dnsResolver, network, host, TYPE_A, FLAG_NO_CACHE_LOOKUP,
                    getAllByName(dnsResolver, network, host, TYPE_A, FLAG_NO_CACHE_LOOKUP,
                    timeout)));
                    timeout)));
        } catch (UnknownHostException e) {
            // Might happen if the host is v6-only, still need to return AAAA answers
        }
        if (result.size() == 0) {
            throw new UnknownHostException(host);
        }
        return result.toArray(new InetAddress[0]);
        return result.toArray(new InetAddress[0]);
    }
    }


+3 −1
Original line number Original line Diff line number Diff line
@@ -298,8 +298,10 @@ public class NetworkMonitorTest {
        setFallbackSpecs(null); // Test with no fallback spec by default
        setFallbackSpecs(null); // Test with no fallback spec by default
        when(mRandom.nextInt()).thenReturn(0);
        when(mRandom.nextInt()).thenReturn(0);


        // DNS probe timeout should not be defined more than half of HANDLER_TIMEOUT_MS. Otherwise,
        // it will fail the test because of timeout expired for querying AAAA and A sequentially.
        when(mResources.getInteger(eq(R.integer.config_captive_portal_dns_probe_timeout)))
        when(mResources.getInteger(eq(R.integer.config_captive_portal_dns_probe_timeout)))
                .thenReturn(500);
                .thenReturn(200);


        doAnswer((invocation) -> {
        doAnswer((invocation) -> {
            URL url = invocation.getArgument(0);
            URL url = invocation.getArgument(0);