commit ed2e1479eeddede01b1d510ef79dc5ec798b39c0 Author: Matthew Finkel Matthew.Finkel@gmail.com Date: Thu Apr 30 15:47:07 2020 +0000
Bug 33931 - Indicate bridge type in stream
Use the first-byte to indicate if the following data stream contains default bridges or custom bridges. In addition, if the stream contains default bridges, then indicate if only one type of bridge should be used after parsing the stream. --- .../org/torproject/android/service/CustomTorInstaller.java | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/service/src/main/java/org/torproject/android/service/CustomTorInstaller.java b/service/src/main/java/org/torproject/android/service/CustomTorInstaller.java index e962137..198c981 100644 --- a/service/src/main/java/org/torproject/android/service/CustomTorInstaller.java +++ b/service/src/main/java/org/torproject/android/service/CustomTorInstaller.java @@ -48,6 +48,18 @@ public class CustomTorInstaller extends TorInstaller { */ String userDefinedBridgeList = Prefs.getBridgesList(); byte bridgeType = (byte) (userDefinedBridgeList.length() > 5 ? 1 : 0); + // Terrible hack. Must keep in sync with topl::addBridgesFromResources. + if (bridgeType == 0) { + switch (userDefinedBridgeList) { + case "obfs4": + bridgeType = 2; + break; + case "meek": + bridgeType = 3; + break; + } + } + ByteArrayInputStream bridgeTypeStream = new ByteArrayInputStream(new byte[]{bridgeType}); InputStream bridgeStream = (bridgeType == 1) ? new ByteArrayInputStream((userDefinedBridgeList + "\r\n").getBytes()) : context.getResources().getAssets().open("common/bridges.txt");