fix bridge/PT enable code based on bridge types

This commit is contained in:
Nathan Freitas 2014-05-04 00:35:14 -04:00
parent 9096f8c7b8
commit 53673dae75
2 changed files with 34 additions and 32 deletions

View File

@ -32,7 +32,7 @@ public interface TorConstants {
public final static String PREF_BRIDGES_ENABLED = "pref_bridges_enabled";
public final static String PREF_BRIDGES_UPDATED = "pref_bridges_enabled";
public final static String PREF_BRIDGES_LIST = "pref_bridges_list";
public final static String PREF_BRIDGES_OBFUSCATED = "pref_bridges_obfuscated";
//public final static String PREF_BRIDGES_OBFUSCATED = "pref_bridges_obfuscated";
public final static String PREF_OR = "pref_or";
public final static String PREF_OR_PORT = "pref_or_port";
public final static String PREF_OR_NICKNAME = "pref_or_nickname";

View File

@ -1710,9 +1710,41 @@ public class TorService extends Service implements TorServiceConstants, TorConst
{
logMessage ("Using bridges");
boolean obfsBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_OBFUSCATED, false);
String bridgeCfgKey = "Bridge";
String bridgeList = prefs.getString(TorConstants.PREF_BRIDGES_LIST,null);
if (bridgeList == null || bridgeList.length() == 0)
{
String msgBridge = getString(R.string.bridge_requires_ip) +
getString(R.string.send_email_for_bridges);
showToolbarNotification(msgBridge, ERROR_NOTIFY_ID, R.drawable.ic_stat_tor, -1, false);
logMessage(msgBridge);
return false;
}
String bridgeDelim = "\n";
if (bridgeList.indexOf(",") != -1)
{
bridgeDelim = ",";
}
showToolbarNotification(getString(R.string.notification_using_bridges) + ": " + bridgeList, TRANSPROXY_NOTIFY_ID, R.drawable.ic_stat_tor, -1, false);
StringTokenizer st = new StringTokenizer(bridgeList,bridgeDelim);
while (st.hasMoreTokens())
{
String bridgeConfigLine = st.nextToken().trim();
logMessage("Adding bridge: " + bridgeConfigLine);
mBinder.updateConfiguration(bridgeCfgKey, bridgeConfigLine, false);
}
//check if any PT bridges are needed
boolean obfsBridges = bridgeList.contains("obfs2")||bridgeList.contains("obfs3")||bridgeList.contains("scramblesuit");
if (obfsBridges)
{
@ -1727,37 +1759,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
logMessage ("Using standard bridges");
}
String bridgeList = prefs.getString(TorConstants.PREF_BRIDGES_LIST,null);
if (bridgeList == null || bridgeList.length() == 0)
{
String msgBridge = getString(R.string.bridge_requires_ip) +
getString(R.string.send_email_for_bridges);
showToolbarNotification(msgBridge, ERROR_NOTIFY_ID, R.drawable.ic_stat_tor, -1, false);
logMessage(msgBridge);
return false;
}
String bridgeDelim = "\n";
if (bridgeList.indexOf(",") != -1)
{
bridgeDelim = ",";
}
showToolbarNotification(getString(R.string.notification_using_bridges) + ": " + bridgeList, TRANSPROXY_NOTIFY_ID, R.drawable.ic_stat_tor, -1, false);
StringTokenizer st = new StringTokenizer(bridgeList,bridgeDelim);
while (st.hasMoreTokens())
{
String bridgeConfigLine = st.nextToken().trim();
logMessage("Adding bridge: " + bridgeConfigLine);
mBinder.updateConfiguration(bridgeCfgKey, bridgeConfigLine, false);
}
mBinder.updateConfiguration("UpdateBridgesFromAuthority", "0", false);