add support for loading default bridges from asset file
This commit is contained in:
parent
b3a953ba64
commit
cf1a644c19
|
@ -1,4 +1,3 @@
|
|||
assets/
|
||||
/external/appcompat/bin/
|
||||
/external/appcompat/gen/
|
||||
/external/bin/
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
obfs3 83.212.101.3:80 A09D536DD1752D542E1FBB3C9CE4449D51298239
|
||||
obfs3 169.229.59.74:31493 AF9F66B7B04F8FF6F32D455F05135250A16543C9
|
||||
obfs3 169.229.59.75:46328 AF9F66B7B04F8FF6F32D455F05135250A16543C9
|
||||
obfs3 109.105.109.163:38980 1E05F577A0EC0213F971D81BF4D86A9E4E8229ED
|
||||
obfs3 109.105.109.163:47779 4C331FA9B3D1D6D8FB0D8FBBF0C259C360D97E6A
|
||||
scramblesuit 83.212.101.3:443 A09D536DD1752D542E1FBB3C9CE4449D51298239 password=XTCXLG2JAMJKZW2POLBAOWOQETQSMASH
|
||||
obfs4 198.245.60.50:443 752CF7825B3B9EA6A98C83AC41F7099D67007EA5 cert=xpmQtKUqQ/6v5X7ijgYE/f03+l2/EuQ1dexjyUhh16wQlu/cpXUGalmhDIlhuiQPNEKmKw iat-mode=0");
|
||||
obfs4 109.105.109.165:10527 8DFCD8FB3285E855F5A55EDDA35696C743ABFC4E cert=Bvg/itxeL4TWKLP6N1MaQzSOC6tcRIBv6q57DYAZc3b2AzuM+/TfB7mqTFEfXILCjEwzVA iat-mode=0
|
||||
obfs4 83.212.101.3:41213 A09D536DD1752D542E1FBB3C9CE4449D51298239 cert=lPRQ/MXdD1t5SRZ9MquYQNT9m5DV757jtdXdlePmRCudUU9CFUOX1Tm7/meFSyPOsud7Cw iat-mode=0
|
||||
obfs4 104.131.108.182:56880 EF577C30B9F788B0E1801CF7E433B3B77792B77A cert=0SFhfDQrKjUJP8Qq6wrwSICEPf3Vl/nJRsYxWbg3QRoSqhl2EB78MPS2lQxbXY4EW1wwXA iat-mode=0
|
||||
obfs4 109.105.109.147:13764 BBB28DF0F201E706BE564EFE690FE9577DD8386D cert=KfMQN/tNMFdda61hMgpiMI7pbwU1T+wxjTulYnfw+4sgvG0zSH7N7fwT10BI8MUdAD7iJA iat-mode=0
|
||||
meek 0.0.2.0:1 46D4A71197B8FA515A826C6B017C522FE264655B url=https://meek-reflect.appspot.com/ front=www.google.com
|
||||
meek 0.0.2.0:2 B9E7141C594AF25699E0079C1F0146F409495296 url=https://d2zfqthxsdq309.cloudfront.net/ front=a0.awsstatic.com
|
||||
meek 0.0.2.0:3 A2C13B7DFCAB1CBF3A884B6EB99A98067AB6EF44 url=https://az786092.vo.msecnd.net/ front=ajax.aspnetcdn.com
|
|
@ -3,12 +3,13 @@
|
|||
<resources>
|
||||
|
||||
<string-array name="bridge_options">
|
||||
<item>Obfs4 (Recommended)</item>
|
||||
<item>Obfs4 (Best)</item>
|
||||
<item>Obfs3</item>
|
||||
<item>ScrambleSuit</item>
|
||||
<item>Tunnel through Azure</item>
|
||||
<item>Tunnel through Amazon</item>
|
||||
<item>Tunnel through Google</item>
|
||||
<item>Get New Bridges</item>
|
||||
<item></item>
|
||||
</string-array>
|
||||
|
||||
|
|
|
@ -3,12 +3,15 @@
|
|||
|
||||
package org.torproject.android;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.torproject.android.service.TorService;
|
||||
|
@ -110,6 +113,15 @@ public class OrbotMainActivity extends AppCompatActivity
|
|||
public final static String INTENT_ACTION_REQUEST_HIDDEN_SERVICE = "org.torproject.android.REQUEST_HS_PORT";
|
||||
public final static String INTENT_ACTION_REQUEST_START_TOR = "org.torproject.android.START_TOR";
|
||||
|
||||
// for bridge loading from the assets default bridges.txt file
|
||||
class Bridge
|
||||
{
|
||||
String type;
|
||||
String config;
|
||||
}
|
||||
|
||||
private ArrayList<Bridge> alBridges = null;
|
||||
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -635,6 +647,8 @@ public class OrbotMainActivity extends AppCompatActivity
|
|||
{
|
||||
String newBridgeValue = urlString.substring(9); //remove the bridge protocol piece
|
||||
newBridgeValue = URLDecoder.decode(newBridgeValue); //decode the value here
|
||||
|
||||
showAlert(getString(R.string.bridges_updated),getString(R.string.restart_orbot_to_use_this_bridge_) + newBridgeValue,false);
|
||||
|
||||
setNewBridges(newBridgeValue);
|
||||
}
|
||||
|
@ -651,8 +665,6 @@ public class OrbotMainActivity extends AppCompatActivity
|
|||
private void setNewBridges (String newBridgeValue)
|
||||
{
|
||||
|
||||
showAlert(getString(R.string.bridges_updated),getString(R.string.restart_orbot_to_use_this_bridge_) + newBridgeValue,false);
|
||||
|
||||
Prefs.setBridgesList(newBridgeValue); //set the string to a preference
|
||||
Prefs.putBridgesEnabled(true);
|
||||
|
||||
|
@ -812,6 +824,9 @@ public class OrbotMainActivity extends AppCompatActivity
|
|||
{
|
||||
results = URLDecoder.decode(results, "UTF-8");
|
||||
results = results.substring(urlIdx+3);
|
||||
|
||||
showAlert(getString(R.string.bridges_updated),getString(R.string.restart_orbot_to_use_this_bridge_) + results,false);
|
||||
|
||||
setNewBridges(results);
|
||||
}
|
||||
else
|
||||
|
@ -840,6 +855,8 @@ public class OrbotMainActivity extends AppCompatActivity
|
|||
|
||||
public void promptSetupBridges ()
|
||||
{
|
||||
loadBridgeDefaults();
|
||||
|
||||
LayoutInflater li = LayoutInflater.from(this);
|
||||
View view = li.inflate(R.layout.layout_diag, null);
|
||||
|
||||
|
@ -859,16 +876,19 @@ public class OrbotMainActivity extends AppCompatActivity
|
|||
switch (which)
|
||||
{
|
||||
case 0: //obfs 4;
|
||||
showGetBridgePrompt("obfs4");
|
||||
|
||||
setupBridgeType("obfs4");
|
||||
enableBridges(true);
|
||||
|
||||
break;
|
||||
case 1: //obfs3
|
||||
showGetBridgePrompt("obfs3");
|
||||
|
||||
setupBridgeType("obfs3");
|
||||
enableBridges(true);
|
||||
|
||||
break;
|
||||
case 2: //scramblesuit
|
||||
showGetBridgePrompt("scramblesuit");
|
||||
|
||||
setupBridgeType("scramblesuit");
|
||||
enableBridges(true);
|
||||
|
||||
break;
|
||||
case 3: //azure
|
||||
Prefs.setBridgesList("2");
|
||||
|
@ -884,6 +904,9 @@ public class OrbotMainActivity extends AppCompatActivity
|
|||
Prefs.setBridgesList("0");
|
||||
enableBridges(true);
|
||||
|
||||
case 6:
|
||||
showGetBridgePrompt("obfs4");
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -1337,4 +1360,61 @@ public class OrbotMainActivity extends AppCompatActivity
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBridgeDefaults ()
|
||||
{
|
||||
if (alBridges == null)
|
||||
{
|
||||
alBridges = new ArrayList<Bridge>();
|
||||
|
||||
try
|
||||
{
|
||||
BufferedReader in=
|
||||
new BufferedReader(new InputStreamReader(getAssets().open("bridges.txt"), "UTF-8"));
|
||||
String str;
|
||||
|
||||
while ((str=in.readLine()) != null) {
|
||||
|
||||
StringTokenizer st = new StringTokenizer (str," ");
|
||||
Bridge b = new Bridge();
|
||||
b.type = st.nextToken();
|
||||
|
||||
StringBuffer sbConfig = new StringBuffer();
|
||||
|
||||
while(st.hasMoreTokens())
|
||||
sbConfig.append(st.nextToken()).append(' ');
|
||||
|
||||
b.config = sbConfig.toString();
|
||||
|
||||
alBridges.add(b);
|
||||
|
||||
}
|
||||
|
||||
in.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setupBridgeType (String type)
|
||||
{
|
||||
StringBuffer sbConfig = new StringBuffer ();
|
||||
|
||||
for (Bridge b : alBridges)
|
||||
{
|
||||
if (b.type.equals(type))
|
||||
{
|
||||
sbConfig.append(b.type);
|
||||
sbConfig.append(' ');
|
||||
sbConfig.append(b.config);
|
||||
sbConfig.append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
setNewBridges(sbConfig.toString());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue