add support for meek PT
This commit is contained in:
parent
1e5651eec3
commit
bff6d0f567
|
@ -99,6 +99,12 @@ public class TorResourceInstaller implements TorServiceConstants {
|
||||||
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
|
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
|
||||||
streamToFile(is,outFile, false, true);
|
streamToFile(is,outFile, false, true);
|
||||||
|
|
||||||
|
|
||||||
|
is = context.getResources().openRawResource(R.raw.meek);
|
||||||
|
outFile = new File(installFolder, MEEK_ASSET_KEY);
|
||||||
|
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
|
||||||
|
streamToFile(is,outFile, false, true);
|
||||||
|
|
||||||
is = context.getResources().openRawResource(R.raw.xtables);
|
is = context.getResources().openRawResource(R.raw.xtables);
|
||||||
outFile = new File(installFolder, IPTABLES_ASSET_KEY);
|
outFile = new File(installFolder, IPTABLES_ASSET_KEY);
|
||||||
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
|
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
|
||||||
|
|
|
@ -115,6 +115,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
private File fileTor;
|
private File fileTor;
|
||||||
private File filePolipo;
|
private File filePolipo;
|
||||||
private File fileObfsclient;
|
private File fileObfsclient;
|
||||||
|
private File fileMeekclient;
|
||||||
private File fileXtables;
|
private File fileXtables;
|
||||||
|
|
||||||
private File fileTorRc;
|
private File fileTorRc;
|
||||||
|
@ -650,6 +651,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
|
|
||||||
fileObfsclient = new File(appBinHome, OBFSCLIENT_ASSET_KEY);
|
fileObfsclient = new File(appBinHome, OBFSCLIENT_ASSET_KEY);
|
||||||
|
|
||||||
|
fileMeekclient = new File(appBinHome, MEEK_ASSET_KEY);
|
||||||
|
|
||||||
fileTorRc = new File(appBinHome, TORRC_ASSET_KEY);
|
fileTorRc = new File(appBinHome, TORRC_ASSET_KEY);
|
||||||
|
|
||||||
fileXtables = new File(appBinHome, IPTABLES_ASSET_KEY);
|
fileXtables = new File(appBinHome, IPTABLES_ASSET_KEY);
|
||||||
|
@ -770,6 +773,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
|
|
||||||
prefPersistNotifications = prefs.getBoolean(TorConstants.PREF_PERSIST_NOTIFICATIONS, true);
|
prefPersistNotifications = prefs.getBoolean(TorConstants.PREF_PERSIST_NOTIFICATIONS, true);
|
||||||
|
|
||||||
|
mUseVPN = prefs.getBoolean("pref_vpn", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startTor () throws Exception
|
private void startTor () throws Exception
|
||||||
|
@ -784,6 +788,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
enableBinExec(fileTor);
|
enableBinExec(fileTor);
|
||||||
enableBinExec(filePolipo);
|
enableBinExec(filePolipo);
|
||||||
enableBinExec(fileObfsclient);
|
enableBinExec(fileObfsclient);
|
||||||
|
enableBinExec(fileMeekclient);
|
||||||
enableBinExec(fileXtables);
|
enableBinExec(fileXtables);
|
||||||
|
|
||||||
updateSettings ();
|
updateSettings ();
|
||||||
|
@ -791,7 +796,12 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
logNotice(getString(R.string.status_starting_up));
|
logNotice(getString(R.string.status_starting_up));
|
||||||
sendCallbackLogMessage(getString(R.string.status_starting_up));
|
sendCallbackLogMessage(getString(R.string.status_starting_up));
|
||||||
|
|
||||||
Shell shellUser = Shell.startShell();
|
ArrayList<String> customEnv = new ArrayList<String>();
|
||||||
|
// customEnv.add("TOR_PT_MANAGED_TRANSPORT_VER=1");
|
||||||
|
// customEnv.add("TOR_PT_CLIENT_TRANSPORTS=meek");
|
||||||
|
|
||||||
|
String baseDirectory = fileTor.getParent();
|
||||||
|
Shell shellUser = Shell.startShell(customEnv, baseDirectory);
|
||||||
|
|
||||||
boolean success = runTorShellCmd(shellUser);
|
boolean success = runTorShellCmd(shellUser);
|
||||||
|
|
||||||
|
@ -809,10 +819,12 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
|
|
||||||
shellRoot.close();
|
shellRoot.close();
|
||||||
}
|
}
|
||||||
else if (mUseVPN)
|
|
||||||
|
if (mUseVPN) //we need to turn on VPN here so the proxy is running
|
||||||
{
|
{
|
||||||
enableVpnProxy();
|
enableVpnProxy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getHiddenServiceHostname ();
|
getHiddenServiceHostname ();
|
||||||
}
|
}
|
||||||
|
@ -1430,16 +1442,22 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
debug ("enabling VPN Proxy");
|
debug ("enabling VPN Proxy");
|
||||||
|
|
||||||
mUseVPN = true;
|
mUseVPN = true;
|
||||||
|
|
||||||
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
||||||
Editor ePrefs = prefs.edit();
|
Editor ePrefs = prefs.edit();
|
||||||
|
|
||||||
|
ePrefs.putBoolean("pref_vpn", true);
|
||||||
|
|
||||||
|
/*
|
||||||
ePrefs.putString("pref_proxy_type", "socks5");
|
ePrefs.putString("pref_proxy_type", "socks5");
|
||||||
ePrefs.putString("pref_proxy_host", "127.0.0.1");
|
ePrefs.putString("pref_proxy_host", "127.0.0.1");
|
||||||
ePrefs.putString("pref_proxy_port", "9999");
|
ePrefs.putString("pref_proxy_port", "9999");
|
||||||
ePrefs.remove("pref_proxy_username");
|
ePrefs.remove("pref_proxy_username");
|
||||||
ePrefs.remove("pref_proxy_password");
|
ePrefs.remove("pref_proxy_password");
|
||||||
|
*/
|
||||||
|
|
||||||
ePrefs.commit();
|
ePrefs.commit();
|
||||||
|
|
||||||
processSettings();
|
processSettings();
|
||||||
|
|
||||||
Intent intent = new Intent(TorService.this, OrbotVpnService.class);
|
Intent intent = new Intent(TorService.this, OrbotVpnService.class);
|
||||||
|
@ -1455,14 +1473,12 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
|
|
||||||
mUseVPN = false;
|
mUseVPN = false;
|
||||||
|
|
||||||
|
|
||||||
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
||||||
Editor ePrefs = prefs.edit();
|
Editor ePrefs = prefs.edit();
|
||||||
ePrefs.remove("pref_proxy_type");
|
ePrefs.putBoolean("pref_vpn", false);
|
||||||
ePrefs.remove("pref_proxy_host");
|
|
||||||
ePrefs.remove("pref_proxy_port");
|
|
||||||
ePrefs.remove("pref_proxy_username");
|
|
||||||
ePrefs.remove("pref_proxy_password");
|
|
||||||
ePrefs.commit();
|
ePrefs.commit();
|
||||||
|
|
||||||
processSettings();
|
processSettings();
|
||||||
|
|
||||||
Intent intent = new Intent(TorService.this, OrbotVpnService.class);
|
Intent intent = new Intent(TorService.this, OrbotVpnService.class);
|
||||||
|
@ -2090,8 +2106,6 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
*/
|
*/
|
||||||
|
|
||||||
boolean useBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_ENABLED, false);
|
boolean useBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_ENABLED, false);
|
||||||
|
|
||||||
//boolean autoUpdateBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_UPDATED, false);
|
|
||||||
|
|
||||||
boolean becomeRelay = prefs.getBoolean(TorConstants.PREF_OR, false);
|
boolean becomeRelay = prefs.getBoolean(TorConstants.PREF_OR, false);
|
||||||
boolean ReachableAddresses = prefs.getBoolean(TorConstants.PREF_REACHABLE_ADDRESSES,false);
|
boolean ReachableAddresses = prefs.getBoolean(TorConstants.PREF_REACHABLE_ADDRESSES,false);
|
||||||
|
@ -2102,35 +2116,49 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
String exitNodes = prefs.getString("pref_exit_nodes", "");
|
String exitNodes = prefs.getString("pref_exit_nodes", "");
|
||||||
String excludeNodes = prefs.getString("pref_exclude_nodes", "");
|
String excludeNodes = prefs.getString("pref_exclude_nodes", "");
|
||||||
|
|
||||||
String proxyType = prefs.getString("pref_proxy_type", null);
|
if (!useBridges)
|
||||||
if (proxyType != null && proxyType.length() > 0)
|
|
||||||
{
|
{
|
||||||
String proxyHost = prefs.getString("pref_proxy_host", null);
|
if (mUseVPN) //set the proxy here if we aren't using a bridge
|
||||||
String proxyPort = prefs.getString("pref_proxy_port", null);
|
{
|
||||||
String proxyUser = prefs.getString("pref_proxy_username", null);
|
String proxyType = "socks5";
|
||||||
String proxyPass = prefs.getString("pref_proxy_password", null);
|
String proxyHost = "127.0.0.1";
|
||||||
|
int proxyPort = 9999;
|
||||||
if ((proxyHost != null && proxyHost.length()>0) && (proxyPort != null && proxyPort.length() > 0))
|
updateConfiguration(proxyType + "Proxy", proxyHost + ':' + proxyPort, false);
|
||||||
{
|
|
||||||
updateConfiguration(proxyType + "Proxy", proxyHost + ':' + proxyPort, false);
|
}
|
||||||
|
else
|
||||||
if (proxyUser != null && proxyPass != null)
|
{
|
||||||
{
|
String proxyType = prefs.getString("pref_proxy_type", null);
|
||||||
if (proxyType.equalsIgnoreCase("socks5"))
|
if (proxyType != null && proxyType.length() > 0)
|
||||||
{
|
{
|
||||||
updateConfiguration("Socks5ProxyUsername", proxyUser, false);
|
String proxyHost = prefs.getString("pref_proxy_host", null);
|
||||||
updateConfiguration("Socks5ProxyPassword", proxyPass, false);
|
String proxyPort = prefs.getString("pref_proxy_port", null);
|
||||||
}
|
String proxyUser = prefs.getString("pref_proxy_username", null);
|
||||||
else
|
String proxyPass = prefs.getString("pref_proxy_password", null);
|
||||||
updateConfiguration(proxyType + "ProxyAuthenticator", proxyUser + ':' + proxyPort, false);
|
|
||||||
|
if ((proxyHost != null && proxyHost.length()>0) && (proxyPort != null && proxyPort.length() > 0))
|
||||||
}
|
{
|
||||||
else if (proxyPass != null)
|
updateConfiguration(proxyType + "Proxy", proxyHost + ':' + proxyPort, false);
|
||||||
updateConfiguration(proxyType + "ProxyAuthenticator", proxyUser + ':' + proxyPort, false);
|
|
||||||
|
if (proxyUser != null && proxyPass != null)
|
||||||
|
{
|
||||||
|
if (proxyType.equalsIgnoreCase("socks5"))
|
||||||
}
|
{
|
||||||
|
updateConfiguration("Socks5ProxyUsername", proxyUser, false);
|
||||||
|
updateConfiguration("Socks5ProxyPassword", proxyPass, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
updateConfiguration(proxyType + "ProxyAuthenticator", proxyUser + ':' + proxyPort, false);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (proxyPass != null)
|
||||||
|
updateConfiguration(proxyType + "ProxyAuthenticator", proxyUser + ':' + proxyPort, false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entranceNodes.length() > 0 || exitNodes.length() > 0 || excludeNodes.length() > 0)
|
if (entranceNodes.length() > 0 || exitNodes.length() > 0 || excludeNodes.length() > 0)
|
||||||
|
@ -2172,57 +2200,102 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
String bridgeCfgKey = "Bridge";
|
String bridgeCfgKey = "Bridge";
|
||||||
|
|
||||||
String bridgeList = prefs.getString(TorConstants.PREF_BRIDGES_LIST,null);
|
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);
|
|
||||||
debug(msgBridge);
|
|
||||||
|
|
||||||
return false;
|
if (bridgeList != null && bridgeList.length() > 1) //longer then 1 = some real values here
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
String bridgeDelim = "\n";
|
|
||||||
|
|
||||||
if (bridgeList.indexOf(",") != -1)
|
|
||||||
{
|
{
|
||||||
bridgeDelim = ",";
|
String bridgeDelim = "\n";
|
||||||
}
|
|
||||||
|
if (bridgeList.indexOf(",") != -1)
|
||||||
|
{
|
||||||
|
bridgeDelim = ",";
|
||||||
|
}
|
||||||
|
|
||||||
|
showToolbarNotification(getString(R.string.notification_using_bridges) + ": " + bridgeList, TRANSPROXY_NOTIFY_ID, R.drawable.ic_stat_tor);
|
||||||
|
|
||||||
|
StringTokenizer st = new StringTokenizer(bridgeList,bridgeDelim);
|
||||||
|
while (st.hasMoreTokens())
|
||||||
|
{
|
||||||
|
String bridgeConfigLine = st.nextToken().trim();
|
||||||
|
debug("Adding bridge: " + bridgeConfigLine);
|
||||||
|
updateConfiguration(bridgeCfgKey, bridgeConfigLine, false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
showToolbarNotification(getString(R.string.notification_using_bridges) + ": " + bridgeList, TRANSPROXY_NOTIFY_ID, R.drawable.ic_stat_tor);
|
//check if any PT bridges are needed
|
||||||
|
boolean obfsBridges = bridgeList.contains("obfs2")||bridgeList.contains("obfs3")||bridgeList.contains("scramblesuit");
|
||||||
StringTokenizer st = new StringTokenizer(bridgeList,bridgeDelim);
|
|
||||||
while (st.hasMoreTokens())
|
if (obfsBridges)
|
||||||
{
|
{
|
||||||
String bridgeConfigLine = st.nextToken().trim();
|
String bridgeConfig = "obfs2,obfs3,scramblesuit exec " + fileObfsclient.getCanonicalPath();
|
||||||
debug("Adding bridge: " + bridgeConfigLine);
|
|
||||||
updateConfiguration(bridgeCfgKey, bridgeConfigLine, false);
|
debug ("Using OBFUSCATED bridges: " + bridgeConfig);
|
||||||
|
|
||||||
}
|
updateConfiguration("ClientTransportPlugin",bridgeConfig, false);
|
||||||
|
}
|
||||||
//check if any PT bridges are needed
|
|
||||||
boolean obfsBridges = bridgeList.contains("obfs2")||bridgeList.contains("obfs3")||bridgeList.contains("scramblesuit");
|
|
||||||
|
|
||||||
if (obfsBridges)
|
|
||||||
{
|
|
||||||
String bridgeConfig = "obfs2,obfs3,scramblesuit exec " + fileObfsclient.getCanonicalPath();
|
|
||||||
|
|
||||||
debug ("Using OBFUSCATED bridges: " + bridgeConfig);
|
|
||||||
|
|
||||||
updateConfiguration("ClientTransportPlugin",bridgeConfig, false);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
debug ("Using standard bridges");
|
//time to do autobridges, aka meek
|
||||||
|
|
||||||
|
debug ("Using meek bridges");
|
||||||
|
|
||||||
|
String proxyBridge = "";
|
||||||
|
String proxyType = prefs.getString("pref_proxy_type", null);
|
||||||
|
|
||||||
|
if (mUseVPN)
|
||||||
|
{
|
||||||
|
proxyType = "socks5";
|
||||||
|
String proxyHost = "127.0.0.1";
|
||||||
|
int proxyPort = 9999;
|
||||||
|
|
||||||
|
proxyBridge = " proxyurl=" + proxyType + "://" + proxyHost + ':' + proxyPort;
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (proxyType != null && proxyType.length() > 0)
|
||||||
|
{
|
||||||
|
String proxyHost = prefs.getString("pref_proxy_host", null);
|
||||||
|
String proxyPort = prefs.getString("pref_proxy_port", null);
|
||||||
|
|
||||||
|
proxyBridge = " proxyurl=" + proxyType + "://" + proxyHost + ':' + proxyPort;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] meekBridge =
|
||||||
|
{
|
||||||
|
"meek 0.0.2.0:1 url=https://meek-reflect.appspot.com/ front=www.google.com",
|
||||||
|
"meek 0.0.2.0:2 url=https://d2zfqthxsdq309.cloudfront.net/ front=a0.awsstatic.com",
|
||||||
|
"meek 0.0.2.0:3 url=https://az668014.vo.msecnd.net/ front=ajax.aspnetcdn.com"
|
||||||
|
};
|
||||||
|
|
||||||
|
int meekIdx = 2; //let's use Azure by default
|
||||||
|
|
||||||
|
if (bridgeList != null && bridgeList.length() == 1)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
meekIdx = Integer.parseInt(bridgeList);
|
||||||
|
|
||||||
|
if (meekIdx+1 > meekBridge.length)
|
||||||
|
throw new Exception("not valid meek idx");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
debug("invalid meek type; please enter 0=Google, 1=AWS, 2=Azure");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateConfiguration(bridgeCfgKey, meekBridge[meekIdx] + proxyBridge, false);
|
||||||
|
|
||||||
|
String bridgeConfig = "meek exec " + fileMeekclient.getCanonicalPath();// + " --log /data/local/tmp/meek-tor.log";
|
||||||
|
|
||||||
|
//updateConfiguration(bridgeCfgKey, "meek 0.0.2.0:1", false);
|
||||||
|
//String bridgeConfig = "meek exec " + fileMeekclient.getCanonicalPath() + " --url=https://meek-reflect.appspot.com/ --front=www.google.com --log meek-client.log";
|
||||||
|
|
||||||
|
updateConfiguration("ClientTransportPlugin",bridgeConfig, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
updateConfiguration("UpdateBridgesFromAuthority", "0", false);
|
// updateConfiguration("UpdateBridgesFromAuthority", "0", false);
|
||||||
|
|
||||||
|
|
||||||
updateConfiguration("UseBridges", "1", false);
|
updateConfiguration("UseBridges", "1", false);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,11 @@ public interface TorServiceConstants {
|
||||||
//obfsproxy
|
//obfsproxy
|
||||||
public static final String OBFSCLIENT_ASSET_KEY = "obfsclient";
|
public static final String OBFSCLIENT_ASSET_KEY = "obfsclient";
|
||||||
|
|
||||||
|
public static final String MEEK_ASSET_KEY = "meek-client";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static final int MESSAGE_TRAFFIC_COUNT = 5;
|
public static final int MESSAGE_TRAFFIC_COUNT = 5;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue