aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/utils/AndroidUsingExecLowPriority.java
diff options
context:
space:
mode:
authorgenofire <geno+dev@fireorbit.de>2020-02-05 20:25:36 +0100
committerGitHub <noreply@github.com>2020-02-05 20:25:36 +0100
commit22dc081ed1f7045b79de385875d551e1af58011c (patch)
treec15bf4c9f1ae17c807c9b9ed68a45ca360e23c36 /src/main/java/de/pixart/messenger/utils/AndroidUsingExecLowPriority.java
parent1e5ebaa19c427adb68f3efa52eb5a9b521064132 (diff)
Networkstack: easy happy eyeball (#411)
* Networkstack: easy happy eyeball * Networkstack: drop own implementation of DNS-Server selection Co-authored-by: Christian Schneppe <kriztan@users.noreply.github.com>
Diffstat (limited to 'src/main/java/de/pixart/messenger/utils/AndroidUsingExecLowPriority.java')
-rw-r--r--src/main/java/de/pixart/messenger/utils/AndroidUsingExecLowPriority.java92
1 files changed, 0 insertions, 92 deletions
diff --git a/src/main/java/de/pixart/messenger/utils/AndroidUsingExecLowPriority.java b/src/main/java/de/pixart/messenger/utils/AndroidUsingExecLowPriority.java
deleted file mode 100644
index 6097fcd03..000000000
--- a/src/main/java/de/pixart/messenger/utils/AndroidUsingExecLowPriority.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2015-2016 the original author or authors
- *
- * This software is licensed under the Apache License, Version 2.0,
- * the GNU Lesser General Public License version 2 or later ("LGPL")
- * and the WTFPL.
- * You may choose either license to govern your use of this software only
- * upon the condition that you accept all of the terms of either
- * the Apache License 2.0, the LGPL 2.1+ or the WTFPL.
- */
-
-package de.pixart.messenger.utils;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.LineNumberReader;
-import java.net.InetAddress;
-import java.util.HashSet;
-import java.util.logging.Level;
-
-import de.measite.minidns.dnsserverlookup.AbstractDNSServerLookupMechanism;
-import de.measite.minidns.dnsserverlookup.AndroidUsingReflection;
-import de.measite.minidns.dnsserverlookup.DNSServerLookupMechanism;
-import de.measite.minidns.util.PlatformDetection;
-
-/**
- * Try to retrieve the list of DNS server by executing getprop.
- */
-public class AndroidUsingExecLowPriority extends AbstractDNSServerLookupMechanism {
-
- public static final DNSServerLookupMechanism INSTANCE = new AndroidUsingExecLowPriority();
- public static final int PRIORITY = AndroidUsingReflection.PRIORITY + 1;
-
- private AndroidUsingExecLowPriority() {
- super(AndroidUsingExecLowPriority.class.getSimpleName(), PRIORITY);
- }
-
- @Override
- public String[] getDnsServerAddresses() {
- try {
- Process process = Runtime.getRuntime().exec("getprop");
- InputStream inputStream = process.getInputStream();
- LineNumberReader lnr = new LineNumberReader(
- new InputStreamReader(inputStream));
- String line;
- HashSet<String> server = new HashSet<>(6);
- while ((line = lnr.readLine()) != null) {
- int split = line.indexOf("]: [");
- if (split == -1) {
- continue;
- }
- String property = line.substring(1, split);
- String value = line.substring(split + 4, line.length() - 1);
-
- if (value.isEmpty()) {
- continue;
- }
-
- if (property.endsWith(".dns") || property.endsWith(".dns1") ||
- property.endsWith(".dns2") || property.endsWith(".dns3") ||
- property.endsWith(".dns4")) {
-
- // normalize the address
-
- InetAddress ip = InetAddress.getByName(value);
-
- if (ip == null) continue;
-
- value = ip.getHostAddress();
-
- if (value == null) continue;
- if (value.length() == 0) continue;
-
- server.add(value);
- }
- }
- if (server.size() > 0) {
- return server.toArray(new String[server.size()]);
- }
- } catch (IOException e) {
- LOGGER.log(Level.WARNING, "Exception in findDNSByExec", e);
- }
- return null;
- }
-
- @Override
- public boolean isAvailable() {
- return PlatformDetection.isAndroid();
- }
-
-} \ No newline at end of file