[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [orbot/master] make bridge allocation shuffle randomly to distribute load
commit 1dbe5eac55f79d48ed3a69c6d19d1962f5a764b3
Author: Nathan Freitas <nathan@xxxxxxxxxxx>
Date: Mon Jan 25 15:45:36 2016 -0500
make bridge allocation shuffle randomly to distribute load
inspired by this work: https://trac.torproject.org/projects/tor/ticket/18113
we don't want all users to start with the same bridges in the same order
---
src/org/torproject/android/OrbotMainActivity.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/org/torproject/android/OrbotMainActivity.java b/src/org/torproject/android/OrbotMainActivity.java
index e020dc2..ae9a8dc 100644
--- a/src/org/torproject/android/OrbotMainActivity.java
+++ b/src/org/torproject/android/OrbotMainActivity.java
@@ -10,7 +10,9 @@ import java.net.URLDecoder;
import java.net.URLEncoder;
import java.text.NumberFormat;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Locale;
+import java.util.Random;
import java.util.StringTokenizer;
import org.json.JSONArray;
@@ -1384,7 +1386,7 @@ public class OrbotMainActivity extends AppCompatActivity
while(st.hasMoreTokens())
sbConfig.append(st.nextToken()).append(' ');
- b.config = sbConfig.toString();
+ b.config = sbConfig.toString().trim();
alBridges.add(b);
@@ -1404,6 +1406,11 @@ public class OrbotMainActivity extends AppCompatActivity
{
StringBuffer sbConfig = new StringBuffer ();
+ //we should randomly sort alBridges so we don't have the same bridge order each time
+ long seed = System.nanoTime();
+ Collections.shuffle(alBridges, new Random(seed));
+
+ //now go through the list to find the bridges we want
for (Bridge b : alBridges)
{
if (b.type.equals(type))
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits