more bridge and proxy configuration clean up
This commit is contained in:
parent
f2490d9032
commit
068cd05836
|
@ -55,7 +55,6 @@ import org.torproject.android.settings.TorifiedApp;
|
||||||
import org.torproject.android.vpn.OrbotVpnService;
|
import org.torproject.android.vpn.OrbotVpnService;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
|
@ -545,11 +544,13 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
|
|
||||||
conn = null;
|
conn = null;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
killProcess(fileTor);
|
killProcess(fileTor);
|
||||||
|
|
||||||
killProcess(filePolipo);
|
killProcess(filePolipo);
|
||||||
// killProcess(fileObfsclient);
|
killProcess(fileObfsclient);
|
||||||
|
killProcess(fileMeekclient);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,9 +564,9 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
|
|
||||||
logNotice("Found " + fileProcBin.getName() + " PID=" + procId + " - killing now...");
|
logNotice("Found " + fileProcBin.getName() + " PID=" + procId + " - killing now...");
|
||||||
|
|
||||||
SimpleCommand killCommand = new SimpleCommand("toolbox kill " + procId);
|
SimpleCommand killCommand = new SimpleCommand("toolbox kill -9 " + procId);
|
||||||
shell.add(killCommand);
|
shell.add(killCommand);
|
||||||
killCommand = new SimpleCommand("kill " + procId);
|
killCommand = new SimpleCommand("kill -9 " + procId);
|
||||||
shell.add(killCommand);
|
shell.add(killCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -711,6 +712,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
extraLines.append("VirtualAddrNetwork 10.192.0.0/10").append('\n');
|
extraLines.append("VirtualAddrNetwork 10.192.0.0/10").append('\n');
|
||||||
extraLines.append("AutomapHostsOnResolve 1").append('\n');
|
extraLines.append("AutomapHostsOnResolve 1").append('\n');
|
||||||
|
|
||||||
|
extraLines.append("DisableNetwork 0").append('\n');
|
||||||
|
|
||||||
|
|
||||||
extraLines.append("CircuitStreamTimeout 60").append('\n');
|
extraLines.append("CircuitStreamTimeout 60").append('\n');
|
||||||
|
|
||||||
|
@ -797,8 +800,13 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
sendCallbackLogMessage(getString(R.string.status_starting_up));
|
sendCallbackLogMessage(getString(R.string.status_starting_up));
|
||||||
|
|
||||||
ArrayList<String> customEnv = new ArrayList<String>();
|
ArrayList<String> customEnv = new ArrayList<String>();
|
||||||
// customEnv.add("TOR_PT_MANAGED_TRANSPORT_VER=1");
|
|
||||||
// customEnv.add("TOR_PT_CLIENT_TRANSPORTS=meek");
|
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
||||||
|
boolean useBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_ENABLED, false);
|
||||||
|
|
||||||
|
if (useBridges)
|
||||||
|
if (mUseVPN)
|
||||||
|
customEnv.add("TOR_PT_PROXY=http://127.0.0.1:9998");
|
||||||
|
|
||||||
String baseDirectory = fileTor.getParent();
|
String baseDirectory = fileTor.getParent();
|
||||||
Shell shellUser = Shell.startShell(customEnv, baseDirectory);
|
Shell shellUser = Shell.startShell(customEnv, baseDirectory);
|
||||||
|
@ -1423,8 +1431,6 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (newState == STATUS_OFF)
|
else if (newState == STATUS_OFF)
|
||||||
{
|
|
||||||
if (mCurrentStatus == STATUS_ON)
|
|
||||||
{
|
{
|
||||||
sendCallbackLogMessage (getString(R.string.status_shutting_down));
|
sendCallbackLogMessage (getString(R.string.status_shutting_down));
|
||||||
|
|
||||||
|
@ -1432,7 +1438,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
|
|
||||||
mCurrentStatus = STATUS_OFF;
|
mCurrentStatus = STATUS_OFF;
|
||||||
sendCallbackStatus(mCurrentStatus);
|
sendCallbackStatus(mCurrentStatus);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1445,17 +1451,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
|
|
||||||
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
||||||
Editor ePrefs = prefs.edit();
|
Editor ePrefs = prefs.edit();
|
||||||
|
|
||||||
ePrefs.putBoolean("pref_vpn", true);
|
ePrefs.putBoolean("pref_vpn", true);
|
||||||
|
|
||||||
/*
|
|
||||||
ePrefs.putString("pref_proxy_type", "socks5");
|
|
||||||
ePrefs.putString("pref_proxy_host", "127.0.0.1");
|
|
||||||
ePrefs.putString("pref_proxy_port", "9999");
|
|
||||||
ePrefs.remove("pref_proxy_username");
|
|
||||||
ePrefs.remove("pref_proxy_password");
|
|
||||||
*/
|
|
||||||
|
|
||||||
ePrefs.commit();
|
ePrefs.commit();
|
||||||
|
|
||||||
processSettings();
|
processSettings();
|
||||||
|
@ -2118,6 +2114,9 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
|
|
||||||
if (!useBridges)
|
if (!useBridges)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
updateConfiguration("UseBridges", "0", false);
|
||||||
|
|
||||||
if (mUseVPN) //set the proxy here if we aren't using a bridge
|
if (mUseVPN) //set the proxy here if we aren't using a bridge
|
||||||
{
|
{
|
||||||
String proxyType = "socks5";
|
String proxyType = "socks5";
|
||||||
|
@ -2160,40 +2159,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (entranceNodes.length() > 0 || exitNodes.length() > 0 || excludeNodes.length() > 0)
|
|
||||||
{
|
|
||||||
//only apply GeoIP if you need it
|
|
||||||
File fileGeoIP = new File(appBinHome,GEOIP_ASSET_KEY);
|
|
||||||
File fileGeoIP6 = new File(appBinHome,GEOIP6_ASSET_KEY);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if ((!fileGeoIP.exists()))
|
|
||||||
{
|
|
||||||
TorResourceInstaller installer = new TorResourceInstaller(this, appBinHome);
|
|
||||||
boolean success = installer.installGeoIP();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
updateConfiguration("GeoIPFile", fileGeoIP.getCanonicalPath(), false);
|
|
||||||
updateConfiguration("GeoIPv6File", fileGeoIP6.getCanonicalPath(), false);
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
showToolbarNotification (getString(R.string.error_installing_binares),ERROR_NOTIFY_ID,R.drawable.ic_stat_notifyerr);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updateConfiguration("EntryNodes", entranceNodes, false);
|
|
||||||
updateConfiguration("ExitNodes", exitNodes, false);
|
|
||||||
updateConfiguration("ExcludeNodes", excludeNodes, false);
|
|
||||||
updateConfiguration("StrictNodes", enableStrictNodes ? "1" : "0", false);
|
|
||||||
|
|
||||||
if (useBridges)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
debug ("Using bridges");
|
debug ("Using bridges");
|
||||||
|
@ -2237,8 +2203,6 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
{
|
{
|
||||||
//time to do autobridges, aka meek
|
//time to do autobridges, aka meek
|
||||||
|
|
||||||
debug ("Using meek bridges");
|
|
||||||
|
|
||||||
String proxyBridge = "";
|
String proxyBridge = "";
|
||||||
String proxyType = prefs.getString("pref_proxy_type", null);
|
String proxyType = prefs.getString("pref_proxy_type", null);
|
||||||
|
|
||||||
|
@ -2248,7 +2212,9 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
String proxyHost = "127.0.0.1";
|
String proxyHost = "127.0.0.1";
|
||||||
int proxyPort = 9998; //9999;
|
int proxyPort = 9998; //9999;
|
||||||
|
|
||||||
proxyBridge = " proxy=" + proxyType + "://" + proxyHost + ':' + proxyPort;
|
//proxyBridge = " proxy=" + proxyType + "://" + proxyHost + ':' + proxyPort; //proxy=http://127.0.0.1:9998
|
||||||
|
// updateConfiguration(proxyType + "Proxy", proxyHost + ':' + proxyPort, false);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (proxyType != null && proxyType.length() > 0)
|
else if (proxyType != null && proxyType.length() > 0)
|
||||||
|
@ -2256,10 +2222,17 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
String proxyHost = prefs.getString("pref_proxy_host", null);
|
String proxyHost = prefs.getString("pref_proxy_host", null);
|
||||||
String proxyPort = prefs.getString("pref_proxy_port", null);
|
String proxyPort = prefs.getString("pref_proxy_port", null);
|
||||||
|
|
||||||
proxyBridge = " proxyurl=" + proxyType + "://" + proxyHost + ':' + proxyPort;
|
//proxyBridge = " proxy=" + proxyType + "://" + proxyHost + ':' + proxyPort;
|
||||||
|
updateConfiguration(proxyType + "Proxy", proxyHost + ':' + proxyPort, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug ("Using meek bridges");
|
||||||
|
|
||||||
|
String bridgeConfig = "meek exec " + fileMeekclient.getCanonicalPath();
|
||||||
|
updateConfiguration("ClientTransportPlugin",bridgeConfig, false);
|
||||||
|
|
||||||
|
|
||||||
String[] meekBridge =
|
String[] meekBridge =
|
||||||
{
|
{
|
||||||
"meek 0.0.2.0:1 url=https://meek-reflect.appspot.com/ front=www.google.com",
|
"meek 0.0.2.0:1 url=https://meek-reflect.appspot.com/ front=www.google.com",
|
||||||
|
@ -2286,12 +2259,6 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
|
|
||||||
updateConfiguration(bridgeCfgKey, meekBridge[meekIdx] + proxyBridge, false);
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2300,12 +2267,41 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (entranceNodes.length() > 0 || exitNodes.length() > 0 || excludeNodes.length() > 0)
|
||||||
{
|
{
|
||||||
updateConfiguration("UseBridges", "0", false);
|
//only apply GeoIP if you need it
|
||||||
|
File fileGeoIP = new File(appBinHome,GEOIP_ASSET_KEY);
|
||||||
|
File fileGeoIP6 = new File(appBinHome,GEOIP6_ASSET_KEY);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ((!fileGeoIP.exists()))
|
||||||
|
{
|
||||||
|
TorResourceInstaller installer = new TorResourceInstaller(this, appBinHome);
|
||||||
|
boolean success = installer.installGeoIP();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateConfiguration("GeoIPFile", fileGeoIP.getCanonicalPath(), false);
|
||||||
|
updateConfiguration("GeoIPv6File", fileGeoIP6.getCanonicalPath(), false);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
showToolbarNotification (getString(R.string.error_installing_binares),ERROR_NOTIFY_ID,R.drawable.ic_stat_notifyerr);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateConfiguration("EntryNodes", entranceNodes, false);
|
||||||
|
updateConfiguration("ExitNodes", exitNodes, false);
|
||||||
|
updateConfiguration("ExcludeNodes", excludeNodes, false);
|
||||||
|
updateConfiguration("StrictNodes", enableStrictNodes ? "1" : "0", false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (ReachableAddresses)
|
if (ReachableAddresses)
|
||||||
|
@ -2387,15 +2383,14 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
|
|
||||||
debug("Adding hidden service on port: " + hsPortConfig);
|
debug("Adding hidden service on port: " + hsPortConfig);
|
||||||
|
|
||||||
|
|
||||||
updateConfiguration("HiddenServiceDir",hsDirPath, false);
|
updateConfiguration("HiddenServiceDir",hsDirPath, false);
|
||||||
updateConfiguration("HiddenServicePort",hsPortConfig, false);
|
updateConfiguration("HiddenServicePort",hsPortConfig, false);
|
||||||
|
|
||||||
|
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Log.e(this.TAG,"error parsing hsport",e);
|
Log.e(TAG,"error parsing hsport",e);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(this.TAG,"error starting share server",e);
|
Log.e(TAG,"error starting share server",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2412,6 +2407,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
updateConfiguration("DNSListenAddress","10.0.0.1:" + TorServiceConstants.TOR_DNS_PORT_DEFAULT,false);
|
updateConfiguration("DNSListenAddress","10.0.0.1:" + TorServiceConstants.TOR_DNS_PORT_DEFAULT,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// updateConfiguration("DisableNetwork","0", false);
|
||||||
|
|
||||||
saveConfiguration();
|
saveConfiguration();
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ public interface TorServiceConstants {
|
||||||
public static final String CMD_UPDATE = "update";
|
public static final String CMD_UPDATE = "update";
|
||||||
|
|
||||||
|
|
||||||
public static final String BINARY_TOR_VERSION = "0.2.5.10-openssl1.0.1i-nonPIE-polipofix";
|
public static final String BINARY_TOR_VERSION = "0.2.5.10-openssl1.0.1i-PIE-bridgepatch";
|
||||||
public static final String PREF_BINARY_TOR_VERSION_INSTALLED = "BINARY_TOR_VERSION_INSTALLED";
|
public static final String PREF_BINARY_TOR_VERSION_INSTALLED = "BINARY_TOR_VERSION_INSTALLED";
|
||||||
|
|
||||||
//obfsproxy
|
//obfsproxy
|
||||||
|
|
Loading…
Reference in New Issue