fixes for settings processing and QRCode scanning of bridges
- support new JSON array form bridges.torproject.org - only enable TransProxy and DNSPort settings if the user enables transproxy
This commit is contained in:
parent
4b31ef849a
commit
8f7165ce57
|
@ -56,6 +56,8 @@ import android.widget.ToggleButton;
|
||||||
import com.google.zxing.integration.android.IntentIntegrator;
|
import com.google.zxing.integration.android.IntentIntegrator;
|
||||||
import com.google.zxing.integration.android.IntentResult;
|
import com.google.zxing.integration.android.IntentResult;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
import org.torproject.android.service.TorService;
|
import org.torproject.android.service.TorService;
|
||||||
import org.torproject.android.service.TorServiceConstants;
|
import org.torproject.android.service.TorServiceConstants;
|
||||||
import org.torproject.android.service.TorServiceUtils;
|
import org.torproject.android.service.TorServiceUtils;
|
||||||
|
@ -263,11 +265,11 @@ public class OrbotMainActivity extends Activity
|
||||||
boolean useVPN = Prefs.useVpn();
|
boolean useVPN = Prefs.useVpn();
|
||||||
mBtnVPN.setChecked(useVPN);
|
mBtnVPN.setChecked(useVPN);
|
||||||
|
|
||||||
/**
|
//auto start VPN if VPN is enabled
|
||||||
if (useVPN)
|
if (useVPN)
|
||||||
{
|
{
|
||||||
startActivity(new Intent(OrbotMainActivity.this,VPNEnableActivity.class));
|
startActivity(new Intent(OrbotMainActivity.this,VPNEnableActivity.class));
|
||||||
}*/
|
}
|
||||||
|
|
||||||
mBtnVPN.setOnClickListener(new View.OnClickListener ()
|
mBtnVPN.setOnClickListener(new View.OnClickListener ()
|
||||||
{
|
{
|
||||||
|
@ -827,16 +829,31 @@ public class OrbotMainActivity extends Activity
|
||||||
if (results != null && results.length() > 0)
|
if (results != null && results.length() > 0)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
results = URLDecoder.decode(results, "UTF-8");
|
|
||||||
|
|
||||||
int urlIdx = results.indexOf("://");
|
int urlIdx = results.indexOf("://");
|
||||||
|
|
||||||
if (urlIdx!=-1)
|
if (urlIdx!=-1)
|
||||||
|
{
|
||||||
|
results = URLDecoder.decode(results, "UTF-8");
|
||||||
results = results.substring(urlIdx+3);
|
results = results.substring(urlIdx+3);
|
||||||
|
setNewBridges(results);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
JSONArray bridgeJson = new JSONArray(results);
|
||||||
|
StringBuffer bridgeLines = new StringBuffer();
|
||||||
|
|
||||||
setNewBridges(results);
|
for (int i = 0; i < bridgeJson.length(); i++)
|
||||||
|
{
|
||||||
|
String bridgeLine = bridgeJson.getString(i);
|
||||||
|
bridgeLines.append(bridgeLine).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
setNewBridges(bridgeLines.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
Log.e(TAG,"unsupported",e);
|
Log.e(TAG,"unsupported",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,6 +133,8 @@ public class TorResourceInstaller implements TorServiceConstants {
|
||||||
streamToFile(is,outFile, false, true);
|
streamToFile(is,outFile, false, true);
|
||||||
setExecutable(outFile);
|
setExecutable(outFile);
|
||||||
|
|
||||||
|
installGeoIP();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,14 +198,14 @@ public class TorResourceInstaller implements TorServiceConstants {
|
||||||
* Extract the Tor binary from the APK file using ZIP
|
* Extract the Tor binary from the APK file using ZIP
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public boolean installGeoIP () throws IOException, FileNotFoundException
|
private boolean installGeoIP () throws IOException, FileNotFoundException
|
||||||
{
|
{
|
||||||
|
|
||||||
InputStream is;
|
InputStream is;
|
||||||
File outFile;
|
File outFile;
|
||||||
|
|
||||||
is = context.getResources().openRawResource(R.raw.geoip);
|
|
||||||
outFile = new File(installFolder, GEOIP_ASSET_KEY);
|
outFile = new File(installFolder, GEOIP_ASSET_KEY);
|
||||||
|
is = context.getResources().openRawResource(R.raw.geoip);
|
||||||
streamToFile(is, outFile, false, true);
|
streamToFile(is, outFile, false, true);
|
||||||
|
|
||||||
is = context.getResources().openRawResource(R.raw.geoip6);
|
is = context.getResources().openRawResource(R.raw.geoip6);
|
||||||
|
|
|
@ -621,8 +621,8 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
|
||||||
fileControlPort = new File(OrbotApp.appBinHome, "control.txt");
|
fileControlPort = new File(OrbotApp.appBinHome, "control.txt");
|
||||||
extraLines.append(TORRC_CONTROLPORT_FILE_KEY).append(' ').append(fileControlPort.getCanonicalPath()).append('\n');
|
extraLines.append(TORRC_CONTROLPORT_FILE_KEY).append(' ').append(fileControlPort.getCanonicalPath()).append('\n');
|
||||||
|
|
||||||
extraLines.append("RunAsDaemon 1").append('\n');
|
// extraLines.append("RunAsDaemon 1").append('\n');
|
||||||
extraLines.append("AvoidDiskWrites 1").append('\n');
|
// extraLines.append("AvoidDiskWrites 1").append('\n');
|
||||||
|
|
||||||
String socksPortPref = prefs.getString(OrbotConstants.PREF_SOCKS,
|
String socksPortPref = prefs.getString(OrbotConstants.PREF_SOCKS,
|
||||||
String.valueOf(TorServiceConstants.SOCKS_PROXY_PORT_DEFAULT));
|
String.valueOf(TorServiceConstants.SOCKS_PROXY_PORT_DEFAULT));
|
||||||
|
@ -634,17 +634,25 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
|
||||||
extraLines.append("TestSocks 0").append('\n');
|
extraLines.append("TestSocks 0").append('\n');
|
||||||
extraLines.append("WarnUnsafeSocks 1").append('\n');
|
extraLines.append("WarnUnsafeSocks 1").append('\n');
|
||||||
|
|
||||||
extraLines.append("TransPort ").append("auto").append('\n');
|
if (Prefs.useTransparentProxying())
|
||||||
extraLines.append("DNSPort ").append(TorServiceConstants.TOR_DNS_PORT_DEFAULT).append("\n");
|
|
||||||
|
|
||||||
if (Prefs.transparentTethering())
|
|
||||||
{
|
{
|
||||||
extraLines.append("TransListenAddress 0.0.0.0").append('\n');
|
|
||||||
extraLines.append("DNSListenAddress 0.0.0.0").append('\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
extraLines.append("VirtualAddrNetwork 10.192.0.0/10").append('\n');
|
String transPort = prefs.getString("pref_transport", TorServiceConstants.TOR_TRANSPROXY_PORT_DEFAULT+"");
|
||||||
extraLines.append("AutomapHostsOnResolve 1").append('\n');
|
String dnsPort = prefs.getString("pref_dnsport", TorServiceConstants.TOR_DNS_PORT_DEFAULT+"");
|
||||||
|
|
||||||
|
extraLines.append("TransPort ").append(transPort).append('\n');
|
||||||
|
extraLines.append("DNSPort ").append(dnsPort).append("\n");
|
||||||
|
|
||||||
|
if (Prefs.transparentTethering())
|
||||||
|
{
|
||||||
|
extraLines.append("TransListenAddress 0.0.0.0").append('\n');
|
||||||
|
extraLines.append("DNSListenAddress 0.0.0.0").append('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
extraLines.append("VirtualAddrNetwork 10.192.0.0/10").append('\n');
|
||||||
|
extraLines.append("AutomapHostsOnResolve 1").append('\n');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
extraLines.append("DisableNetwork 0").append('\n');
|
extraLines.append("DisableNetwork 0").append('\n');
|
||||||
|
|
||||||
|
@ -654,7 +662,6 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
|
||||||
extraLines.append("Log info syslog").append('\n');
|
extraLines.append("Log info syslog").append('\n');
|
||||||
extraLines.append("SafeLogging 0").append('\n');
|
extraLines.append("SafeLogging 0").append('\n');
|
||||||
|
|
||||||
//extraLines.append("Log debug stdout").append('\n');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
processSettingsImpl(extraLines);
|
processSettingsImpl(extraLines);
|
||||||
|
@ -1937,17 +1944,6 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
|
||||||
|
|
||||||
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
||||||
|
|
||||||
/*
|
|
||||||
String socksConfig = prefs.getString(TorConstants.PREF_SOCKS, TorServiceConstants.PORT_SOCKS_DEFAULT);
|
|
||||||
|
|
||||||
enableSocks (socksConfig,false);
|
|
||||||
|
|
||||||
String transPort = prefs.getString("pref_transport", TorServiceConstants.TOR_TRANSPROXY_PORT_DEFAULT+"");
|
|
||||||
String dnsPort = prefs.getString("pref_dnsport", TorServiceConstants.TOR_DNS_PORT_DEFAULT+"");
|
|
||||||
|
|
||||||
enableTransProxyAndDNSPorts(transPort, dnsPort);
|
|
||||||
*/
|
|
||||||
|
|
||||||
boolean useBridges = Prefs.bridgesEnabled();
|
boolean useBridges = Prefs.bridgesEnabled();
|
||||||
|
|
||||||
boolean becomeRelay = prefs.getBoolean(OrbotConstants.PREF_OR, false);
|
boolean becomeRelay = prefs.getBoolean(OrbotConstants.PREF_OR, false);
|
||||||
|
@ -2034,11 +2030,11 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
|
||||||
|
|
||||||
for (String bridgeConfigLine : bridgeListLines)
|
for (String bridgeConfigLine : bridgeListLines)
|
||||||
{
|
{
|
||||||
if (bridgeConfigLine != null && bridgeConfigLine.length() > 0)
|
if (!TextUtils.isEmpty(bridgeConfigLine))
|
||||||
{
|
{
|
||||||
extraLines.append("Bridge ");
|
extraLines.append("Bridge ");
|
||||||
|
|
||||||
bridgeConfigLine = bridgeConfigLine.replace('<27>', ' ');
|
//bridgeConfigLine = bridgeConfigLine.replace('<27>', ' ');
|
||||||
|
|
||||||
StringTokenizer st = new StringTokenizer (bridgeConfigLine," ");
|
StringTokenizer st = new StringTokenizer (bridgeConfigLine," ");
|
||||||
while (st.hasMoreTokens())
|
while (st.hasMoreTokens())
|
||||||
|
@ -2093,14 +2089,12 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
|
||||||
if (entranceNodes.length() > 0 || exitNodes.length() > 0 || excludeNodes.length() > 0)
|
if (entranceNodes.length() > 0 || exitNodes.length() > 0 || excludeNodes.length() > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (enableGeoIP ())
|
//only apply GeoIP if you need it
|
||||||
{ //only apply GeoIP if you need it
|
File fileGeoIP = new File(OrbotApp.appBinHome, GEOIP_ASSET_KEY);
|
||||||
File fileGeoIP = new File(OrbotApp.appBinHome, GEOIP_ASSET_KEY);
|
File fileGeoIP6 = new File(OrbotApp.appBinHome, GEOIP6_ASSET_KEY);
|
||||||
File fileGeoIP6 = new File(OrbotApp.appBinHome, GEOIP6_ASSET_KEY);
|
|
||||||
|
|
||||||
extraLines.append("GeoIPFile" + ' ' + fileGeoIP.getCanonicalPath()).append('\n');
|
extraLines.append("GeoIPFile" + ' ' + fileGeoIP.getCanonicalPath()).append('\n');
|
||||||
extraLines.append("GeoIPv6File" + ' ' + fileGeoIP6.getCanonicalPath()).append('\n');
|
extraLines.append("GeoIPv6File" + ' ' + fileGeoIP6.getCanonicalPath()).append('\n');
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2354,9 +2348,6 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
enableGeoIP ();
|
|
||||||
|
|
||||||
File fileGeoIP = new File(OrbotApp.appBinHome, GEOIP_ASSET_KEY);
|
File fileGeoIP = new File(OrbotApp.appBinHome, GEOIP_ASSET_KEY);
|
||||||
File fileGeoIP6 = new File(OrbotApp.appBinHome, GEOIP6_ASSET_KEY);
|
File fileGeoIP6 = new File(OrbotApp.appBinHome, GEOIP6_ASSET_KEY);
|
||||||
|
|
||||||
|
@ -2370,8 +2361,6 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
|
||||||
conn.setConf("DisableNetwork","0");
|
conn.setConf("DisableNetwork","0");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (IOException ioe)
|
catch (IOException ioe)
|
||||||
{
|
{
|
||||||
|
@ -2380,33 +2369,6 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean enableGeoIP ()
|
|
||||||
{
|
|
||||||
File fileGeoIP = new File(OrbotApp.appBinHome, GEOIP_ASSET_KEY);
|
|
||||||
File fileGeoIP6 = new File(OrbotApp.appBinHome, GEOIP6_ASSET_KEY);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if ((!fileGeoIP.exists()))
|
|
||||||
{
|
|
||||||
TorResourceInstaller installer = new TorResourceInstaller(this, OrbotApp.appBinHome);
|
|
||||||
boolean success = installer.installGeoIP();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
showToolbarNotification (getString(R.string.error_installing_binares),ERROR_NOTIFY_ID,R.drawable.ic_stat_notifyerr);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,7 @@ public interface TorServiceConstants {
|
||||||
public final static String PDNSD_ASSET_KEY = "pdnsd";
|
public final static String PDNSD_ASSET_KEY = "pdnsd";
|
||||||
|
|
||||||
//EXIT COUNTRY CODES
|
//EXIT COUNTRY CODES
|
||||||
public final static String[] COUNTRY_CODES = {"DE","AT","SE","CH","IS","CA","US","FR","BG","AU","BR","CZ","DK","FI","GB","HU","NL","JP","HK","RO","RU","SG","SK","CN"};
|
public final static String[] COUNTRY_CODES = {"DE","AT","SE","CH","IS","CA","US","ES","FR","BG","PL","AU","BR","CZ","DK","FI","GB","HU","NL","JP","RO","RU","SG","SK"};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue