GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still and

Unverified Commit 8869cf4f authored by Isis Lovecruft's avatar Isis Lovecruft
Browse files

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

 * 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.
parent 099454f2
......@@ -246,6 +246,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";
......@@ -361,6 +374,7 @@ let TorLauncherUtil = // Public
return bridgeArray;
} catch(e) {};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment