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) {
requestTorRereadConfig();
if (hsKeyPath != null) {
BackupUtils hsutils = new BackupUtils(getApplicationContext());
hsutils.restoreKeyBackup(hsPort, hsKeyPath);
}
startTor();
new Thread() {
@ -631,12 +636,6 @@ public class OrbotMainActivity extends AppCompatActivity
nResult.putExtra("hs_host", hostname);
if (hsKeyPath != null) {
BackupUtils hsutils = new BackupUtils(getApplicationContext());
hsutils.restoreKeyBackup(hsPort, hsKeyPath);
requestTorRereadConfig();
}
if (backupToPackage != null && backupToPackage.length() > 0) {
String servicePath = getFilesDir() + "/" + TorServiceConstants.HIDDEN_SERVICES_DIR + "/hs" + hsPort;
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) {
String keyFilePath = mHSBasePath + "/hs" + hsPort + "/private_key";
File serviceDir = new File(mHSBasePath, "hs" + hsPort);
if (!serviceDir.isDirectory())
serviceDir.mkdirs();
try {
ParcelFileDescriptor mInputPFD = mContext.getContentResolver().openFileDescriptor(hsKeyPath, "r");
InputStream fileStream = new FileInputStream(mInputPFD.getFileDescriptor());
OutputStream file = new FileOutputStream(keyFilePath);
OutputStream file = new FileOutputStream(serviceDir.getAbsolutePath() + "/private_key");
byte[] buffer = new byte[1024];
int length;