[tbb-commits] [tor-launcher/maint-0.2.7] Bug 18113: Randomly permutate available default bridges of chosen type.
gk at torproject.org
gk at torproject.org
Thu Jan 21 19:35:50 UTC 2016
commit 99ea6908eace93472b72670abc1f0bc6c4f86dfa
Author: Isis Lovecruft <isis at torproject.org>
Date: Thu Jan 21 03:37:43 2016 +0000
Bug 18113: Randomly permutate available default bridges of chosen type.
* ADDS a new function to TorLauncherUtil, rearrangeBridges() which
takes an array of items and returns a random permutation of that
array.
* CHANGE defaultBridges() getter to call this.rearrangeBridges()
before returning the default bridges. This causing the ordering of
the default bridges in the torrc to vary among clients, resulting
in a more even distribution of clients to default bridges.
---
src/modules/tl-util.jsm | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/modules/tl-util.jsm b/src/modules/tl-util.jsm
index ac680a8..2ef4b15 100644
--- a/src/modules/tl-util.jsm
+++ b/src/modules/tl-util.jsm
@@ -242,6 +242,19 @@ let TorLauncherUtil = // Public
} catch (e) {}
},
+ // Currently, this returns a random permutation of an array, bridgeArray.
+ // Later, we might want to change this function to weight based on the
+ // bridges' bandwidths.
+ rearrangeBridges: function(bridgeArray)
+ {
+ for (var j, x, i = bridgeArray.length; i;
+ j = parseInt(Math.random() * i),
+ x = bridgeArray[--i],
+ bridgeArray[i] = bridgeArray[j],
+ bridgeArray[j] = x);
+ return bridgeArray;
+ },
+
get shouldStartAndOwnTor()
{
const kPrefStartTor = "extensions.torlauncher.start_tor";
@@ -341,6 +354,7 @@ let TorLauncherUtil = // Public
bridgeArray.push(s);
}
}
+ this.rearrangeBridges(bridgeArray);
return bridgeArray;
} catch(e) {};
More information about the tbb-commits
mailing list