0009-Bug-28051-Change-Orbot-s-behavior-for-Tor-Browser.patch 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. From e9d07a68a445b644106780a4759cf41657762c91 Mon Sep 17 00:00:00 2001
  2. From: Matthew Finkel <Matthew.Finkel@gmail.com>
  3. Date: Sat, 24 Nov 2018 04:52:26 +0000
  4. Subject: [PATCH 09/13] Bug 28051 - Change Orbot's behavior for Tor Browser
  5. ---
  6. .../torproject/android/OrbotMainActivity.java | 10 +++++++++-
  7. app/src/main/res/menu/orbot_main.xml | 2 +-
  8. .../torproject/android/service/TorService.java | 17 ++++++++++++-----
  9. .../android/service/TorServiceConstants.java | 11 ++++++-----
  10. 4 files changed, 28 insertions(+), 12 deletions(-)
  11. diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
  12. index 044b957f..e011817e 100644
  13. --- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java
  14. +++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
  15. @@ -552,7 +552,9 @@ public class OrbotMainActivity extends AppCompatActivity
  16. * still exists
  17. **/
  18. private void doExit() {
  19. - stopTor();
  20. + // Don't stop Tor when we exit Orbot. Let Fennec take care of
  21. + // that when we really exit the app.
  22. + //stopTor();
  23. // Kill all the wizard activities
  24. setResult(RESULT_CLOSE_ALL);
  25. @@ -1122,6 +1124,11 @@ public class OrbotMainActivity extends AppCompatActivity
  26. mTxtOrbotLog.append(torServiceMsg + '\n');
  27. + // Return to the browser when we reach 100% bootstrapped
  28. + if (torServiceMsg.contains(TorServiceConstants.TOR_CONTROL_PORT_MSG_BOOTSTRAP_DONE)) {
  29. + finish();
  30. + }
  31. +
  32. }
  33. if (torStatus == null || newTorStatus.equals(torStatus)) {
  34. @@ -1384,6 +1391,7 @@ public class OrbotMainActivity extends AppCompatActivity
  35. iv.setOnClickListener(new View.OnClickListener() {
  36. @Override
  37. public void onClick(View v) {
  38. + // This should never be false, because we are the browser now.
  39. if (!appInstalledOrNot(TorServiceConstants.BROWSER_APP_USERNAME))
  40. promptInstallOrfox();
  41. else
  42. diff --git a/app/src/main/res/menu/orbot_main.xml b/app/src/main/res/menu/orbot_main.xml
  43. index cb25b9e0..1231da8e 100644
  44. --- a/app/src/main/res/menu/orbot_main.xml
  45. +++ b/app/src/main/res/menu/orbot_main.xml
  46. @@ -87,7 +87,7 @@
  47. />
  48. <item android:id="@+id/menu_exit"
  49. - android:title="@string/menu_exit"
  50. + android:title="@string/button_close"
  51. android:icon="@drawable/ic_menu_exit"
  52. yourapp:showAsAction="never"
  53. diff --git a/orbotservice/src/main/java/org/torproject/android/service/TorService.java b/orbotservice/src/main/java/org/torproject/android/service/TorService.java
  54. index a12a97bd..189ee6ab 100644
  55. --- a/orbotservice/src/main/java/org/torproject/android/service/TorService.java
  56. +++ b/orbotservice/src/main/java/org/torproject/android/service/TorService.java
  57. @@ -285,6 +285,10 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
  58. //Reusable code.
  59. PackageManager pm = getPackageManager();
  60. Intent intent = pm.getLaunchIntentForPackage(getPackageName());
  61. + // Add these so Fennec's LauncherActivity can correctly route the request
  62. + // to Orbot when the user taps the Notification
  63. + intent.setAction(TorServiceConstants.TOR_APP_USERNAME);
  64. + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  65. PendingIntent pendIntent = PendingIntent.getActivity(TorService.this, 0, intent, 0);
  66. if (mNotifyBuilder == null)
  67. @@ -413,9 +417,9 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
  68. @Override
  69. public void onTaskRemoved(Intent rootIntent){
  70. Log.d(OrbotConstants.TAG,"task removed");
  71. - Intent intent = new Intent( this, DummyActivity.class );
  72. - intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
  73. - startActivity( intent );
  74. + // Don't prevent being killed. If the user swiped away the
  75. + // app, then we should die.
  76. + stopTor();
  77. }
  78. @Override
  79. @@ -656,12 +660,14 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
  80. }
  81. extraLines.append("SOCKSPort ").append(socksPortPref).append(isolate).append('\n');
  82. - extraLines.append("SafeSocks 0").append('\n');
  83. + // We don't want this disabled.
  84. + //extraLines.append("SafeSocks 0").append('\n');
  85. extraLines.append("TestSocks 0").append('\n');
  86. if (Prefs.openProxyOnAllInterfaces())
  87. extraLines.append("SocksListenAddress 0.0.0.0").append('\n');
  88. - extraLines.append("HTTPTunnelPort ").append(mPortHTTP).append(isolate).append('\n');
  89. + // We don't want/need this either
  90. + //extraLines.append("HTTPTunnelPort ").append(mPortHTTP).append(isolate).append('\n');
  91. if(prefs.getBoolean(OrbotConstants.PREF_CONNECTION_PADDING, false))
  92. @@ -869,6 +875,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
  93. String torCmdString = fileTor.getCanonicalPath()
  94. + " DataDirectory " + appCacheHome.getCanonicalPath()
  95. + + " SocksPort " + TorServiceConstants.SOCKS_PROXY_PORT_DEFAULT
  96. + " --defaults-torrc " + torrcPath
  97. + " -f " + torrcPath + ".custom";
  98. diff --git a/orbotservice/src/main/java/org/torproject/android/service/TorServiceConstants.java b/orbotservice/src/main/java/org/torproject/android/service/TorServiceConstants.java
  99. index 4b62a6a8..44743156 100644
  100. --- a/orbotservice/src/main/java/org/torproject/android/service/TorServiceConstants.java
  101. +++ b/orbotservice/src/main/java/org/torproject/android/service/TorServiceConstants.java
  102. @@ -8,7 +8,7 @@ import android.content.Intent;
  103. public interface TorServiceConstants {
  104. String TOR_APP_USERNAME = "org.torproject.android";
  105. - String BROWSER_APP_USERNAME = "info.guardianproject.orfox";
  106. + String BROWSER_APP_USERNAME = "org.torproject.torbrowser_alpha";
  107. String DIRECTORY_TOR_BINARY = "bin";
  108. String DIRECTORY_TOR_DATA = "data";
  109. @@ -52,15 +52,16 @@ public interface TorServiceConstants {
  110. String IP_LOCALHOST = "127.0.0.1";
  111. int UPDATE_TIMEOUT = 1000;
  112. - int TOR_TRANSPROXY_PORT_DEFAULT = 9040;
  113. + int TOR_TRANSPROXY_PORT_DEFAULT = 9140;
  114. int STANDARD_DNS_PORT = 53;
  115. int TOR_DNS_PORT_DEFAULT = 5400;
  116. String TOR_VPN_DNS_LISTEN_ADDRESS = "127.0.0.1";
  117. - int CONTROL_PORT_DEFAULT = 9051;
  118. - int HTTP_PROXY_PORT_DEFAULT = 8118; // like Privoxy!
  119. - int SOCKS_PROXY_PORT_DEFAULT = 9050;
  120. + // Not used, but we'll change this for consistency
  121. + int CONTROL_PORT_DEFAULT = 9151;
  122. + int HTTP_PROXY_PORT_DEFAULT = 8218; // like Privoxy!
  123. + int SOCKS_PROXY_PORT_DEFAULT = 9150;
  124. //path to check Tor against
  125. --
  126. 2.17.1