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

[tor-commits] [orbot/master] use new jtorctl constants for Tor signal names



commit f738497736188578a0b746eb35d843d0bb3f9b30
Author: Hans-Christoph Steiner <hans@xxxxxxx>
Date:   Fri Dec 13 22:34:47 2019 +0100

    use new jtorctl constants for Tor signal names
    
    Tor now prefers its own names, rather than the POSIX names, e.g. SHUTDOWN
    rather than HALT or RELOAD instead of HUP.
---
 .../org/torproject/android/mini/MiniMainActivity.java  |  5 +++--
 .../java/org/torproject/android/OrbotMainActivity.java |  3 ++-
 .../android/ui/onboarding/CustomBridgesActivity.java   |  4 +++-
 .../torproject/android/ui/onboarding/MoatActivity.java |  6 ++++--
 .../org/torproject/android/service/OrbotService.java   | 18 +++++++++---------
 .../android/service/TorServiceConstants.java           |  2 --
 6 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/app-mini/src/main/java/org/torproject/android/mini/MiniMainActivity.java b/app-mini/src/main/java/org/torproject/android/mini/MiniMainActivity.java
index 26b17fdf..34d3d10d 100644
--- a/app-mini/src/main/java/org/torproject/android/mini/MiniMainActivity.java
+++ b/app-mini/src/main/java/org/torproject/android/mini/MiniMainActivity.java
@@ -50,6 +50,7 @@ import androidx.recyclerview.widget.RecyclerView;
 import com.google.zxing.integration.android.IntentIntegrator;
 import com.google.zxing.integration.android.IntentResult;
 
+import net.freehaven.tor.control.TorControlCommands;
 import org.json.JSONArray;
 import org.torproject.android.core.Languages;
 import org.torproject.android.core.LocaleHelper;
@@ -680,7 +681,7 @@ public class MiniMainActivity extends AppCompatActivity implements OrbotConstant
     }
 
     private void requestTorRereadConfig() {
-        sendIntentToService(TorServiceConstants.CMD_SIGNAL_HUP);
+        sendIntentToService(TorControlCommands.SIGNAL_RELOAD);
     }
 
     @Override
@@ -875,7 +876,7 @@ public class MiniMainActivity extends AppCompatActivity implements OrbotConstant
     }
 
     private void requestNewTorIdentity() {
-        sendIntentToService(TorServiceConstants.CMD_NEWNYM);
+        sendIntentToService(TorControlCommands.SIGNAL_NEWNYM);
 
         Rotate3dAnimation rotation = new Rotate3dAnimation(ROTATE_FROM, ROTATE_TO, imgStatus.getWidth() / 2f, imgStatus.getWidth() / 2f, 20f, false);
         rotation.setFillAfter(true);
diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
index d6b6daa8..0bb5be44 100644
--- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java
+++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
@@ -41,6 +41,7 @@ import android.widget.Spinner;
 import android.widget.TextView;
 import android.widget.Toast;
 
+import net.freehaven.tor.control.TorControlCommands;
 import androidx.annotation.RequiresApi;
 import androidx.appcompat.app.AppCompatActivity;
 import androidx.appcompat.widget.SwitchCompat;
@@ -832,7 +833,7 @@ public class OrbotMainActivity extends AppCompatActivity implements OrbotConstan
     }
 
     private void requestTorRereadConfig() {
-        sendIntentToService(TorServiceConstants.CMD_SIGNAL_HUP);
+        sendIntentToService(TorControlCommands.SIGNAL_RELOAD);
     }
 
     @Override
diff --git a/app/src/main/java/org/torproject/android/ui/onboarding/CustomBridgesActivity.java b/app/src/main/java/org/torproject/android/ui/onboarding/CustomBridgesActivity.java
index f20ba4ff..9b668413 100644
--- a/app/src/main/java/org/torproject/android/ui/onboarding/CustomBridgesActivity.java
+++ b/app/src/main/java/org/torproject/android/ui/onboarding/CustomBridgesActivity.java
@@ -26,6 +26,8 @@ import androidx.appcompat.widget.Toolbar;
 import com.google.zxing.integration.android.IntentIntegrator;
 import com.google.zxing.integration.android.IntentResult;
 
+import net.freehaven.tor.control.TorControlCommands;
+
 import org.json.JSONArray;
 import org.torproject.android.R;
 import org.torproject.android.core.ClipboardUtils;
@@ -191,7 +193,7 @@ public class CustomBridgesActivity extends AppCompatActivity implements TextWatc
         Prefs.putBridgesEnabled(bridges != null);
 
         Intent intent = new Intent(this, OrbotService.class);
-        intent.setAction(TorServiceConstants.CMD_SIGNAL_HUP);
+        intent.setAction(TorControlCommands.SIGNAL_RELOAD);
         startService(intent);
     }
 
