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

[tor-commits] [orbot/master] fixes for #285 reset dormant state on start / resume



commit 3087f77b09c9319597dde229e57f45581c1aaac9
Author: n8fr8 <nathan@xxxxxxxxxxxxxxxxxxxx>
Date:   Wed Aug 19 14:22:14 2020 -0400

    fixes for #285 reset dormant state on start / resume
    more info at:
    https://gitlab.torproject.org/tpo/core/tor/-/issues/40097w
---
 .../org/torproject/android/OrbotMainActivity.java  |  2 ++
 .../torproject/android/service/OrbotService.java   | 26 ++++++++++++++++++++--
 .../android/service/TorServiceConstants.java       |  1 +
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
index af311c34..c7ca1a7f 100644
--- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java
+++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
@@ -898,6 +898,8 @@ public class OrbotMainActivity extends AppCompatActivity implements OrbotConstan
     protected void onResume() {
         super.onResume();
 
+        sendIntentToService(TorServiceConstants.CMD_ACTIVE);
+
         mBtnBridges.setChecked(Prefs.bridgesEnabled());
         refreshVpnState();
 
diff --git a/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java b/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java
index a3aa2d98..61404632 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java
@@ -424,7 +424,11 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
                     requestTorRereadConfig();
                 } else if (action.equals(CMD_NEWNYM)) {
                     newIdentity();
-                } else if (action.equals(CMD_SET_EXIT)) {
+                }
+                else if (action.equals(CMD_ACTIVE)) {
+                    sendSignalActive();
+                }
+                else if (action.equals(CMD_SET_EXIT)) {
 
                 	setExitNode(mIntent.getStringExtra("exit"));
 
@@ -600,6 +604,7 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
 
             IntentFilter filter = new IntentFilter();
             filter.addAction(CMD_NEWNYM);
+            filter.addAction(CMD_ACTIVE);
             mActionBroadcastReceiver = new ActionBroadcastReceiver();
             registerReceiver(mActionBroadcastReceiver, filter);
 
@@ -783,8 +788,9 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
         extraLines.append("VirtualAddrNetwork 10.192.0.0/10").append('\n');
         extraLines.append("AutomapHostsOnResolve 1").append('\n');
 
-       // extraLines.append("DormantClientTimeout 10 minutes").append('\n');
+        extraLines.append("DormantClientTimeout 10 minutes").append('\n');
        // extraLines.append("DormantOnFirstStartup 0").append('\n');
+        extraLines.append("DormantCanceledByStartup 1").append('\n');
 
         extraLines.append("DisableNetwork 0").append('\n');
 
@@ -1399,6 +1405,17 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
 
         }
 
+        public void sendSignalActive ()
+        {
+            if (conn != null && mCurrentStatus == STATUS_ON) {
+                try {
+                    conn.signal("ACTIVE");
+                } catch (IOException e) {
+                    debug("error send active: " + e.getLocalizedMessage());
+                }
+            }
+        }
+
         public void newIdentity ()
         {
             //it is possible to not have a connection yet, and someone might try to newnym
@@ -2139,6 +2156,11 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
                     newIdentity();
                     break;
                 }
+                case CMD_ACTIVE:
+                {
+                    sendSignalActive();
+                    break;
+                }
             }
         }
     }
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 9220095a..dfd5a5f0 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/TorServiceConstants.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/TorServiceConstants.java
@@ -105,6 +105,7 @@ public interface TorServiceConstants {
     String CMD_SIGNAL_HUP = "signal_hup";
     String CMD_NEWNYM = "newnym";
     String CMD_SET_EXIT = "setexit";
+    String CMD_ACTIVE = "ACTIVE";
 
     String PREF_BINARY_TOR_VERSION_INSTALLED = "BINARY_TOR_VERSION_INSTALLED";
 



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