X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fhelpers%2FProxyHelper.java;h=04e40e9b4dad4ef85fa5625b38079bc4001812c0;hp=b978a02d48b77759cf291f47f6306c9ffcb49596;hb=5c9367467e671483924626fa69eb8a4e61d24352;hpb=4d51aa9acb8daaec1326f14e5025fde6d1f0dcd8 diff --git a/app/src/main/java/com/stoutner/privacybrowser/helpers/ProxyHelper.java b/app/src/main/java/com/stoutner/privacybrowser/helpers/ProxyHelper.java index b978a02d..04e40e9b 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/helpers/ProxyHelper.java +++ b/app/src/main/java/com/stoutner/privacybrowser/helpers/ProxyHelper.java @@ -245,29 +245,29 @@ public class ProxyHelper { // Define a proxy variable. Proxy proxy; - // Set the proxy according to the current proxy mode + // Get the proxy according to the current proxy mode. switch (MainWebViewActivity.proxyMode) { case (ProxyHelper.TOR): if (Build.VERSION.SDK_INT >= 21) { - // Set the socket address to be localhost port 9050. - SocketAddress torSocketAddress = new InetSocketAddress("localhost", 9050); + // Use localhost port 9050 as the socket address. + SocketAddress torSocketAddress = InetSocketAddress.createUnresolved("localhost", 9050); - // Set a SOCKS proxy. + // Create a SOCKS proxy. proxy = new Proxy(Proxy.Type.SOCKS, torSocketAddress); } else { - // Set the socket address to be localhost port 8118. - SocketAddress oldTorSocketAddress = new InetSocketAddress("localhost", 8118); + // Use localhost port 8118 as the socket address. + SocketAddress oldTorSocketAddress = InetSocketAddress.createUnresolved("localhost", 8118); - // Set an HTTP proxy. + // Create an HTTP proxy. proxy = new Proxy(Proxy.Type.HTTP, oldTorSocketAddress); } break; case (ProxyHelper.I2P): - // Set the socket address to be localhost port 4444. - SocketAddress i2pSocketAddress = new InetSocketAddress("localhost", 4444); + // Use localhost port 4444 as the socket address. + SocketAddress i2pSocketAddress = InetSocketAddress.createUnresolved("localhost", 4444); - // Set an HTTP proxy. + // Create an HTTP proxy. proxy = new Proxy(Proxy.Type.HTTP, i2pSocketAddress); break; @@ -283,18 +283,18 @@ public class ProxyHelper { // Convert the custom proxy URL string to a URI. Uri customProxyUri = Uri.parse(customProxyUrlString); - // Set the socket address. - SocketAddress customSocketAddress = new InetSocketAddress(customProxyUri.getHost(), customProxyUri.getPort()); + // Get the custom socket address. + SocketAddress customSocketAddress = InetSocketAddress.createUnresolved(customProxyUri.getHost(), customProxyUri.getPort()); // Get the custom proxy scheme. String customProxyScheme = customProxyUri.getScheme(); - // Set the proxy according to the scheme. + // Create a proxy according to the scheme. if ((customProxyScheme != null) && customProxyScheme.startsWith("socks")) { // A SOCKS proxy is specified. - // Set a SOCKS proxy. + // Create a SOCKS proxy. proxy = new Proxy(Proxy.Type.SOCKS, customSocketAddress); } else { // A SOCKS proxy is not specified. - // Set an HTTP proxy. + // Create an HTTP proxy. proxy = new Proxy(Proxy.Type.HTTP, customSocketAddress); } } catch (Exception exception) { // The custom proxy cannot be parsed. @@ -304,10 +304,9 @@ public class ProxyHelper { break; default: // No proxy is in use. - // Set a direct proxy. + // Create a direct proxy. proxy = Proxy.NO_PROXY; break; - } // Return the proxy.