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

[tor-commits] [orbot/master] isolate hidden services configuration dirs



commit 0818b0c96313d47493b5d34afd95ada4b19adc3c
Author: arrase <arrase@xxxxxxxxx>
Date:   Wed Nov 23 00:12:06 2016 +0100

    isolate hidden services configuration dirs
---
 .../java/org/torproject/android/backup/BackupUtils.java | 13 ++++++++-----
 .../android/ui/hs/providers/HSContentProvider.java      |  1 -
 .../java/org/torproject/android/service/TorService.java | 17 +++++++++++------
 .../torproject/android/service/TorServiceConstants.java |  2 ++
 4 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/app/src/main/java/org/torproject/android/backup/BackupUtils.java b/app/src/main/java/org/torproject/android/backup/BackupUtils.java
index 42c98f8..5d77d17 100644
--- a/app/src/main/java/org/torproject/android/backup/BackupUtils.java
+++ b/app/src/main/java/org/torproject/android/backup/BackupUtils.java
@@ -9,10 +9,13 @@ import org.torproject.android.storage.ExternalStorage;
 import java.io.File;
 
 public class BackupUtils {
-    private static File appCacheHome;
+    private static File mHSBasePath;
 
     public BackupUtils(Context context) {
-        appCacheHome = context.getDir(TorServiceConstants.DIRECTORY_TOR_DATA, Application.MODE_PRIVATE);
+        mHSBasePath = context.getDir(
+                TorServiceConstants.DIRECTORY_TOR_DATA + "/" + TorServiceConstants.HIDDEN_SERVICES_DIR,
+                Application.MODE_PRIVATE
+        );
     }
 
     public String createOnionBackup(Integer port) {
@@ -25,8 +28,8 @@ public class BackupUtils {
 
         String zip_path = storage_path + "/hs" + port + ".zip";
         String files[] = {
-                appCacheHome + "/hs" + port + "/hostname",
-                appCacheHome + "/hs" + port + "/private_key"
+                mHSBasePath + "/hs" + port + "/hostname",
+                mHSBasePath + "/hs" + port + "/private_key"
         };
 
         ZipIt zip = new ZipIt(files, zip_path);
@@ -40,6 +43,6 @@ public class BackupUtils {
 
     public void restoreOnionBackup(Integer port, String path) {
         ZipIt zip = new ZipIt(null, path);
-        zip.unzip(appCacheHome + "/hs" + port);
+        zip.unzip(mHSBasePath + "/hs" + port);
     }
 }
diff --git a/app/src/main/java/org/torproject/android/ui/hs/providers/HSContentProvider.java b/app/src/main/java/org/torproject/android/ui/hs/providers/HSContentProvider.java
index 2c031d8..f222b85 100644
--- a/app/src/main/java/org/torproject/android/ui/hs/providers/HSContentProvider.java
+++ b/app/src/main/java/org/torproject/android/ui/hs/providers/HSContentProvider.java
@@ -121,7 +121,6 @@ public class HSContentProvider extends ContentProvider {
     }
 
     public static final class HiddenService implements BaseColumns {
-        //Nombres de columnas
         public static final String NAME = "name";
         public static final String PORT = "port";
         public static final String ONION_PORT = "onion_port";
diff --git a/orbotservice/src/main/java/org/torproject/android/service/TorService.java b/orbotservice/src/main/java/org/torproject/android/service/TorService.java
index dfd0195..f8ed3b3 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/TorService.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/TorService.java
@@ -23,14 +23,12 @@ import android.content.ContextWrapper;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.SharedPreferences;
-import android.content.SharedPreferences.Editor;
 import android.content.pm.PackageManager;
 import android.database.Cursor;
 import android.net.ConnectivityManager;
 import android.net.NetworkInfo;
 import android.net.Uri;
 import android.os.Build;
-import android.os.Bundle;
 import android.os.IBinder;
 import android.os.RemoteException;
 import android.provider.BaseColumns;
@@ -128,18 +126,20 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
     public static File fileObfsclient;
     public static File fileXtables;
     public static File fileTorRc;
+    private File mHSBasePath;
 
     private Shell mShell;
     private Shell mShellPolipo;
 
+
     private static final Uri CONTENT_URI = Uri.parse("content://org.torproject.android.ui.hs.providers/hs");
 
     public static final class HiddenService implements BaseColumns {
-        //Nombres de columnas
         public static final String NAME = "name";
         public static final String PORT = "port";
         public static final String ONION_PORT = "onion_port";
         public static final String DOMAIN = "domain";
+        public static final String CREATED_BY_USER = "created_by_user";
 
         private HiddenService() {
         }
@@ -147,7 +147,6 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
 
     private String[] mProjection = new String[]{
 			HiddenService._ID,
-			HiddenService.NAME,
 			HiddenService.DOMAIN,
 			HiddenService.PORT,
 			HiddenService.ONION_PORT};
@@ -532,6 +531,12 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
             fileXtables = new File(appBinHome, TorServiceConstants.IPTABLES_ASSET_KEY);
             fileTorRc = new File(appBinHome, TorServiceConstants.TORRC_ASSET_KEY);
 
+            mHSBasePath = new File(appCacheHome , TorServiceConstants.HIDDEN_SERVICES_DIR);
+
+            if (!mHSBasePath.isDirectory()) {
+                mHSBasePath.mkdirs();
+            }
+
             mEventHandler = new TorEventHandler(this);
 
             if (mNotificationManager == null)
@@ -773,7 +778,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
 
                         // Update only new domains
                         if(HSDomain == null || HSDomain.length() < 1) {
-                            String hsDirPath = new File(appCacheHome,"hs" + HSLocalPort).getCanonicalPath();
+                            String hsDirPath = new File(mHSBasePath.getAbsolutePath(),"hs" + HSLocalPort).getCanonicalPath();
                             File file = new File(hsDirPath, "hostname");
 
                             if (file.exists())
@@ -1782,7 +1787,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
                 while (hidden_services.moveToNext()) {
                     Integer HSLocalPort = hidden_services.getInt(hidden_services.getColumnIndex(HiddenService.PORT));
                     Integer HSOnionPort = hidden_services.getInt(hidden_services.getColumnIndex(HiddenService.ONION_PORT));
-                    String hsDirPath = new File(appCacheHome,"hs" + HSLocalPort).getCanonicalPath();
+                    String hsDirPath = new File(mHSBasePath.getAbsolutePath(),"hs" + HSLocalPort).getCanonicalPath();
 
                     debug("Adding hidden service on port: " + HSLocalPort);
 
diff --git a/orbotservice/src/main/java/org/torproject/android/service/TorServiceConstants.java b/orbotservice/src/main/java/org/torproject/android/service/TorServiceConstants.java
index 00ade29..9bc5a03 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/TorServiceConstants.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/TorServiceConstants.java
@@ -159,4 +159,6 @@ public interface TorServiceConstants {
 			"meek_lite 0.0.2.0:3 url=https://az668014.vo.msecnd.net/ front=ajax.aspnetcdn.com"
 		};
 
+	public static final String HIDDEN_SERVICES_DIR = "hidden_services";
+
 }



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