From cec82ec0de0535417b8e8f21b4b1a88e9300fe12 Mon Sep 17 00:00:00 2001 From: Nathan Freitas Date: Mon, 7 Mar 2016 14:02:07 -0500 Subject: [PATCH] VPN code cleanup and ensure DNS is listening on all interfaces --- .../android/service/TorService.java | 42 +------------------ .../android/vpn/OrbotVpnService.java | 4 +- 2 files changed, 4 insertions(+), 42 deletions(-) diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java index 0a66fd4c..06636ed3 100644 --- a/src/org/torproject/android/service/TorService.java +++ b/src/org/torproject/android/service/TorService.java @@ -776,13 +776,6 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon shellRoot.close(); } - /** - if (Prefs.useVpn()) //we need to turn on VPN here so the proxy is running - { - enableVpnProxy(); - }*/ - - getHiddenServiceHostname (); } else @@ -1204,6 +1197,8 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon Prefs.putUseVpn(true); processTransparentProxying(); + updateConfiguration("DNSPort",TOR_VPN_DNS_LISTEN_ADDRESS + ":" + TorServiceConstants.TOR_DNS_PORT_DEFAULT,false); + Intent intent = new Intent(TorService.this, OrbotVpnService.class); intent.setAction("start"); @@ -1213,36 +1208,6 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon } - public void refreshVpnProxy () { - - debug ("refreshing VPN Proxy"); - - try - { - conn.setConf("DisableNetwork", "1"); - - Intent intent = new Intent(TorService.this, OrbotVpnService.class); - intent.setAction("refresh"); - startService(intent); - - //updateConfiguration("DNSPort",TOR_VPN_DNS_LISTEN_ADDRESS + ":" + TorServiceConstants.TOR_DNS_PORT_DEFAULT,false); - //updateConfiguration("DNSPort",TorServiceConstants.TOR_DNS_PORT_DEFAULT+"",false); - updateConfiguration("DisableNetwork","0", false); - - saveConfiguration(); - - - conn.setConf("DisableNetwork", "0"); - } - catch (Exception ioe) - { - Log.e(TAG,"error restarting network",ioe); - } - - } - - - public void clearVpnProxy () { debug ("clearing VPN Proxy"); @@ -1853,9 +1818,6 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon shell.close(); } - // else if (Prefs.useVpn()) //we need to turn on VPN here so the proxy is running - // refreshVpnProxy(); - } } diff --git a/src/org/torproject/android/vpn/OrbotVpnService.java b/src/org/torproject/android/vpn/OrbotVpnService.java index c5f6b828..6540f029 100644 --- a/src/org/torproject/android/vpn/OrbotVpnService.java +++ b/src/org/torproject/android/vpn/OrbotVpnService.java @@ -77,8 +77,8 @@ public class OrbotVpnService extends VpnService implements Handler.Callback { private final static boolean mIsLollipop = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; - //this is the actual DNS server we talk with over TCP/IP - private final static String DEFAULT_ACTUAL_DNS_HOST = "127.0.0.1";//"8.8.8.8";//use Google here, or 8.8.4.4 as backup? + //this is the actual DNS server we talk to over UDP or TCP (now using Tor's DNS port) + private final static String DEFAULT_ACTUAL_DNS_HOST = "127.0.0.1"; private final static int DEFAULT_ACTUAL_DNS_PORT = TorServiceConstants.TOR_DNS_PORT_DEFAULT; private boolean isRestart = false;