[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [orbot/master] Fixes #474 Remove Briar from Orbot VPN Routing + UI



commit 9759e94faebaa6d71e8230d15170b0a72d28be39
Author: bim <dsnake@xxxxxxxxxxxxxx>
Date:   Tue Aug 10 17:08:42 2021 -0400

    Fixes #474 Remove Briar from Orbot VPN Routing + UI
    
    Also removes Tor Browser and Tor Browser Alpha
---
 .../java/org/torproject/android/ui/AppManagerActivity.java  |  9 +++++++--
 .../org/torproject/android/service/vpn/OrbotVpnManager.java |  5 +++--
 .../org/torproject/android/service/vpn/TorifiedApp.java     | 13 +++++--------
 .../java/org/torproject/android/service/vpn/VpnPrefs.java   | 10 ++++++++++
 4 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/app/src/main/java/org/torproject/android/ui/AppManagerActivity.java b/app/src/main/java/org/torproject/android/ui/AppManagerActivity.java
index 156ccfce..8994ed50 100644
--- a/app/src/main/java/org/torproject/android/ui/AppManagerActivity.java
+++ b/app/src/main/java/org/torproject/android/ui/AppManagerActivity.java
@@ -34,6 +34,7 @@ import org.torproject.android.R;
 import org.torproject.android.service.OrbotConstants;
 import org.torproject.android.service.util.Prefs;
 import org.torproject.android.service.vpn.TorifiedApp;
+import org.torproject.android.service.vpn.VpnPrefs;
 
 import java.lang.ref.WeakReference;
 import java.util.ArrayList;
@@ -54,9 +55,13 @@ public class AppManagerActivity extends AppCompatActivity implements OnClickList
     private ListAdapter adapterApps;
     private ProgressBar progressBar;
 
-    // returns true if the given app is enabled and not orbot
+    /**
+     * @return true if the app is "enabled", not Orbot, and not in
+     * {@link org.torproject.android.service.vpn.VpnPrefs#BYPASS_VPN_PACKAGES}
+     */
     public static boolean includeAppInUi(ApplicationInfo applicationInfo) {
         if (!applicationInfo.enabled) return false;
+        if (Arrays.binarySearch(VpnPrefs.BYPASS_VPN_PACKAGES, applicationInfo.packageName) >= 0) return false;
         return !BuildConfig.APPLICATION_ID.equals(applicationInfo.packageName);
     }
 
@@ -117,7 +122,7 @@ public class AppManagerActivity extends AppCompatActivity implements OnClickList
 
         final LayoutInflater inflater = getLayoutInflater();
 
-        adapterApps = new ArrayAdapter<TorifiedApp>(this, R.layout.layout_apps_item, R.id.itemtext, mApps) {
+        adapterApps = new ArrayAdapter<>(this, R.layout.layout_apps_item, R.id.itemtext, mApps) {
 
             @Override
             public View getView(int position, View convertView, ViewGroup parent) {
diff --git a/orbotservice/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java b/orbotservice/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java
index 0f20b1c6..a0b3178c 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java
@@ -344,9 +344,7 @@ public class OrbotVpnManager implements Handler.Callback {
         for (TorifiedApp app : apps) {
             if (app.isTorified() && (!app.getPackageName().equals(mService.getPackageName()))) {
                 if (prefs.getBoolean(app.getPackageName() + OrbotConstants.APP_TOR_KEY, true)) {
-
                     builder.addAllowedApplication(app.getPackageName());
-
                 }
 
                 perAppEnabled = true;
@@ -354,6 +352,9 @@ public class OrbotVpnManager implements Handler.Callback {
             }
         }
 
+        for (String packageName : VpnPrefs.BYPASS_VPN_PACKAGES)
+            builder.addDisallowedApplication(packageName);
+
         if (!perAppEnabled)
             builder.addDisallowedApplication(mService.getPackageName());
 
diff --git a/orbotservice/src/main/java/org/torproject/android/service/vpn/TorifiedApp.java b/orbotservice/src/main/java/org/torproject/android/service/vpn/TorifiedApp.java
index 2eabaa76..098639ed 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/vpn/TorifiedApp.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/vpn/TorifiedApp.java
@@ -31,6 +31,8 @@ public class TorifiedApp implements Comparable {
     private boolean usesInternet = false;
     private int[] enabledPorts;
 
+
+
     public static ArrayList<TorifiedApp> getApps(Context context, SharedPreferences prefs) {
 
         String tordAppString = prefs.getString(PREFS_KEY_TORIFIED, "");
@@ -56,25 +58,22 @@ public class TorifiedApp implements Comparable {
 
         ApplicationInfo aInfo;
 
-        int appIdx = 0;
         TorifiedApp app;
 
         while (itAppInfo.hasNext()) {
             aInfo = itAppInfo.next();
 
             app = new TorifiedApp();
-
             try {
                 PackageInfo pInfo = pMgr.getPackageInfo(aInfo.packageName, PackageManager.GET_PERMISSIONS);
-
-                if (pInfo != null && pInfo.requestedPermissions != null) {
+                if (Arrays.binarySearch(VpnPrefs.BYPASS_VPN_PACKAGES, aInfo.packageName) >= 0) {
+                    app.setUsesInternet(false);
+                } else if (pInfo != null && pInfo.requestedPermissions != null) {
                     for (String permInfo : pInfo.requestedPermissions) {
                         if (permInfo.equals(Manifest.permission.INTERNET)) {
                             app.setUsesInternet(true);
-
                         }
                     }
-
                 }
 
 
@@ -117,8 +116,6 @@ public class TorifiedApp implements Comparable {
             } else {
                 app.setTorified(false);
             }
-
-            appIdx++;
         }
 
         Collections.sort(apps);
diff --git a/orbotservice/src/main/java/org/torproject/android/service/vpn/VpnPrefs.java b/orbotservice/src/main/java/org/torproject/android/service/vpn/VpnPrefs.java
index 4945241a..4ac17c91 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/vpn/VpnPrefs.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/vpn/VpnPrefs.java
@@ -5,4 +5,14 @@ public interface VpnPrefs {
     String PREFS_DNS_PORT = "PREFS_DNS_PORT";
 
     String PREFS_KEY_TORIFIED = "PrefTord";
+
+    /**
+     * Include packages here to make the VPNService ignore these apps (On Lollipop+). This is to
+     * prevent tor over tor scenarios...
+     */
+    String[] BYPASS_VPN_PACKAGES = new String[] {
+            "org.torproject.torbrowser_alpha",
+            "org.torproject.torbrowser",
+            "org.briarproject.briar.android" // https://github.com/guardianproject/orbot/issues/474
+    };
 }



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits