MiniDNS / minidns

DNS library for Android and Java SE
Other
220 stars 61 forks source link

findDNS returning blacklisted servers #69

Closed PeterEdens closed 7 years ago

PeterEdens commented 7 years ago

I am using compile 'de.measite.minidns:minidns-hla:0.2.2'

In DNSClient.java the function findDNS iterates through the blacklisted servers to remove them then returns the original array containing the blacklisted servers so it is not possible to blacklist servers:

public static synchronized String[] findDNS() { String[] resArray = null; for (DNSServerLookupMechanism mechanism : LOOKUP_MECHANISMS) { resArray = mechanism.getDnsServerAddresses(); if (resArray == null) { continue; }

        List<String> res = new ArrayList<>(Arrays.asList(resArray));

        Iterator<String> it = res.iterator();
        while (it.hasNext()) {
            String potentialDnsServer = it.next();

            if (blacklistedDnsServers.contains(potentialDnsServer)) {
                LOGGER.fine("The DNS server lookup mechanism '" + mechanism.getName()
                + "' returned a blacklisted result: '" + potentialDnsServer + "'");
                it.remove();
            }
        }

        if (!res.isEmpty()) {
            break;
        }
    }

    return resArray;
}

The latest code on Github looks good and returns res but the 0.2.2 code is as above.