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

Commit e6b29898 authored by Andreas Sandblad's avatar Andreas Sandblad Committed by Johan Redestig
Browse files

Don't perform DNS lookup in android.net.Proxy.isLocalHost

This fixes degrade introduced by:
Switch to using public APIs instead of private ones.
536ff5a6

Change-Id: I63cbea82d85d55d933bcfc9e7a311d1aa2324955
parent 7d9c73fb
Loading
Loading
Loading
Loading
+6 −8
Original line number Original line Diff line number Diff line
@@ -24,9 +24,7 @@ import android.os.SystemProperties;
import android.provider.Settings;
import android.provider.Settings;
import android.util.Log;
import android.util.Log;


import java.net.InetAddress;
import java.net.URI;
import java.net.URI;
import java.net.UnknownHostException;


import junit.framework.Assert;
import junit.framework.Assert;


@@ -162,15 +160,15 @@ final public class Proxy {
            final URI uri = URI.create(url);
            final URI uri = URI.create(url);
            final String host = uri.getHost();
            final String host = uri.getHost();
            if (host != null) {
            if (host != null) {
                if (host.equalsIgnoreCase("localhost")) {
                // TODO: InetAddress.isLoopbackAddress should be used to check
                    return true;
                // for localhost. However no public factory methods exist which
                }
                // can be used without triggering DNS lookup if host is not localhost.
                if (InetAddress.getByName(host).isLoopbackAddress()) {
                if (host.equalsIgnoreCase("localhost") ||
                        host.equals("127.0.0.1") ||
                        host.equals("[::1]")) {
                    return true;
                    return true;
                }
                }
            }
            }
        } catch (UnknownHostException uex) {
            // Ignore (INetworkSystem.ipStringToByteArray)
        } catch (IllegalArgumentException iex) {
        } catch (IllegalArgumentException iex) {
            // Ignore (URI.create)
            // Ignore (URI.create)
        }
        }