This commit is contained in:
arrase 2016-11-28 01:04:32 +01:00
parent 0a6d623cf7
commit 9ffb0b3915
2 changed files with 12 additions and 9 deletions

View File

@ -597,7 +597,12 @@ public class OrbotMainActivity extends AppCompatActivity
if (onionHostname == null || onionHostname.length() < 1) { if (onionHostname == null || onionHostname.length() < 1) {
requestTorRereadConfig(); if (hsKeyPath != null) {
BackupUtils hsutils = new BackupUtils(getApplicationContext());
hsutils.restoreKeyBackup(hsPort, hsKeyPath);
}
startTor();
new Thread() { new Thread() {
@ -631,12 +636,6 @@ public class OrbotMainActivity extends AppCompatActivity
nResult.putExtra("hs_host", hostname); nResult.putExtra("hs_host", hostname);
if (hsKeyPath != null) {
BackupUtils hsutils = new BackupUtils(getApplicationContext());
hsutils.restoreKeyBackup(hsPort, hsKeyPath);
requestTorRereadConfig();
}
if (backupToPackage != null && backupToPackage.length() > 0) { if (backupToPackage != null && backupToPackage.length() > 0) {
String servicePath = getFilesDir() + "/" + TorServiceConstants.HIDDEN_SERVICES_DIR + "/hs" + hsPort; String servicePath = getFilesDir() + "/" + TorServiceConstants.HIDDEN_SERVICES_DIR + "/hs" + hsPort;
File hidden_service_key = new File(servicePath, "private_key"); File hidden_service_key = new File(servicePath, "private_key");

View File

@ -211,12 +211,16 @@ public class BackupUtils {
} }
public void restoreKeyBackup(int hsPort, Uri hsKeyPath) { public void restoreKeyBackup(int hsPort, Uri hsKeyPath) {
String keyFilePath = mHSBasePath + "/hs" + hsPort + "/private_key";
File serviceDir = new File(mHSBasePath, "hs" + hsPort);
if (!serviceDir.isDirectory())
serviceDir.mkdirs();
try { try {
ParcelFileDescriptor mInputPFD = mContext.getContentResolver().openFileDescriptor(hsKeyPath, "r"); ParcelFileDescriptor mInputPFD = mContext.getContentResolver().openFileDescriptor(hsKeyPath, "r");
InputStream fileStream = new FileInputStream(mInputPFD.getFileDescriptor()); InputStream fileStream = new FileInputStream(mInputPFD.getFileDescriptor());
OutputStream file = new FileOutputStream(keyFilePath); OutputStream file = new FileOutputStream(serviceDir.getAbsolutePath() + "/private_key");
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
int length; int length;