@Test public void parsePropsWithNewlineTest() throws UnknownHostException, IOException { Reader reader = new StringReader(PROPS_WITH_NEWLINE); BufferedReader bufferedReader = new BufferedReader(reader); Set<String> servers = AndroidUsingExec.parseProps(bufferedReader, false); assertTrue(servers.isEmpty()); }
protected static Set<String> parseProps(BufferedReader lnr, boolean logWarning) throws UnknownHostException, IOException { String line = null; Set<String> server = new HashSet<String>(6); while ((line = lnr.readLine()) != null) { int split = line.indexOf(PROP_DELIM); if (split == -1) { continue; } String property = line.substring(1, split); int valueStart = split + PROP_DELIM.length(); int valueEnd = line.length() - 1; if (valueEnd < valueStart) { if (logWarning) { LOGGER.warning("Malformed property detected: \"" + line + '"'); } continue; } String value = line.substring(valueStart, valueEnd); if (value.isEmpty()) { continue; } if (property.endsWith(".dns") || property.endsWith(".dns1") || property.endsWith(".dns2") || property.endsWith(".dns3") || property.endsWith(".dns4")) { InetAddress ip = InetAddress.getByName(value); if (ip == null) continue; value = ip.getHostAddress(); if (value == null) continue; if (value.length() == 0) continue; server.add(value); } } return server; }
AndroidUsingExec extends AbstractDnsServerLookupMechanism { protected static Set<String> parseProps(BufferedReader lnr, boolean logWarning) throws UnknownHostException, IOException { String line = null; Set<String> server = new HashSet<String>(6); while ((line = lnr.readLine()) != null) { int split = line.indexOf(PROP_DELIM); if (split == -1) { continue; } String property = line.substring(1, split); int valueStart = split + PROP_DELIM.length(); int valueEnd = line.length() - 1; if (valueEnd < valueStart) { if (logWarning) { LOGGER.warning("Malformed property detected: \"" + line + '"'); } continue; } String value = line.substring(valueStart, valueEnd); if (value.isEmpty()) { continue; } if (property.endsWith(".dns") || property.endsWith(".dns1") || property.endsWith(".dns2") || property.endsWith(".dns3") || property.endsWith(".dns4")) { InetAddress ip = InetAddress.getByName(value); if (ip == null) continue; value = ip.getHostAddress(); if (value == null) continue; if (value.length() == 0) continue; server.add(value); } } return server; } }
AndroidUsingExec extends AbstractDnsServerLookupMechanism { protected static Set<String> parseProps(BufferedReader lnr, boolean logWarning) throws UnknownHostException, IOException { String line = null; Set<String> server = new HashSet<String>(6); while ((line = lnr.readLine()) != null) { int split = line.indexOf(PROP_DELIM); if (split == -1) { continue; } String property = line.substring(1, split); int valueStart = split + PROP_DELIM.length(); int valueEnd = line.length() - 1; if (valueEnd < valueStart) { if (logWarning) { LOGGER.warning("Malformed property detected: \"" + line + '"'); } continue; } String value = line.substring(valueStart, valueEnd); if (value.isEmpty()) { continue; } if (property.endsWith(".dns") || property.endsWith(".dns1") || property.endsWith(".dns2") || property.endsWith(".dns3") || property.endsWith(".dns4")) { InetAddress ip = InetAddress.getByName(value); if (ip == null) continue; value = ip.getHostAddress(); if (value == null) continue; if (value.length() == 0) continue; server.add(value); } } return server; } private  AndroidUsingExec(); }
AndroidUsingExec extends AbstractDnsServerLookupMechanism { protected static Set<String> parseProps(BufferedReader lnr, boolean logWarning) throws UnknownHostException, IOException { String line = null; Set<String> server = new HashSet<String>(6); while ((line = lnr.readLine()) != null) { int split = line.indexOf(PROP_DELIM); if (split == -1) { continue; } String property = line.substring(1, split); int valueStart = split + PROP_DELIM.length(); int valueEnd = line.length() - 1; if (valueEnd < valueStart) { if (logWarning) { LOGGER.warning("Malformed property detected: \"" + line + '"'); } continue; } String value = line.substring(valueStart, valueEnd); if (value.isEmpty()) { continue; } if (property.endsWith(".dns") || property.endsWith(".dns1") || property.endsWith(".dns2") || property.endsWith(".dns3") || property.endsWith(".dns4")) { InetAddress ip = InetAddress.getByName(value); if (ip == null) continue; value = ip.getHostAddress(); if (value == null) continue; if (value.length() == 0) continue; server.add(value); } } return server; } private  AndroidUsingExec(); @Override List<String> getDnsServerAddresses(); @Override boolean isAvailable(); }
AndroidUsingExec extends AbstractDnsServerLookupMechanism { protected static Set<String> parseProps(BufferedReader lnr, boolean logWarning) throws UnknownHostException, IOException { String line = null; Set<String> server = new HashSet<String>(6); while ((line = lnr.readLine()) != null) { int split = line.indexOf(PROP_DELIM); if (split == -1) { continue; } String property = line.substring(1, split); int valueStart = split + PROP_DELIM.length(); int valueEnd = line.length() - 1; if (valueEnd < valueStart) { if (logWarning) { LOGGER.warning("Malformed property detected: \"" + line + '"'); } continue; } String value = line.substring(valueStart, valueEnd); if (value.isEmpty()) { continue; } if (property.endsWith(".dns") || property.endsWith(".dns1") || property.endsWith(".dns2") || property.endsWith(".dns3") || property.endsWith(".dns4")) { InetAddress ip = InetAddress.getByName(value); if (ip == null) continue; value = ip.getHostAddress(); if (value == null) continue; if (value.length() == 0) continue; server.add(value); } } return server; } private  AndroidUsingExec(); @Override List<String> getDnsServerAddresses(); @Override boolean isAvailable(); static final DnsServerLookupMechanism INSTANCE; static final int PRIORITY; }