diff --git a/app/src/main/java/org/torproject/android/ui/onboarding/MoatActivity.java b/app/src/main/java/org/torproject/android/ui/onboarding/MoatActivity.java
index 2bb0807e..165b1a63 100644
--- a/app/src/main/java/org/torproject/android/ui/onboarding/MoatActivity.java
+++ b/app/src/main/java/org/torproject/android/ui/onboarding/MoatActivity.java
@@ -40,6 +40,8 @@ import com.android.volley.toolbox.HurlStack;
 import com.android.volley.toolbox.JsonObjectRequest;
 import com.android.volley.toolbox.Volley;
 
+import net.freehaven.tor.control.TorControlCommands;
+
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
@@ -328,7 +330,7 @@ public class MoatActivity extends AppCompatActivity implements View.OnClickListe
                         Prefs.setBridgesList(sb.toString());
                         Prefs.putBridgesEnabled(true);
 
-                        sendIntentToService(TorServiceConstants.CMD_SIGNAL_HUP);
+                        sendIntentToService(TorControlCommands.SIGNAL_RELOAD);
 
                         mSuccess = true;
                         setResult(RESULT_OK);
@@ -422,7 +424,7 @@ public class MoatActivity extends AppCompatActivity implements View.OnClickListe
 
              //   mQueue = Volley.newRequestQueue(this, new ProxiedHurlStack(host, port));
 
-                sendIntentToService(TorServiceConstants.CMD_SIGNAL_HUP);
+                sendIntentToService(TorControlCommands.SIGNAL_RELOAD);
 
                 if (mCaptcha == null) {
                     fetchCaptcha();
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 396881d3..844da292 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java
@@ -235,7 +235,7 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
 
         mNotifyBuilder.mActions.clear(); // clear out NEWNYM action
         if (conn != null) { // only add new identity action when there is a connection
-            Intent intentRefresh = new Intent(CMD_NEWNYM);
+            Intent intentRefresh = new Intent(TorControlCommands.SIGNAL_NEWNYM);
             PendingIntent pendingIntentNewNym = PendingIntent.getBroadcast(this, 0, intentRefresh, PendingIntent.FLAG_UPDATE_CURRENT);
             mNotifyBuilder.addAction(R.drawable.ic_refresh_white_24dp, getString(R.string.menu_new_identity), pendingIntentNewNym);
         }
@@ -421,7 +421,7 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
 
                 try {
                     logNotice("sending HALT signal to Tor process");
-                    conn.shutdownTor("SHUTDOWN");
+                    conn.shutdownTor(TorControlCommands.SIGNAL_SHUTDOWN);
 
                 } catch (IOException e) {
                     Log.d(OrbotConstants.TAG, "error shutting down Tor via connection", e);
@@ -448,9 +448,9 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
 
     private void requestTorRereadConfig() {
         try {
-            if (conn != null)
-                conn.signal("HUP");
-
+            if (conn != null) {
+                conn.signal(TorControlCommands.SIGNAL_RELOAD);
+            }
         } catch (IOException e) {
             e.printStackTrace();
         }
@@ -507,7 +507,7 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
             //  registerReceiver(mNetworkStateReceiver , mNetworkStateFilter);
 
             IntentFilter filter = new IntentFilter();
-            filter.addAction(CMD_NEWNYM);
+            filter.addAction(TorControlCommands.SIGNAL_NEWNYM);
             filter.addAction(CMD_ACTIVE);
             mActionBroadcastReceiver = new ActionBroadcastReceiver();
             registerReceiver(mActionBroadcastReceiver, filter);
@@ -1588,9 +1588,9 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
                         mVpnManager.handleIntent(new Builder(), mIntent);
                 } else if (action.equals(ACTION_STATUS)) {
                     replyWithStatus(mIntent);
-                } else if (action.equals(CMD_SIGNAL_HUP)) {
+                } else if (action.equals(TorControlCommands.SIGNAL_RELOAD)) {
                     requestTorRereadConfig();
-                } else if (action.equals(CMD_NEWNYM)) {
+                } else if (action.equals(TorControlCommands.SIGNAL_NEWNYM)) {
                     newIdentity();
                 } else if (action.equals(CMD_ACTIVE)) {
                     sendSignalActive();
@@ -1606,7 +1606,7 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
     private class ActionBroadcastReceiver extends BroadcastReceiver {
         public void onReceive(Context context, Intent intent) {
             switch (intent.getAction()) {
-                case CMD_NEWNYM: {
+                case TorControlCommands.SIGNAL_NEWNYM: {
                     newIdentity();
                     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 d2dc4877..d2a71788 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/TorServiceConstants.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/TorServiceConstants.java
@@ -93,8 +93,6 @@ public interface TorServiceConstants {
     String STATUS_STARTS_DISABLED = "STARTS_DISABLED";
 
     // actions for internal command Intents
-    String CMD_SIGNAL_HUP = "signal_hup";
-    String CMD_NEWNYM = "newnym";
     String CMD_SET_EXIT = "setexit";
     String CMD_ACTIVE = "ACTIVE";
 



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