tor-commits
Threads by month
- ----- 2025 -----
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
April 2015
- 19 participants
- 1110 discussions

[orbot/master] a little bit of code re-org and new package for wizard
by n8fr8@torproject.org 03 Apr '15
by n8fr8@torproject.org 03 Apr '15
03 Apr '15
commit 6a7c593353f725d6fb3863ad04220061c60d942c
Author: Nathan Freitas <nathan(a)freitas.net>
Date: Sat Mar 28 00:39:58 2015 -0400
a little bit of code re-org and new package for wizard
---
AndroidManifest.xml | 4 +-
res/menu/orbot_main.xml | 8 +-
res/values/strings.xml | 2 +
src/org/torproject/android/OrbotApp.java | 2 +-
src/org/torproject/android/OrbotConstants.java | 55 +++++
src/org/torproject/android/OrbotMainActivity.java | 35 ++--
src/org/torproject/android/TorConstants.java | 55 -----
.../android/service/TorResourceInstaller.java | 4 +-
src/org/torproject/android/service/TorService.java | 26 +--
.../android/service/TorServiceUtils.java | 6 +-
.../torproject/android/service/TorTransProxy.java | 6 +-
.../torproject/android/settings/AppManager.java | 4 +-
.../android/ui/ChooseLocaleWizardActivity.java | 135 -------------
.../torproject/android/ui/OrbotLogActivity.java | 4 +-
src/org/torproject/android/ui/TipsAndTricks.java | 213 --------------------
.../ui/wizard/ChooseLocaleWizardActivity.java | 135 +++++++++++++
.../android/ui/wizard/TipsAndTricks.java | 213 ++++++++++++++++++++
17 files changed, 459 insertions(+), 448 deletions(-)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 0dbd192..ee624d8 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -88,8 +88,8 @@
/>
- <activity android:name=".ui.TipsAndTricks" android:exported="false"/>
- <activity android:name=".ui.ChooseLocaleWizardActivity" android:exported="false"/>
+ <activity android:name="org.torproject.android.ui.wizard.TipsAndTricks" android:exported="false"/>
+ org.torproject.android.ui.wizard.ChooseLocaleWizardActivityui.ChooseLocaleWizardActivity" android:exported="false"/>
<activity android:name=".settings.SettingsPreferences" android:label="@string/app_name"/>
<activity android:name=".settings.AppManager" android:label="@string/app_name"/>
diff --git a/res/menu/orbot_main.xml b/res/menu/orbot_main.xml
index 55e5b17..cff67e9 100644
--- a/res/menu/orbot_main.xml
+++ b/res/menu/orbot_main.xml
@@ -26,6 +26,11 @@
yourapp:showAsAction="always"
/>
+ <item
+ android:title="@string/menu_qr"
+ yourapp:showAsAction="never"
+ >
+ <menu>
<item android:id="@+id/menu_scan"
android:title="@string/menu_scan"
yourapp:showAsAction="never"
@@ -35,7 +40,8 @@
android:title="@string/menu_share_bridge"
yourapp:showAsAction="never"
/>
-
+ </menu>
+ </item>
<!--
<item android:id="@+id/menu_verify"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1b7b0cc..f5a1fe7 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -316,4 +316,6 @@
<string name="bridges_updated">Bridges Updated</string>
<string name="restart_orbot_to_use_this_bridge_">"Restart Orbot to use these bridges: "</string>
+
+ <string name="menu_qr">QR Codes</string>
</resources>
diff --git a/src/org/torproject/android/OrbotApp.java b/src/org/torproject/android/OrbotApp.java
index cb1824c..4e6d9ec 100644
--- a/src/org/torproject/android/OrbotApp.java
+++ b/src/org/torproject/android/OrbotApp.java
@@ -9,7 +9,7 @@ import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.preference.PreferenceManager;
-public class OrbotApp extends Application implements TorConstants
+public class OrbotApp extends Application implements OrbotConstants
{
private Locale locale;
diff --git a/src/org/torproject/android/OrbotConstants.java b/src/org/torproject/android/OrbotConstants.java
new file mode 100644
index 0000000..e400851
--- /dev/null
+++ b/src/org/torproject/android/OrbotConstants.java
@@ -0,0 +1,55 @@
+/* Copyright (c) 2009, Nathan Freitas, Orbot/The Guardian Project - http://openideals.com/guardian */
+/* See LICENSE for licensing information */
+
+package org.torproject.android;
+
+public interface OrbotConstants {
+
+ public final static String TAG = "Orbot";
+
+
+ public final static String PREFS_KEY = "OrbotPrefs";
+ public final static String PREFS_KEY_TORIFIED = "PrefTord";
+
+ public final static int FILE_WRITE_BUFFER_SIZE = 2048;
+
+ //path to check Tor against
+ public final static String URL_TOR_CHECK = "https://check.torproject.org";
+
+
+ public final static String NEWLINE = "\n";
+
+ // public final static String INTENT_TOR_SERVICE = "org.torproject.android.service.TOR_SERVICE";
+
+ public final static String HANDLER_TOR_MSG = "torServiceMsg";
+
+ 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_OR = "pref_or";
+ public final static String PREF_OR_PORT = "pref_or_port";
+ public final static String PREF_OR_NICKNAME = "pref_or_nickname";
+ public final static String PREF_REACHABLE_ADDRESSES = "pref_reachable_addresses";
+ public final static String PREF_REACHABLE_ADDRESSES_PORTS = "pref_reachable_addresses_ports";
+ public final static String PREF_TRANSPARENT = "pref_transparent";
+ public final static String PREF_TRANSPARENT_ALL = "pref_transparent_all";
+
+ public final static String PREF_HAS_ROOT = "has_root";
+ public final static int RESULT_CLOSE_ALL = 0;
+
+ public final static String PREF_USE_SYSTEM_IPTABLES = "pref_use_sys_iptables";
+
+ public final static String PREF_PERSIST_NOTIFICATIONS = "pref_persistent_notifications";
+
+ public final static String PREF_DEFAULT_LOCALE = "pref_default_locale";
+
+ public final static String PREF_DISABLE_NETWORK = "pref_disable_network";
+
+ public final static String PREF_TOR_SHARED_PREFS = "org.torproject.android_preferences";
+
+ public final static int MAX_LOG_LENGTH = 10000;
+
+ public final static String PREF_SOCKS = "pref_socks";
+
+}
diff --git a/src/org/torproject/android/OrbotMainActivity.java b/src/org/torproject/android/OrbotMainActivity.java
index 9f38be4..406f15d 100644
--- a/src/org/torproject/android/OrbotMainActivity.java
+++ b/src/org/torproject/android/OrbotMainActivity.java
@@ -13,10 +13,10 @@ import org.torproject.android.service.TorService;
import org.torproject.android.service.TorServiceConstants;
import org.torproject.android.service.TorServiceUtils;
import org.torproject.android.settings.SettingsPreferences;
-import org.torproject.android.ui.ChooseLocaleWizardActivity;
import org.torproject.android.ui.ImageProgressView;
import org.torproject.android.ui.Rotate3dAnimation;
-import org.torproject.android.ui.TipsAndTricks;
+import org.torproject.android.ui.wizard.ChooseLocaleWizardActivity;
+import org.torproject.android.ui.wizard.TipsAndTricks;
import android.annotation.TargetApi;
import android.app.Activity;
@@ -67,7 +67,7 @@ import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
-public class OrbotMainActivity extends Activity implements TorConstants, OnLongClickListener, OnTouchListener, OnSharedPreferenceChangeListener
+public class OrbotMainActivity extends Activity implements OrbotConstants, OnLongClickListener, OnTouchListener, OnSharedPreferenceChangeListener
{
/* Useful UI bits */
private TextView lblStatus = null; //the main text display widget
@@ -417,18 +417,21 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
else if (item.getItemId() == R.id.menu_share_bridge)
{
- String bridges = mPrefs.getString(TorConstants.PREF_BRIDGES_LIST, null);
+ String bridges = mPrefs.getString(OrbotConstants.PREF_BRIDGES_LIST, null);
- try {
- bridges = "bridge://" + URLEncoder.encode(bridges,"UTF-8");
-
- IntentIntegrator integrator = new IntentIntegrator(OrbotMainActivity.this);
- integrator.shareText(bridges);
-
- } catch (UnsupportedEncodingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ if (bridges != null && bridges.length() > 0)
+ {
+ try {
+ bridges = "bridge://" + URLEncoder.encode(bridges,"UTF-8");
+
+ IntentIntegrator integrator = new IntentIntegrator(OrbotMainActivity.this);
+ integrator.shareText(bridges);
+
+ } catch (UnsupportedEncodingException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
}
@@ -652,8 +655,8 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
Editor pEdit = mPrefs.edit();
- pEdit.putString(TorConstants.PREF_BRIDGES_LIST,newBridgeValue); //set the string to a preference
- pEdit.putBoolean(TorConstants.PREF_BRIDGES_ENABLED,true);
+ pEdit.putString(OrbotConstants.PREF_BRIDGES_LIST,newBridgeValue); //set the string to a preference
+ pEdit.putBoolean(OrbotConstants.PREF_BRIDGES_ENABLED,true);
pEdit.commit();
diff --git a/src/org/torproject/android/TorConstants.java b/src/org/torproject/android/TorConstants.java
deleted file mode 100644
index 9b0966e..0000000
--- a/src/org/torproject/android/TorConstants.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Copyright (c) 2009, Nathan Freitas, Orbot/The Guardian Project - http://openideals.com/guardian */
-/* See LICENSE for licensing information */
-
-package org.torproject.android;
-
-public interface TorConstants {
-
- public final static String TAG = "Orbot";
-
-
- public final static String PREFS_KEY = "OrbotPrefs";
- public final static String PREFS_KEY_TORIFIED = "PrefTord";
-
- public final static int FILE_WRITE_BUFFER_SIZE = 2048;
-
- //path to check Tor against
- public final static String URL_TOR_CHECK = "https://check.torproject.org";
-
-
- public final static String NEWLINE = "\n";
-
- // public final static String INTENT_TOR_SERVICE = "org.torproject.android.service.TOR_SERVICE";
-
- public final static String HANDLER_TOR_MSG = "torServiceMsg";
-
- 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_OR = "pref_or";
- public final static String PREF_OR_PORT = "pref_or_port";
- public final static String PREF_OR_NICKNAME = "pref_or_nickname";
- public final static String PREF_REACHABLE_ADDRESSES = "pref_reachable_addresses";
- public final static String PREF_REACHABLE_ADDRESSES_PORTS = "pref_reachable_addresses_ports";
- public final static String PREF_TRANSPARENT = "pref_transparent";
- public final static String PREF_TRANSPARENT_ALL = "pref_transparent_all";
-
- public final static String PREF_HAS_ROOT = "has_root";
- public final static int RESULT_CLOSE_ALL = 0;
-
- public final static String PREF_USE_SYSTEM_IPTABLES = "pref_use_sys_iptables";
-
- public final static String PREF_PERSIST_NOTIFICATIONS = "pref_persistent_notifications";
-
- public final static String PREF_DEFAULT_LOCALE = "pref_default_locale";
-
- public final static String PREF_DISABLE_NETWORK = "pref_disable_network";
-
- public final static String PREF_TOR_SHARED_PREFS = "org.torproject.android_preferences";
-
- public final static int MAX_LOG_LENGTH = 10000;
-
- public final static String PREF_SOCKS = "pref_socks";
-
-}
diff --git a/src/org/torproject/android/service/TorResourceInstaller.java b/src/org/torproject/android/service/TorResourceInstaller.java
index 6f81f97..a56c618 100644
--- a/src/org/torproject/android/service/TorResourceInstaller.java
+++ b/src/org/torproject/android/service/TorResourceInstaller.java
@@ -20,7 +20,7 @@ import java.util.zip.ZipInputStream;
import org.sufficientlysecure.rootcommands.Shell;
import org.sufficientlysecure.rootcommands.command.SimpleCommand;
import org.torproject.android.R;
-import org.torproject.android.TorConstants;
+import org.torproject.android.OrbotConstants;
import android.content.Context;
import android.util.Log;
@@ -265,7 +265,7 @@ public class TorResourceInstaller implements TorServiceConstants {
} catch (IOException ex) {
- Log.e(TorConstants.TAG, "error copying binary", ex);
+ Log.e(OrbotConstants.TAG, "error copying binary", ex);
}
}
diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java
index 5100368..9529d6d 100644
--- a/src/org/torproject/android/service/TorService.java
+++ b/src/org/torproject/android/service/TorService.java
@@ -51,7 +51,7 @@ import org.sufficientlysecure.rootcommands.Shell;
import org.sufficientlysecure.rootcommands.command.SimpleCommand;
import org.torproject.android.OrbotMainActivity;
import org.torproject.android.R;
-import org.torproject.android.TorConstants;
+import org.torproject.android.OrbotConstants;
import org.torproject.android.settings.AppManager;
import org.torproject.android.settings.TorifiedApp;
import org.torproject.android.vpn.OrbotVpnService;
@@ -79,7 +79,7 @@ import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.widget.RemoteViews;
-public class TorService extends Service implements TorServiceConstants, TorConstants, EventHandler
+public class TorService extends Service implements TorServiceConstants, OrbotConstants, EventHandler
{
public static boolean ENABLE_DEBUG_LOG = true;
@@ -783,7 +783,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
ENABLE_DEBUG_LOG = prefs.getBoolean("pref_enable_logging",false);
Log.i(TAG,"debug logging:" + ENABLE_DEBUG_LOG);
- prefPersistNotifications = prefs.getBoolean(TorConstants.PREF_PERSIST_NOTIFICATIONS, true);
+ prefPersistNotifications = prefs.getBoolean(OrbotConstants.PREF_PERSIST_NOTIFICATIONS, true);
mUseVPN = prefs.getBoolean("pref_vpn", false);
}
@@ -811,7 +811,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
ArrayList<String> customEnv = new ArrayList<String>();
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
- boolean useBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_ENABLED, false);
+ boolean useBridges = prefs.getBoolean(OrbotConstants.PREF_BRIDGES_ENABLED, false);
if (useBridges)
if (mUseVPN && !mIsLollipop)
@@ -1185,7 +1185,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
- String socksPortPref = prefs.getString(TorConstants.PREF_SOCKS, TorServiceConstants.PORT_SOCKS_DEFAULT);
+ String socksPortPref = prefs.getString(OrbotConstants.PREF_SOCKS, TorServiceConstants.PORT_SOCKS_DEFAULT);
if (socksPortPref.indexOf(':')!=-1)
socksPortPref = socksPortPref.split(":")[1];
@@ -2043,7 +2043,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
- boolean doNetworKSleep = prefs.getBoolean(TorConstants.PREF_DISABLE_NETWORK, true);
+ boolean doNetworKSleep = prefs.getBoolean(OrbotConstants.PREF_DISABLE_NETWORK, true);
final ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkInfo netInfo = cm.getActiveNetworkInfo();
@@ -2114,10 +2114,10 @@ public class TorService extends Service implements TorServiceConstants, TorConst
enableTransProxyAndDNSPorts(transPort, dnsPort);
*/
- boolean useBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_ENABLED, false);
+ boolean useBridges = prefs.getBoolean(OrbotConstants.PREF_BRIDGES_ENABLED, false);
- boolean becomeRelay = prefs.getBoolean(TorConstants.PREF_OR, false);
- boolean ReachableAddresses = prefs.getBoolean(TorConstants.PREF_REACHABLE_ADDRESSES,false);
+ boolean becomeRelay = prefs.getBoolean(OrbotConstants.PREF_OR, false);
+ boolean ReachableAddresses = prefs.getBoolean(OrbotConstants.PREF_REACHABLE_ADDRESSES,false);
boolean enableHiddenServices = prefs.getBoolean("pref_hs_enable", false);
boolean enableStrictNodes = prefs.getBoolean("pref_strict_nodes", false);
@@ -2182,7 +2182,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
updateConfiguration("UseBridges", "1", false);
- String bridgeList = prefs.getString(TorConstants.PREF_BRIDGES_LIST,null);
+ String bridgeList = prefs.getString(OrbotConstants.PREF_BRIDGES_LIST,null);
if (bridgeList != null && bridgeList.length() > 1) //longer then 1 = some real values here
{
@@ -2302,7 +2302,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
if (ReachableAddresses)
{
String ReachableAddressesPorts =
- prefs.getString(TorConstants.PREF_REACHABLE_ADDRESSES_PORTS, "*:80,*:443");
+ prefs.getString(OrbotConstants.PREF_REACHABLE_ADDRESSES_PORTS, "*:80,*:443");
updateConfiguration("ReachableAddresses", ReachableAddressesPorts, false);
@@ -2323,8 +2323,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
{
if (becomeRelay && (!useBridges) && (!ReachableAddresses))
{
- int ORPort = Integer.parseInt(prefs.getString(TorConstants.PREF_OR_PORT, "9001"));
- String nickname = prefs.getString(TorConstants.PREF_OR_NICKNAME, "Orbot");
+ int ORPort = Integer.parseInt(prefs.getString(OrbotConstants.PREF_OR_PORT, "9001"));
+ String nickname = prefs.getString(OrbotConstants.PREF_OR_NICKNAME, "Orbot");
String dnsFile = writeDNSFile ();
diff --git a/src/org/torproject/android/service/TorServiceUtils.java b/src/org/torproject/android/service/TorServiceUtils.java
index a22b328..609a8e2 100644
--- a/src/org/torproject/android/service/TorServiceUtils.java
+++ b/src/org/torproject/android/service/TorServiceUtils.java
@@ -9,7 +9,7 @@ import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
-import org.torproject.android.TorConstants;
+import org.torproject.android.OrbotConstants;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
@@ -117,9 +117,9 @@ public class TorServiceUtils implements TorServiceConstants {
public static SharedPreferences getSharedPrefs (Context context)
{
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB)
- return context.getSharedPreferences(TorConstants.PREF_TOR_SHARED_PREFS,0 | Context.MODE_MULTI_PROCESS);
+ return context.getSharedPreferences(OrbotConstants.PREF_TOR_SHARED_PREFS,0 | Context.MODE_MULTI_PROCESS);
else
- return context.getSharedPreferences(TorConstants.PREF_TOR_SHARED_PREFS,Context.MODE_PRIVATE);
+ return context.getSharedPreferences(OrbotConstants.PREF_TOR_SHARED_PREFS,Context.MODE_PRIVATE);
}
}
diff --git a/src/org/torproject/android/service/TorTransProxy.java b/src/org/torproject/android/service/TorTransProxy.java
index 78b6ebd..4c32bb5 100644
--- a/src/org/torproject/android/service/TorTransProxy.java
+++ b/src/org/torproject/android/service/TorTransProxy.java
@@ -7,7 +7,7 @@ import java.util.concurrent.TimeoutException;
import org.sufficientlysecure.rootcommands.Shell;
import org.sufficientlysecure.rootcommands.command.SimpleCommand;
-import org.torproject.android.TorConstants;
+import org.torproject.android.OrbotConstants;
import org.torproject.android.settings.TorifiedApp;
import android.content.Context;
@@ -49,7 +49,7 @@ public class TorTransProxy implements TorServiceConstants {
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context);
- useSystemIpTables = prefs.getBoolean(TorConstants.PREF_USE_SYSTEM_IPTABLES, false);
+ useSystemIpTables = prefs.getBoolean(OrbotConstants.PREF_USE_SYSTEM_IPTABLES, false);
if (useSystemIpTables)
{
@@ -72,7 +72,7 @@ public class TorTransProxy implements TorServiceConstants {
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context);
- useSystemIpTables = prefs.getBoolean(TorConstants.PREF_USE_SYSTEM_IPTABLES, false);
+ useSystemIpTables = prefs.getBoolean(OrbotConstants.PREF_USE_SYSTEM_IPTABLES, false);
if (useSystemIpTables)
{
diff --git a/src/org/torproject/android/settings/AppManager.java b/src/org/torproject/android/settings/AppManager.java
index 5818519..19dff0a 100644
--- a/src/org/torproject/android/settings/AppManager.java
+++ b/src/org/torproject/android/settings/AppManager.java
@@ -11,7 +11,7 @@ import java.util.List;
import java.util.StringTokenizer;
import org.torproject.android.R;
-import org.torproject.android.TorConstants;
+import org.torproject.android.OrbotConstants;
import org.torproject.android.service.TorServiceUtils;
import android.app.Activity;
@@ -38,7 +38,7 @@ import android.widget.ListView;
import android.widget.TextView;
//import android.R;
-public class AppManager extends Activity implements OnCheckedChangeListener, OnClickListener, TorConstants {
+public class AppManager extends Activity implements OnCheckedChangeListener, OnClickListener, OrbotConstants {
private ListView listApps;
private final static String TAG = "Orbot";
diff --git a/src/org/torproject/android/ui/ChooseLocaleWizardActivity.java b/src/org/torproject/android/ui/ChooseLocaleWizardActivity.java
deleted file mode 100644
index 95f8766..0000000
--- a/src/org/torproject/android/ui/ChooseLocaleWizardActivity.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package org.torproject.android.ui;
-
-import java.util.Locale;
-
-import org.torproject.android.R;
-import org.torproject.android.TorConstants;
-import org.torproject.android.service.TorServiceUtils;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.Editor;
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.view.KeyEvent;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.ListView;
-import android.widget.Toast;
-
-public class ChooseLocaleWizardActivity extends Activity implements TorConstants {
-
- private int flag = 0;
- private ListView listLocales;
-
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
-
- }
-
- @Override
- protected void onStart() {
-
- super.onStart();
- setContentView(R.layout.layout_wizard_locale);
-
-
- listLocales = (ListView)findViewById(R.id.wizard_locale_list);
- Button next = ((Button)findViewById(R.id.btnWizard2));
- // next.setEnabled(false);
-
- String[] strLangs = getResources().getStringArray(R.array.languages);
- strLangs[0] = Locale.getDefault().getDisplayName();
- ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, strLangs);
- listLocales.setAdapter(adapter);
-
- listLocales.setSelection(0);
-
-
- listLocales.setOnItemClickListener(new OnItemClickListener() {
-
-
- @Override
- public void onItemClick(AdapterView<?> arg0, View arg1,
- int arg2, long arg3) {
-
- setLocalePref(arg2);
- finish();
- startActivity(new Intent(ChooseLocaleWizardActivity.this, TipsAndTricks.class));
-
- }
- });
-
- next.setOnClickListener(new View.OnClickListener() {
-
- public void onClick(View v) {
- setLocalePref(0);
- finish();
- startActivity(new Intent(ChooseLocaleWizardActivity.this, TipsAndTricks.class));
-
- }
- });
-
-
-
- }
-
- private void setLocalePref(int selId)
- {
-
- SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
-
- Configuration config = getResources().getConfiguration();
-
- String[] localeVals = getResources().getStringArray(R.array.languages_values);
-
- String lang = localeVals[selId];
-
- Editor pEdit = prefs.edit();
- pEdit.putString(PREF_DEFAULT_LOCALE, lang);
- pEdit.commit();
- Locale locale = null;
-
- if (lang.equals("xx"))
- {
- locale = Locale.getDefault();
-
- }
- else
- locale = new Locale(lang);
-
- Locale.setDefault(locale);
- config.locale = locale;
- getResources().updateConfiguration(config, getResources().getDisplayMetrics());
-
-
-
-
- }
-
- @Override
- protected void onRestoreInstanceState(Bundle savedInstanceState) {
- super.onRestoreInstanceState(savedInstanceState);
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
-
- }
-
- //Code to override the back button!
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if(keyCode == KeyEvent.KEYCODE_BACK){
- Toast.makeText(getApplicationContext(), R.string.wizard_exit_at_first_screen_toast, Toast.LENGTH_SHORT).show();
- return true;
- }
- return false;
- }
-}
\ No newline at end of file
diff --git a/src/org/torproject/android/ui/OrbotLogActivity.java b/src/org/torproject/android/ui/OrbotLogActivity.java
index ae83b77..4a24d3f 100644
--- a/src/org/torproject/android/ui/OrbotLogActivity.java
+++ b/src/org/torproject/android/ui/OrbotLogActivity.java
@@ -3,7 +3,7 @@
package org.torproject.android.ui;
-import org.torproject.android.TorConstants;
+import org.torproject.android.OrbotConstants;
import android.app.Activity;
import android.content.BroadcastReceiver;
@@ -14,7 +14,7 @@ import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
-public class OrbotLogActivity extends Activity implements TorConstants
+public class OrbotLogActivity extends Activity implements OrbotConstants
{
/** Called when the activity is first created. */
diff --git a/src/org/torproject/android/ui/TipsAndTricks.java b/src/org/torproject/android/ui/TipsAndTricks.java
deleted file mode 100644
index d0e711b..0000000
--- a/src/org/torproject/android/ui/TipsAndTricks.java
+++ /dev/null
@@ -1,213 +0,0 @@
-package org.torproject.android.ui;
-
-import org.torproject.android.R;
-import org.torproject.android.TorConstants;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.Button;
-import android.widget.TextView;
-
-public class TipsAndTricks extends Activity implements TorConstants {
-
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
-
- }
-
- @Override
- protected void onStart() {
-
- super.onStart();
- setContentView(R.layout.layout_wizard_tips);
-
- stepFive();
-
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
-
- }
-
- void stepFive(){
-
-
- String title = getString(R.string.wizard_tips_title);
-
- setTitle(title);
-
- Button btnLink = (Button)findViewById(R.id.WizardRootButtonInstallGibberbot);
-
- btnLink.setOnClickListener(new OnClickListener() {
-
- public void onClick(View view) {
-
- String url = getString(R.string.gibberbot_apk_url);
- finish();
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
-
- }
- });
-
- btnLink = (Button)findViewById(R.id.WizardRootButtonInstallOrweb);
-
- btnLink.setOnClickListener(new OnClickListener() {
-
- public void onClick(View view) {
-
- String url = getString(R.string.orweb_apk_url);
- finish();
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
-
- }
- });
-
- btnLink = (Button)findViewById(R.id.WizardRootButtonInstallDuckgo);
-
- btnLink.setOnClickListener(new OnClickListener() {
-
- public void onClick(View view) {
-
- String url = getString(R.string.duckgo_apk_url);
- finish();
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
-
- }
- });
-
- btnLink = (Button)findViewById(R.id.WizardRootButtonInstallFirefox);
-
- btnLink.setOnClickListener(new OnClickListener() {
-
- public void onClick(View view) {
-
- String url = getString(R.string.proxymob_setup_url);
- finish();
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
-
- }
- });
-
- btnLink = (Button)findViewById(R.id.WizardRootButtonInstallTwitter);
-
- btnLink.setOnClickListener(new OnClickListener() {
-
- public void onClick(View view) {
-
- String url = getString(R.string.twitter_setup_url);
- finish();
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
-
- }
- });
-
- btnLink = (Button)findViewById(R.id.WizardRootButtonInstallStoryMaker);
-
- btnLink.setOnClickListener(new OnClickListener() {
-
- public void onClick(View view) {
-
- String url = getString(R.string.story_maker_url);
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
-
- }
- });
-
- btnLink = (Button)findViewById(R.id.WizardRootButtonInstallMartus);
-
- btnLink.setOnClickListener(new OnClickListener() {
-
- public void onClick(View view) {
-
- String url = getString(R.string.martus_url);
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
-
- }
- });
-
-
- btnLink = (Button)findViewById(R.id.WizardRootButtonGooglePlay);
-
- btnLink.setOnClickListener(new OnClickListener() {
-
- public void onClick(View view) {
-
- String url = getString(R.string.wizard_tips_play_url);
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
-
- }
- });
-
-
- Button back = ((Button)findViewById(R.id.btnWizard1));
- Button next = ((Button)findViewById(R.id.btnWizard2));
-
- back.setOnClickListener(new View.OnClickListener() {
-
- public void onClick(View v) {
- finish();
- startActivityForResult(new Intent(TipsAndTricks.this, ChooseLocaleWizardActivity.class), 1);
- }
- });
-
- next.setOnClickListener(new View.OnClickListener() {
-
- public void onClick(View v) {
- //showWizardFinal();
-
- finish();
- }
- });
-
- }
-
-
-
- //Code to override the back button!
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if(keyCode == KeyEvent.KEYCODE_BACK){
- finish();
- startActivity(new Intent(getBaseContext(), ChooseLocaleWizardActivity.class));
- return true;
- }
- return false;
- }
-
- /*
- private void showWizardFinal ()
- {
- String title = null;
- String msg = null;
-
-
- title = context.getString(R.string.wizard_final);
- msg = context.getString(R.string.wizard_final_msg);
-
- DialogInterface.OnClickListener ocListener = new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- context.startActivity(new Intent(context, Orbot.class));
-
- }
- };
-
-
- new AlertDialog.Builder(context)
- .setIcon(R.drawable.icon)
- .setTitle(title)
- .setPositiveButton(R.string.button_close, ocListener)
- .setMessage(msg)
- .show();
- }*/
-}
diff --git a/src/org/torproject/android/ui/wizard/ChooseLocaleWizardActivity.java b/src/org/torproject/android/ui/wizard/ChooseLocaleWizardActivity.java
new file mode 100644
index 0000000..3fdd746
--- /dev/null
+++ b/src/org/torproject/android/ui/wizard/ChooseLocaleWizardActivity.java
@@ -0,0 +1,135 @@
+package org.torproject.android.ui.wizard;
+
+import java.util.Locale;
+
+import org.torproject.android.R;
+import org.torproject.android.OrbotConstants;
+import org.torproject.android.service.TorServiceUtils;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.ListView;
+import android.widget.Toast;
+
+public class ChooseLocaleWizardActivity extends Activity implements OrbotConstants {
+
+ private int flag = 0;
+ private ListView listLocales;
+
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+
+ }
+
+ @Override
+ protected void onStart() {
+
+ super.onStart();
+ setContentView(R.layout.layout_wizard_locale);
+
+
+ listLocales = (ListView)findViewById(R.id.wizard_locale_list);
+ Button next = ((Button)findViewById(R.id.btnWizard2));
+ // next.setEnabled(false);
+
+ String[] strLangs = getResources().getStringArray(R.array.languages);
+ strLangs[0] = Locale.getDefault().getDisplayName();
+ ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, strLangs);
+ listLocales.setAdapter(adapter);
+
+ listLocales.setSelection(0);
+
+
+ listLocales.setOnItemClickListener(new OnItemClickListener() {
+
+
+ @Override
+ public void onItemClick(AdapterView<?> arg0, View arg1,
+ int arg2, long arg3) {
+
+ setLocalePref(arg2);
+ finish();
+ startActivity(new Intent(ChooseLocaleWizardActivity.this, TipsAndTricks.class));
+
+ }
+ });
+
+ next.setOnClickListener(new View.OnClickListener() {
+
+ public void onClick(View v) {
+ setLocalePref(0);
+ finish();
+ startActivity(new Intent(ChooseLocaleWizardActivity.this, TipsAndTricks.class));
+
+ }
+ });
+
+
+
+ }
+
+ private void setLocalePref(int selId)
+ {
+
+ SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
+
+ Configuration config = getResources().getConfiguration();
+
+ String[] localeVals = getResources().getStringArray(R.array.languages_values);
+
+ String lang = localeVals[selId];
+
+ Editor pEdit = prefs.edit();
+ pEdit.putString(PREF_DEFAULT_LOCALE, lang);
+ pEdit.commit();
+ Locale locale = null;
+
+ if (lang.equals("xx"))
+ {
+ locale = Locale.getDefault();
+
+ }
+ else
+ locale = new Locale(lang);
+
+ Locale.setDefault(locale);
+ config.locale = locale;
+ getResources().updateConfiguration(config, getResources().getDisplayMetrics());
+
+
+
+
+ }
+
+ @Override
+ protected void onRestoreInstanceState(Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+
+ }
+
+ //Code to override the back button!
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if(keyCode == KeyEvent.KEYCODE_BACK){
+ Toast.makeText(getApplicationContext(), R.string.wizard_exit_at_first_screen_toast, Toast.LENGTH_SHORT).show();
+ return true;
+ }
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/src/org/torproject/android/ui/wizard/TipsAndTricks.java b/src/org/torproject/android/ui/wizard/TipsAndTricks.java
new file mode 100644
index 0000000..d47a4fb
--- /dev/null
+++ b/src/org/torproject/android/ui/wizard/TipsAndTricks.java
@@ -0,0 +1,213 @@
+package org.torproject.android.ui.wizard;
+
+import org.torproject.android.R;
+import org.torproject.android.OrbotConstants;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.TextView;
+
+public class TipsAndTricks extends Activity implements OrbotConstants {
+
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+
+ }
+
+ @Override
+ protected void onStart() {
+
+ super.onStart();
+ setContentView(R.layout.layout_wizard_tips);
+
+ stepFive();
+
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+
+ }
+
+ void stepFive(){
+
+
+ String title = getString(R.string.wizard_tips_title);
+
+ setTitle(title);
+
+ Button btnLink = (Button)findViewById(R.id.WizardRootButtonInstallGibberbot);
+
+ btnLink.setOnClickListener(new OnClickListener() {
+
+ public void onClick(View view) {
+
+ String url = getString(R.string.gibberbot_apk_url);
+ finish();
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
+
+ }
+ });
+
+ btnLink = (Button)findViewById(R.id.WizardRootButtonInstallOrweb);
+
+ btnLink.setOnClickListener(new OnClickListener() {
+
+ public void onClick(View view) {
+
+ String url = getString(R.string.orweb_apk_url);
+ finish();
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
+
+ }
+ });
+
+ btnLink = (Button)findViewById(R.id.WizardRootButtonInstallDuckgo);
+
+ btnLink.setOnClickListener(new OnClickListener() {
+
+ public void onClick(View view) {
+
+ String url = getString(R.string.duckgo_apk_url);
+ finish();
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
+
+ }
+ });
+
+ btnLink = (Button)findViewById(R.id.WizardRootButtonInstallFirefox);
+
+ btnLink.setOnClickListener(new OnClickListener() {
+
+ public void onClick(View view) {
+
+ String url = getString(R.string.proxymob_setup_url);
+ finish();
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
+
+ }
+ });
+
+ btnLink = (Button)findViewById(R.id.WizardRootButtonInstallTwitter);
+
+ btnLink.setOnClickListener(new OnClickListener() {
+
+ public void onClick(View view) {
+
+ String url = getString(R.string.twitter_setup_url);
+ finish();
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
+
+ }
+ });
+
+ btnLink = (Button)findViewById(R.id.WizardRootButtonInstallStoryMaker);
+
+ btnLink.setOnClickListener(new OnClickListener() {
+
+ public void onClick(View view) {
+
+ String url = getString(R.string.story_maker_url);
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
+
+ }
+ });
+
+ btnLink = (Button)findViewById(R.id.WizardRootButtonInstallMartus);
+
+ btnLink.setOnClickListener(new OnClickListener() {
+
+ public void onClick(View view) {
+
+ String url = getString(R.string.martus_url);
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
+
+ }
+ });
+
+
+ btnLink = (Button)findViewById(R.id.WizardRootButtonGooglePlay);
+
+ btnLink.setOnClickListener(new OnClickListener() {
+
+ public void onClick(View view) {
+
+ String url = getString(R.string.wizard_tips_play_url);
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
+
+ }
+ });
+
+
+ Button back = ((Button)findViewById(R.id.btnWizard1));
+ Button next = ((Button)findViewById(R.id.btnWizard2));
+
+ back.setOnClickListener(new View.OnClickListener() {
+
+ public void onClick(View v) {
+ finish();
+ startActivityForResult(new Intent(TipsAndTricks.this, ChooseLocaleWizardActivity.class), 1);
+ }
+ });
+
+ next.setOnClickListener(new View.OnClickListener() {
+
+ public void onClick(View v) {
+ //showWizardFinal();
+
+ finish();
+ }
+ });
+
+ }
+
+
+
+ //Code to override the back button!
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if(keyCode == KeyEvent.KEYCODE_BACK){
+ finish();
+ startActivity(new Intent(getBaseContext(), ChooseLocaleWizardActivity.class));
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ private void showWizardFinal ()
+ {
+ String title = null;
+ String msg = null;
+
+
+ title = context.getString(R.string.wizard_final);
+ msg = context.getString(R.string.wizard_final_msg);
+
+ DialogInterface.OnClickListener ocListener = new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ context.startActivity(new Intent(context, Orbot.class));
+
+ }
+ };
+
+
+ new AlertDialog.Builder(context)
+ .setIcon(R.drawable.icon)
+ .setTitle(title)
+ .setPositiveButton(R.string.button_close, ocListener)
+ .setMessage(msg)
+ .show();
+ }*/
+}
1
0

03 Apr '15
commit 56df927fb59c90463b2eb6c26d7418dbb4355b38
Author: Nathan Freitas <nathan(a)freitas.net>
Date: Tue Mar 17 13:02:12 2015 -0400
remove liballium and obfsclient dependencies
We are switching to Go-based Meek and Obfs4 PT's
---
external/Makefile | 81 +++--------------------------------------------------
1 file changed, 4 insertions(+), 77 deletions(-)
diff --git a/external/Makefile b/external/Makefile
index 37563a7..9d5e114 100644
--- a/external/Makefile
+++ b/external/Makefile
@@ -70,8 +70,6 @@ endif
libevent libevent-clean \
iptables iptables-clean \
tor tor-clean \
- liballium liballium-clean \
- obfsclient obfsclient-clean \
polipo polipo-clean
all: assets
@@ -114,7 +112,7 @@ openssl-clean:
libevent/Makefile:
sed -i 's@\(SUBDIRS = . include\) sample test@\1@' libevent/Makefile.am
- sed -i 's@\(AC_OUTPUT(Makefile include/Makefile\) test/Makefile sample/Makefile)@\1)@' libevent/configure.in
+ ##sed -i 's@\(AC_OUTPUT(Makefile include/Makefile\) test/Makefile sample/Makefile)@\1)@' libevent/configure.in
cd libevent && ./autogen.sh
cp config.sub libevent
cp config.guess libevent
@@ -208,75 +206,6 @@ tor-clean:
-cd tor && \
git clean -fdx
-
-#------------------------------------------------------------------------------#
-# liballium
-
-liballium/Makefile:
- cd liballium && mkdir m4
- cd liballium && ./autogen.sh
- cp config.sub liballium
- cp config.guess liballium
- cd liballium && \
- CC="$(CC)" AR="$(AR)" RANLIB=$(RANLIB) CFLAGS="$(CFLAGS) -I$(EXTERNAL_ROOT)/include" LDFLAGS="$(LDFLAGS)" \
- ./configure \
- --host=$(HOST) \
- --disable-shared
-
-liballium-build-stamp: liballium/Makefile
- $(MAKE) -C liballium all-am
- touch liballium-build-stamp
-
-liballium: liballium-build-stamp
- test -d lib || mkdir lib
- test -d include || mkdir include
- test -d include/allium || mkdir include/allium
- cp liballium/.libs/liballium-1.0.a lib
- cp liballium/include/* include/allium/
-
-liballium-clean:
- -rm -f include/allium
- -rm -f lib/liballium-1.0.a
- -rm -f liballium-build-stamp
- -cd liballium && \
- git clean -fdx
-
-#------------------------------------------------------------------------------#
-# obfsclient
-
-
-obfsclient/Makefile:
- cd obfsclient && \
- ./autogen.sh
- cp config.sub obfsclient
- cp config.guess obfsclient
- cd obfsclient && \
- CC="$(CC)" CPP="$(CPP)" CXX="$(CXX)" AR="$(AR)" RANLIB=$(RANLIB) \
- CFLAGS="$(CFLAGS) -I$(EXTERNAL_ROOT)/include -I$(EXTERNAL_ROOT)/include/event2" \
- CPPFLAGS="$(CFLAGS) -D_FORTIFY_SOURCE=2 -fwrapv -fno-strict-aliasing -fno-strict-overflow" \
- CXXFLAGS="$(CFLAGS) -D_FORTIFY_SOURCE=2 -fwrapv -fno-strict-aliasing -fno-strict-overflow -I$(NDK_BASE)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/include -I$(NDK_BASE)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/libs/$(APP_ABI)/include" \
-LDFLAGS="$(LDFLAGS)" \
- libevent_CFLAGS="-I$(EXTERNAL_ROOT)/include" libevent_LIBS="-L$(EXTERNAL_ROOT)/lib" \
- liballium_CFLAGS="-I$(EXTERNAL_ROOT)/include" liballium_LIBS="-L$(EXTERNAL_ROOT)/lib" \
- LIBS="-L$(EXTERNAL_ROOT)/lib -levent -lallium-1.0 -L$(NDK_BASE)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/libs/$(APP_ABI)/ -lgnustl_static" \
- ./configure \
- --host=$(HOST) \
- --with-openssl=$(EXTERNAL_ROOT)
-
-obfsclient-build-stamp: obfsclient/Makefile
- $(MAKE) -C obfsclient
- touch obfsclient-build-stamp
-
-obfsclient: openssl libevent liballium obfsclient-build-stamp
- test -d bin || mkdir bin
- cp obfsclient/obfsclient bin
-
-obfsclient-clean:
- -rm -f bin/obfsclient
- -rm -f obfsclient-build-stamp
- -cd obfsclient && \
- git clean -fdx
-
#------------------------------------------------------------------------------#
# polipo
@@ -319,13 +248,11 @@ jtorctl-clean:
#in order to stop Android OS (older devices) from trying to compress/decompress it
#this is related to a bug in compression of assets and resources > 1MB
-assets: tor polipo jtorctl iptables obfsclient
+assets: tor polipo jtorctl iptables
install bin/jtorctl.jar ../libs
install -d ../res/raw
-$(NDK_TOOLCHAIN_BASE)/bin/$(HOST)-strip --strip-debug bin/polipo
-zip ../res/raw/polipo.mp3 bin/polipo
- -$(NDK_TOOLCHAIN_BASE)/bin/$(HOST)-strip --strip-debug bin/obfsclient
- -zip ../res/raw/obfsclient.mp3 bin/obfsclient
-$(NDK_TOOLCHAIN_BASE)/bin/$(HOST)-strip --strip-debug bin/tor
-zip ../res/raw/tor.mp3 bin/tor
-$(NDK_TOOLCHAIN_BASE)/bin/$(HOST)-strip --strip-debug bin/xtables
@@ -333,7 +260,6 @@ assets: tor polipo jtorctl iptables obfsclient
assets-clean:
-rm ../res/raw/polipo.mp3
- -rm ../res/raw/obfsclient.mp3
-rm ../res/raw/tor.mp3
-rm ../res/raw/xtables.mp3
-rm ../libs/jtorctl.jar
@@ -341,7 +267,8 @@ assets-clean:
#------------------------------------------------------------------------------#
# cleanup, cleanup, put the toys away
-clean: openssl-clean libevent-clean tor-clean polipo-clean jtorctl-clean liballium-clean obfsclient-clean assets-clean
+##clean: openssl-clean libevent-clean tor-clean polipo-clean jtorctl-clean assets-clean
+clean: openssl-clean libevent-clean tor-clean polipo-clean jtorctl-clean assets-clean
#------------------------------------------------------------------------------#
# debugging stuff
1
0

[orbot/master] remove proxy prefs, parse bridge URLs, and format strings!
by n8fr8@torproject.org 03 Apr '15
by n8fr8@torproject.org 03 Apr '15
03 Apr '15
commit 3e2b8cff1eee4ace656f170b765b178dbc628765
Author: Nathan Freitas <nathan(a)freitas.net>
Date: Tue Mar 17 13:03:16 2015 -0400
remove proxy prefs, parse bridge URLs, and format strings!
- shouldn't set proxy prefs for Orweb as it conflicts with Orbot's own pref keys
- improve parsing of incoming bridge URLs, as they may not have protocol component in URI
- format strings of up/down values better
---
src/org/torproject/android/OrbotMainActivity.java | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/org/torproject/android/OrbotMainActivity.java b/src/org/torproject/android/OrbotMainActivity.java
index 1a405d2..62cec03 100644
--- a/src/org/torproject/android/OrbotMainActivity.java
+++ b/src/org/torproject/android/OrbotMainActivity.java
@@ -705,11 +705,6 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
}
else
{
- Editor e = mPrefs.edit();
- e.putString("pref_proxy_host", "localhost");
- e.putInt("pref_proxy_port", 8118);
- e.putString("prof_proxy_type","HTTP");
- e.commit();
//use the built-in browser
Intent intentBrowser = new Intent(this, Browser.class);
@@ -717,7 +712,6 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
intentBrowser.setData(Uri.parse(browserLaunchUrl));
startActivity(intentBrowser);
}
-
}
@@ -814,6 +808,11 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
try {
results = URLDecoder.decode(results, "UTF-8");
+ int urlIdx = results.indexOf("://");
+
+ if (urlIdx!=-1)
+ results = results.substring(urlIdx+3);
+
setNewBridges(results);
@@ -1188,9 +1187,9 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
//Locale.getDefault();
if (count < 1e6)
- return mNumberFormat.format(((float)((int)(count*10/1024))/10)) + getString(R.string.kbps);
+ return mNumberFormat.format(Math.round(((float)((int)(count*10/1024))/10))) + getString(R.string.kbps);
- return mNumberFormat.format(((float)((int)(count*100/1024/1024))/100)) + getString(R.string.mbps);
+ return mNumberFormat.format(Math.round(((float)((int)(count*100/1024/1024))/100))) + getString(R.string.mbps);
//return count+" kB";
}
@@ -1200,9 +1199,9 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
// Under 2Mb, returns "xxx.xKb"
// Over 2Mb, returns "xxx.xxMb"
if (count < 1e6)
- return mNumberFormat.format(((float)((int)(count*10/1024))/10)) + getString(R.string.kb);
+ return mNumberFormat.format(Math.round(((float)((int)(count*10/1024))/10))) + getString(R.string.kb);
- return mNumberFormat.format(((float)((int)(count*100/1024/1024))/100)) + getString(R.string.mb);
+ return mNumberFormat.format(Math.round(((float)((int)(count*100/1024/1024))/100))) + getString(R.string.mb);
//return count+" kB";
}
1
0
commit a2662c325d90e3035d0df5a5edc6dba5e350c0c4
Author: Nathan Freitas <nathan(a)freitas.net>
Date: Sat Feb 14 00:43:36 2015 -0500
improve VPN activation
---
src/org/torproject/android/OrbotMainActivity.java | 26 ++++++++++++---------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/src/org/torproject/android/OrbotMainActivity.java b/src/org/torproject/android/OrbotMainActivity.java
index 8abc43e..f0ba484 100644
--- a/src/org/torproject/android/OrbotMainActivity.java
+++ b/src/org/torproject/android/OrbotMainActivity.java
@@ -79,8 +79,7 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
private DrawerLayout mDrawer;
private ActionBarDrawerToggle mDrawerToggle;
private Toolbar mToolbar;
-
-
+
/* Some tracking bits */
private int torStatus = TorServiceConstants.STATUS_OFF; //latest status reported from the tor service
@@ -89,7 +88,8 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
private boolean autoStartFromIntent = false;
private final static long INIT_DELAY = 100;
-
+ private final static int REQUEST_VPN = 8888;
+
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -101,9 +101,6 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
doLayout();
- // appConflictChecker ();
-
-
// Register to receive messages.
// We are registering an observer (mMessageReceiver) to receive Intents
// with actions named "custom-event-name".
@@ -221,8 +218,6 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
imgStatus.setOnLongClickListener(this);
imgStatus.setOnTouchListener(this);
- lblStatus.setText("Initializing the application...");
-
downloadText = (TextView)findViewById(R.id.trafficDown);
uploadText = (TextView)findViewById(R.id.trafficUp);
@@ -247,6 +242,15 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
});
mBtnVPN = (ToggleButton)findViewById(R.id.btnVPN);
+
+ boolean useVPN = mPrefs.getBoolean("pref_vpn", false);
+ mBtnVPN.setChecked(useVPN);
+
+ if (useVPN)
+ {
+ startVpnService ();
+ }
+
mBtnVPN.setOnClickListener(new View.OnClickListener ()
{
@@ -263,6 +267,7 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
});
+
}
@@ -760,8 +765,6 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
}
- private final static int REQUEST_VPN = 8888;
-
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void startVpnService ()
{
@@ -870,10 +873,11 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
if (torServiceMsg.indexOf('%')!=-1)
lblStatus.setText(torServiceMsg);
+ /**
if (torServiceMsg != null && torServiceMsg.length() > 0)
{
mTxtOrbotLog.append(torServiceMsg + '\n');
- }
+ }**/
boolean showFirstTime = mPrefs.getBoolean("connect_first_time",true);
1
0
commit b1294f6d60eacf19c291a372ceeb509701964bb6
Author: Nathan Freitas <nathan(a)freitas.net>
Date: Sat Feb 14 00:43:13 2015 -0500
improve start on boot
---
.../torproject/android/service/OnBootReceiver.java | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/org/torproject/android/service/OnBootReceiver.java b/src/org/torproject/android/service/OnBootReceiver.java
index ef40619..b04a6a1 100644
--- a/src/org/torproject/android/service/OnBootReceiver.java
+++ b/src/org/torproject/android/service/OnBootReceiver.java
@@ -1,10 +1,12 @@
package org.torproject.android.service;
+import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.net.VpnService;
public class OnBootReceiver extends BroadcastReceiver {
@@ -14,15 +16,29 @@ public class OnBootReceiver extends BroadcastReceiver {
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context.getApplicationContext());
boolean startOnBoot = prefs.getBoolean("pref_start_boot",true);
+ boolean useVPN = prefs.getBoolean("pref_vpn",true);
if (startOnBoot)
{
- startService("init",context);
- startService("start",context);
+ if (useVPN)
+ startVpnService(context);
+
+ startService(TorServiceConstants.CMD_INIT,context);
+ startService(TorServiceConstants.CMD_START,context);
+
}
}
+ @SuppressLint("NewApi")
+ public void startVpnService (Context context)
+ {
+ Intent intent = VpnService.prepare(context);
+ if (intent != null) {
+ context.startActivity(intent);
+ }
+
+ }
private void startService (String action, Context context)
{
1
0
commit 1e5651eec39463ef572ae4aa569ccf3b95a5cc91
Author: Nathan Freitas <nathan(a)freitas.net>
Date: Sat Feb 14 00:44:02 2015 -0500
improve VPN clean-up code
---
src/org/torproject/android/vpn/OrbotVpnService.java | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/org/torproject/android/vpn/OrbotVpnService.java b/src/org/torproject/android/vpn/OrbotVpnService.java
index 7919b07..44a2723 100644
--- a/src/org/torproject/android/vpn/OrbotVpnService.java
+++ b/src/org/torproject/android/vpn/OrbotVpnService.java
@@ -137,14 +137,8 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
mProxyServer = null;
}
if (mInterface != null){
- try {
- Log.d(TAG,"closing interface, destroying VPN interface");
- mInterface.close();
- mInterface = null;
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ onRevoke();
+
}
}
@@ -222,7 +216,14 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
{
try
{
- mInterface.close();
+ Log.d(TAG,"closing interface, destroying VPN interface");
+
+ if (mInterface != null)
+ {
+ mInterface.close();
+ mInterface = null;
+ }
+
Tun2Socks.Stop();
}
catch (Exception e)
1
0
commit bff6d0f567a72748035ad87299575731d579bf82
Author: Nathan Freitas <nathan(a)freitas.net>
Date: Sat Feb 14 00:44:09 2015 -0500
add support for meek PT
---
.../android/service/TorResourceInstaller.java | 6 +
src/org/torproject/android/service/TorService.java | 235 +++++++++++++-------
.../android/service/TorServiceConstants.java | 5 +
3 files changed, 165 insertions(+), 81 deletions(-)
diff --git a/src/org/torproject/android/service/TorResourceInstaller.java b/src/org/torproject/android/service/TorResourceInstaller.java
index 07cb4fd..c361e80 100644
--- a/src/org/torproject/android/service/TorResourceInstaller.java
+++ b/src/org/torproject/android/service/TorResourceInstaller.java
@@ -99,6 +99,12 @@ public class TorResourceInstaller implements TorServiceConstants {
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
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);
outFile = new File(installFolder, IPTABLES_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java
index 9bd64f1..81fdf90 100644
--- a/src/org/torproject/android/service/TorService.java
+++ b/src/org/torproject/android/service/TorService.java
@@ -115,6 +115,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
private File fileTor;
private File filePolipo;
private File fileObfsclient;
+ private File fileMeekclient;
private File fileXtables;
private File fileTorRc;
@@ -650,6 +651,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
fileObfsclient = new File(appBinHome, OBFSCLIENT_ASSET_KEY);
+ fileMeekclient = new File(appBinHome, MEEK_ASSET_KEY);
+
fileTorRc = new File(appBinHome, TORRC_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);
+ mUseVPN = prefs.getBoolean("pref_vpn", false);
}
private void startTor () throws Exception
@@ -784,6 +788,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
enableBinExec(fileTor);
enableBinExec(filePolipo);
enableBinExec(fileObfsclient);
+ enableBinExec(fileMeekclient);
enableBinExec(fileXtables);
updateSettings ();
@@ -791,7 +796,12 @@ public class TorService extends Service implements TorServiceConstants, TorConst
logNotice(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);
@@ -809,10 +819,12 @@ public class TorService extends Service implements TorServiceConstants, TorConst
shellRoot.close();
}
- else if (mUseVPN)
+
+ if (mUseVPN) //we need to turn on VPN here so the proxy is running
{
enableVpnProxy();
}
+
getHiddenServiceHostname ();
}
@@ -1430,16 +1442,22 @@ public class TorService extends Service implements TorServiceConstants, TorConst
debug ("enabling VPN Proxy");
mUseVPN = true;
-
+
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
Editor ePrefs = prefs.edit();
+
+ 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();
+
processSettings();
Intent intent = new Intent(TorService.this, OrbotVpnService.class);
@@ -1455,14 +1473,12 @@ public class TorService extends Service implements TorServiceConstants, TorConst
mUseVPN = false;
+
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
- Editor ePrefs = prefs.edit();
- ePrefs.remove("pref_proxy_type");
- ePrefs.remove("pref_proxy_host");
- ePrefs.remove("pref_proxy_port");
- ePrefs.remove("pref_proxy_username");
- ePrefs.remove("pref_proxy_password");
+ Editor ePrefs = prefs.edit();
+ ePrefs.putBoolean("pref_vpn", false);
ePrefs.commit();
+
processSettings();
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 autoUpdateBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_UPDATED, false);
boolean becomeRelay = prefs.getBoolean(TorConstants.PREF_OR, 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 excludeNodes = prefs.getString("pref_exclude_nodes", "");
- String proxyType = prefs.getString("pref_proxy_type", null);
- if (proxyType != null && proxyType.length() > 0)
+ if (!useBridges)
{
- String proxyHost = prefs.getString("pref_proxy_host", null);
- String proxyPort = prefs.getString("pref_proxy_port", null);
- String proxyUser = prefs.getString("pref_proxy_username", null);
- String proxyPass = prefs.getString("pref_proxy_password", null);
-
- if ((proxyHost != null && proxyHost.length()>0) && (proxyPort != null && proxyPort.length() > 0))
- {
- updateConfiguration(proxyType + "Proxy", proxyHost + ':' + 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 (mUseVPN) //set the proxy here if we aren't using a bridge
+ {
+ String proxyType = "socks5";
+ String proxyHost = "127.0.0.1";
+ int proxyPort = 9999;
+ updateConfiguration(proxyType + "Proxy", proxyHost + ':' + proxyPort, false);
+
+ }
+ else
+ {
+ String proxyType = prefs.getString("pref_proxy_type", null);
+ if (proxyType != null && proxyType.length() > 0)
+ {
+ String proxyHost = prefs.getString("pref_proxy_host", null);
+ String proxyPort = prefs.getString("pref_proxy_port", null);
+ String proxyUser = prefs.getString("pref_proxy_username", null);
+ String proxyPass = prefs.getString("pref_proxy_password", null);
+
+ if ((proxyHost != null && proxyHost.length()>0) && (proxyPort != null && proxyPort.length() > 0))
+ {
+ updateConfiguration(proxyType + "Proxy", proxyHost + ':' + 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)
@@ -2172,57 +2200,102 @@ public class TorService extends Service implements TorServiceConstants, TorConst
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);
- debug(msgBridge);
- return false;
- }
-
-
- String bridgeDelim = "\n";
-
- if (bridgeList.indexOf(",") != -1)
+ if (bridgeList != null && bridgeList.length() > 1) //longer then 1 = some real values here
{
- 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);
+
+ }
+
+ //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);
+ }
}
-
- 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())
+ else
{
- String bridgeConfigLine = st.nextToken().trim();
- debug("Adding bridge: " + bridgeConfigLine);
- updateConfiguration(bridgeCfgKey, bridgeConfigLine, false);
+ //time to do autobridges, aka meek
- }
-
- //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);
+ debug ("Using meek bridges");
- updateConfiguration("ClientTransportPlugin",bridgeConfig, false);
- }
- else
- {
- debug ("Using standard 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);
diff --git a/src/org/torproject/android/service/TorServiceConstants.java b/src/org/torproject/android/service/TorServiceConstants.java
index 4c3adc9..f065d58 100644
--- a/src/org/torproject/android/service/TorServiceConstants.java
+++ b/src/org/torproject/android/service/TorServiceConstants.java
@@ -92,6 +92,11 @@ public interface TorServiceConstants {
//obfsproxy
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;
1
0
commit ee82b5afb1d9bb66958eb4d20efe432be6f6eada
Author: Nathan Freitas <nathan(a)freitas.net>
Date: Sat Feb 14 01:55:11 2015 -0500
update version for alpha
---
AndroidManifest.xml | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 2123bc7..92e18b0 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,22 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.torproject.android"
- android:versionName="15.0.0-alpha-2"
- android:versionCode="15002"
+ android:versionName="15.0.0-alpha-3"
+ android:versionCode="15003"
android:installLocation="auto"
>
- <uses-sdk android:minSdkVersion="9" android:maxSdkVersion="22" android:targetSdkVersion="22"/>
+ <uses-sdk android:minSdkVersion="16" android:maxSdkVersion="22" android:targetSdkVersion="22"/>
<permission android:name="org.torproject.android.MANAGE_TOR"
android:label="@string/permission_manage_tor_label"
android:description="@string/permission_manage_tor_description"
android:protectionLevel="signature"/>
- <!-- <uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>-->
+
<uses-permission android:name="org.torproject.android.MANAGE_TOR"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
-
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application android:name="org.torproject.android.OrbotApp" android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
1
0

[orbot/master] implementing http server for meek-client VPN bypass
by n8fr8@torproject.org 03 Apr '15
by n8fr8@torproject.org 03 Apr '15
03 Apr '15
commit 096eae705baeaa05e703efbdfc0cd52b965699cb
Author: Nathan Freitas <nathan(a)freitas.net>
Date: Sat Feb 14 01:54:56 2015 -0500
implementing http server for meek-client VPN bypass
---
src/org/torproject/android/service/TorService.java | 16 +-
src/org/torproject/android/vpn/HttpProxy.java | 606 ++++++++++++++++++++
.../torproject/android/vpn/OrbotVpnService.java | 25 +-
3 files changed, 633 insertions(+), 14 deletions(-)
diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java
index 81fdf90..01fa339 100644
--- a/src/org/torproject/android/service/TorService.java
+++ b/src/org/torproject/android/service/TorService.java
@@ -2120,9 +2120,9 @@ public class TorService extends Service implements TorServiceConstants, TorConst
{
if (mUseVPN) //set the proxy here if we aren't using a bridge
{
- String proxyType = "socks5";
- String proxyHost = "127.0.0.1";
- int proxyPort = 9999;
+ String proxyType = "http";//"socks5";
+ String proxyHost = "10.0.0.1";
+ int proxyPort = 8888;//9999;
updateConfiguration(proxyType + "Proxy", proxyHost + ':' + proxyPort, false);
}
@@ -2244,11 +2244,11 @@ public class TorService extends Service implements TorServiceConstants, TorConst
if (mUseVPN)
{
- proxyType = "socks5";
- String proxyHost = "127.0.0.1";
- int proxyPort = 9999;
-
- proxyBridge = " proxyurl=" + proxyType + "://" + proxyHost + ':' + proxyPort;
+ proxyType = "http"; //"socks5";
+ String proxyHost = "10.0.0.1";
+ int proxyPort = 8888; //9999;
+
+ proxyBridge = " proxy=" + proxyType + "://" + proxyHost + ':' + proxyPort;
}
else if (proxyType != null && proxyType.length() > 0)
diff --git a/src/org/torproject/android/vpn/HttpProxy.java b/src/org/torproject/android/vpn/HttpProxy.java
new file mode 100644
index 0000000..617788b
--- /dev/null
+++ b/src/org/torproject/android/vpn/HttpProxy.java
@@ -0,0 +1,606 @@
+package org.torproject.android.vpn;
+/* <!-- in case someone opens this in a browser... --> <pre> */
+/*
+ * This is a simple multi-threaded Java proxy server
+ * for HTTP requests (HTTPS doesn't seem to work, because
+ * the CONNECT requests aren't always handled properly).
+ * I implemented the class as a thread so you can call it
+ * from other programs and kill it, if necessary (by using
+ * the closeSocket() method).
+ *
+ * We'll call this the 1.1 version of this class. All I
+ * changed was to separate the HTTP header elements with
+ * \r\n instead of just \n, to comply with the official
+ * HTTP specification.
+ *
+ * This can be used either as a direct proxy to other
+ * servers, or as a forwarding proxy to another proxy
+ * server. This makes it useful if you want to monitor
+ * traffic going to and from a proxy server (for example,
+ * you can run this on your local machine and set the
+ * fwdServer and fwdPort to a real proxy server, and then
+ * tell your browser to use "localhost" as the proxy, and
+ * you can watch the browser traffic going in and out).
+ *
+ * One limitation of this implementation is that it doesn't
+ * close the ProxyThread socket if the client disconnects
+ * or the server never responds, so you could end up with
+ * a bunch of loose threads running amuck and waiting for
+ * connections. As a band-aid, you can set the server socket
+ * to timeout after a certain amount of time (use the
+ * setTimeout() method in the ProxyThread class), although
+ * this can cause false timeouts if a remote server is simply
+ * slow to respond.
+ *
+ * Another thing is that it doesn't limit the number of
+ * socket threads it will create, so if you use this on a
+ * really busy machine that processed a bunch of requests,
+ * you may have problems. You should use thread pools if
+ * you're going to try something like this in a "real"
+ * application.
+ *
+ * Note that if you're using the "main" method to run this
+ * by itself and you don't need the debug output, it will
+ * run a bit faster if you pipe the std output to 'nul'.
+ *
+ * You may use this code as you wish, just don't pretend
+ * that you wrote it yourself, and don't hold me liable for
+ * anything that it does or doesn't do. If you're feeling
+ * especially honest, please include a link to nsftools.com
+ * along with the code. Thanks, and good luck.
+ *
+ * Julian Robichaux -- http://www.nsftools.com
+ */
+import java.io.*;
+import java.net.*;
+import java.nio.channels.SocketChannel;
+import java.lang.reflect.Array;
+
+import android.net.VpnService;
+
+public class HttpProxy extends Thread
+{
+ public static final int DEFAULT_PORT = 8080;
+
+ private ServerSocket server = null;
+ private int thisPort = DEFAULT_PORT;
+ private String fwdServer = "";
+ private int fwdPort = 0;
+ private int ptTimeout = ProxyThread.DEFAULT_TIMEOUT;
+ private int debugLevel = 0;
+ private PrintStream debugOut = System.out;
+
+ public static VpnService vpnService;
+
+ /* here's a main method, in case you want to run this by itself */
+ public static void main (String args[])
+ {
+ int port = 0;
+ String fwdProxyServer = "";
+ int fwdProxyPort = 0;
+
+ if (args.length == 0)
+ {
+ System.err.println("USAGE: java HttpProxy <port number> [<fwd proxy> <fwd port>]");
+ System.err.println(" <port number> the port this service listens on");
+ System.err.println(" <fwd proxy> optional proxy server to forward requests to");
+ System.err.println(" <fwd port> the port that the optional proxy server is on");
+ System.err.println("\nHINT: if you don't want to see all the debug information flying by,");
+ System.err.println("you can pipe the output to a file or to 'nul' using \">\". For example:");
+ System.err.println(" to send output to the file prox.txt: java HttpProxy 8080 > prox.txt");
+ System.err.println(" to make the output go away: java HttpProxy 8080 > nul");
+ return;
+ }
+
+ // get the command-line parameters
+ port = Integer.parseInt(args[0]);
+ if (args.length > 2)
+ {
+ fwdProxyServer = args[1];
+ fwdProxyPort = Integer.parseInt(args[2]);
+ }
+
+ // create and start the HttpProxy thread, using a 20 second timeout
+ // value to keep the threads from piling up too much
+ System.err.println(" ** Starting HttpProxy on port " + port + ". Press CTRL-C to end. **\n");
+ HttpProxy jp = new HttpProxy(port, fwdProxyServer, fwdProxyPort, 20);
+ jp.setDebug(1, System.out); // or set the debug level to 2 for tons of output
+ jp.start();
+
+ // run forever; if you were calling this class from another
+ // program and you wanted to stop the HttpProxy thread at some
+ // point, you could write a loop that waits for a certain
+ // condition and then calls HttpProxy.closeSocket() to kill
+ // the running HttpProxy thread
+ while (true)
+ {
+ try { Thread.sleep(3000); } catch (Exception e) {}
+ }
+
+ // if we ever had a condition that stopped the loop above,
+ // we'd want to do this to kill the running thread
+ //jp.closeSocket();
+ //return;
+ }
+
+
+ /* the proxy server just listens for connections and creates
+ * a new thread for each connection attempt (the ProxyThread
+ * class really does all the work)
+ */
+ public HttpProxy (int port)
+ {
+ thisPort = port;
+ }
+
+ public HttpProxy (int port, String proxyServer, int proxyPort)
+ {
+ thisPort = port;
+ fwdServer = proxyServer;
+ fwdPort = proxyPort;
+ }
+
+ public HttpProxy (int port, String proxyServer, int proxyPort, int timeout)
+ {
+ thisPort = port;
+ fwdServer = proxyServer;
+ fwdPort = proxyPort;
+ ptTimeout = timeout;
+ }
+
+ public static void setVpnService (final VpnService v)
+ {
+ vpnService = v;
+ }
+
+ /* allow the user to decide whether or not to send debug
+ * output to the console or some other PrintStream
+ */
+ public void setDebug (int level, PrintStream out)
+ {
+ debugLevel = level;
+ debugOut = out;
+ }
+
+
+ /* get the port that we're supposed to be listening on
+ */
+ public int getPort ()
+ {
+ return thisPort;
+ }
+
+
+ /* return whether or not the socket is currently open
+ */
+ public boolean isRunning ()
+ {
+ if (server == null)
+ return false;
+ else
+ return true;
+ }
+
+
+ /* closeSocket will close the open ServerSocket; use this
+ * to halt a running HttpProxy thread
+ */
+ public void closeSocket ()
+ {
+ try {
+ // close the open server socket
+ server.close();
+ // send it a message to make it stop waiting immediately
+ // (not really necessary)
+ /*Socket s = new Socket("localhost", thisPort);
+ OutputStream os = s.getOutputStream();
+ os.write((byte)0);
+ os.close();
+ s.close();*/
+ } catch(Exception e) {
+ if (debugLevel > 0)
+ debugOut.println(e);
+ }
+
+ server = null;
+ }
+
+
+ public void run()
+ {
+ try {
+ // create a server socket, and loop forever listening for
+ // client connections
+ server = new ServerSocket(thisPort);
+ if (debugLevel > 0)
+ debugOut.println("Started HttpProxy on port " + thisPort);
+
+ while (true)
+ {
+ Socket client = server.accept();
+ HttpProxy.vpnService.protect(client);
+ ProxyThread t = new ProxyThread(client, fwdServer, fwdPort);
+ t.setDebug(debugLevel, debugOut);
+ t.setTimeout(ptTimeout);
+ t.start();
+ }
+ } catch (Exception e) {
+ if (debugLevel > 0)
+ debugOut.println("HttpProxy Thread error: " + e);
+ }
+
+ closeSocket();
+ }
+
+}
+
+
+/*
+ * The ProxyThread will take an HTTP request from the client
+ * socket and send it to either the server that the client is
+ * trying to contact, or another proxy server
+ */
+class ProxyThread extends Thread
+{
+ private Socket pSocket;
+ private String fwdServer = "";
+ private int fwdPort = 0;
+ private int debugLevel = 0;
+ private PrintStream debugOut = System.out;
+
+ // the socketTimeout is used to time out the connection to
+ // the remote server after a certain period of inactivity;
+ // the value is in milliseconds -- use zero if you don't want
+ // a timeout
+ public static final int DEFAULT_TIMEOUT = 20 * 1000;
+ private int socketTimeout = DEFAULT_TIMEOUT;
+
+
+ public ProxyThread(Socket s)
+ {
+ pSocket = s;
+ }
+
+ public ProxyThread(Socket s, String proxy, int port)
+ {
+ pSocket = s;
+ fwdServer = proxy;
+ fwdPort = port;
+ }
+
+
+ public void setTimeout (int timeout)
+ {
+ // assume that the user will pass the timeout value
+ // in seconds (because that's just more intuitive)
+ socketTimeout = timeout * 1000;
+ }
+
+
+ public void setDebug (int level, PrintStream out)
+ {
+ debugLevel = level;
+ debugOut = out;
+ }
+
+
+ public void run()
+ {
+ try
+ {
+ long startTime = System.currentTimeMillis();
+
+ // client streams (make sure you're using streams that use
+ // byte arrays, so things like GIF and JPEG files and file
+ // downloads will transfer properly)
+ BufferedInputStream clientIn = new BufferedInputStream(pSocket.getInputStream());
+ BufferedOutputStream clientOut = new BufferedOutputStream(pSocket.getOutputStream());
+
+ // the socket to the remote server
+ Socket server = null;
+
+ // other variables
+ byte[] request = null;
+ byte[] response = null;
+ int requestLength = 0;
+ int responseLength = 0;
+ int pos = -1;
+ StringBuffer host = new StringBuffer("");
+ String hostName = "";
+ int hostPort = 80;
+
+ // get the header info (the web browser won't disconnect after
+ // it's sent a request, so make sure the waitForDisconnect
+ // parameter is false)
+ request = getHTTPData(clientIn, host, false);
+ requestLength = Array.getLength(request);
+
+ // separate the host name from the host port, if necessary
+ // (like if it's "servername:8000")
+ hostName = host.toString();
+ pos = hostName.indexOf(":");
+ if (pos > 0)
+ {
+ try { hostPort = Integer.parseInt(hostName.substring(pos + 1));
+ } catch (Exception e) { }
+ hostName = hostName.substring(0, pos);
+ }
+
+ // either forward this request to another proxy server or
+ // send it straight to the Host
+ try
+ {
+ server = SocketChannel.open().socket();
+
+ if ((null != server) && (null != HttpProxy.vpnService)) {
+ HttpProxy.vpnService.protect(server);
+ }
+
+ if ((fwdServer.length() > 0) && (fwdPort > 0))
+ {
+ //server = new Socket(fwdServer, fwdPort);
+ server.connect(new InetSocketAddress(fwdServer, fwdPort));
+
+ } else {
+ //server = new Socket(hostName, hostPort);
+ server.connect(new InetSocketAddress(hostName, hostPort));
+
+ }
+
+
+ HttpProxy.vpnService.protect(server);
+
+ } catch (Exception e) {
+ // tell the client there was an error
+ String errMsg = "HTTP/1.0 500\nContent Type: text/plain\n\n" +
+ "Error connecting to the server:\n" + e + "\n";
+ clientOut.write(errMsg.getBytes(), 0, errMsg.length());
+ }
+
+ if (server != null)
+ {
+ server.setSoTimeout(socketTimeout);
+ BufferedInputStream serverIn = new BufferedInputStream(server.getInputStream());
+ BufferedOutputStream serverOut = new BufferedOutputStream(server.getOutputStream());
+
+ // send the request out
+ serverOut.write(request, 0, requestLength);
+ serverOut.flush();
+
+ // and get the response; if we're not at a debug level that
+ // requires us to return the data in the response, just stream
+ // it back to the client to save ourselves from having to
+ // create and destroy an unnecessary byte array. Also, we
+ // should set the waitForDisconnect parameter to 'true',
+ // because some servers (like Google) don't always set the
+ // Content-Length header field, so we have to listen until
+ // they decide to disconnect (or the connection times out).
+ if (debugLevel > 1)
+ {
+ response = getHTTPData(serverIn, true);
+ responseLength = Array.getLength(response);
+ } else {
+ responseLength = streamHTTPData(serverIn, clientOut, true);
+ }
+
+ serverIn.close();
+ serverOut.close();
+ }
+
+ // send the response back to the client, if we haven't already
+ if (debugLevel > 1)
+ clientOut.write(response, 0, responseLength);
+
+ // if the user wants debug info, send them debug info; however,
+ // keep in mind that because we're using threads, the output won't
+ // necessarily be synchronous
+ if (debugLevel > 0)
+ {
+ long endTime = System.currentTimeMillis();
+ debugOut.println("Request from " + pSocket.getInetAddress().getHostAddress() +
+ " on Port " + pSocket.getLocalPort() +
+ " to host " + hostName + ":" + hostPort +
+ "\n (" + requestLength + " bytes sent, " +
+ responseLength + " bytes returned, " +
+ Long.toString(endTime - startTime) + " ms elapsed)");
+ debugOut.flush();
+ }
+ if (debugLevel > 1)
+ {
+ debugOut.println("REQUEST:\n" + (new String(request)));
+ debugOut.println("RESPONSE:\n" + (new String(response)));
+ debugOut.flush();
+ }
+
+ // close all the client streams so we can listen again
+ clientOut.close();
+ clientIn.close();
+ pSocket.close();
+ } catch (Exception e) {
+ if (debugLevel > 0)
+ debugOut.println("Error in ProxyThread: " + e);
+ //e.printStackTrace();
+ }
+
+ }
+
+
+ private byte[] getHTTPData (InputStream in, boolean waitForDisconnect)
+ {
+ // get the HTTP data from an InputStream, and return it as
+ // a byte array
+ // the waitForDisconnect parameter tells us what to do in case
+ // the HTTP header doesn't specify the Content-Length of the
+ // transmission
+ StringBuffer foo = new StringBuffer("");
+ return getHTTPData(in, foo, waitForDisconnect);
+ }
+
+
+ private byte[] getHTTPData (InputStream in, StringBuffer host, boolean waitForDisconnect)
+ {
+ // get the HTTP data from an InputStream, and return it as
+ // a byte array, and also return the Host entry in the header,
+ // if it's specified -- note that we have to use a StringBuffer
+ // for the 'host' variable, because a String won't return any
+ // information when it's used as a parameter like that
+ ByteArrayOutputStream bs = new ByteArrayOutputStream();
+ streamHTTPData(in, bs, host, waitForDisconnect);
+ return bs.toByteArray();
+ }
+
+
+ private int streamHTTPData (InputStream in, OutputStream out, boolean waitForDisconnect)
+ {
+ StringBuffer foo = new StringBuffer("");
+ return streamHTTPData(in, out, foo, waitForDisconnect);
+ }
+
+ private int streamHTTPData (InputStream in, OutputStream out,
+ StringBuffer host, boolean waitForDisconnect)
+ {
+ // get the HTTP data from an InputStream, and send it to
+ // the designated OutputStream
+ StringBuffer header = new StringBuffer("");
+ String data = "";
+ int responseCode = 200;
+ int contentLength = 0;
+ int pos = -1;
+ int byteCount = 0;
+
+ try
+ {
+ // get the first line of the header, so we know the response code
+ data = readLine(in);
+ if (data != null)
+ {
+ header.append(data + "\r\n");
+ pos = data.indexOf(" ");
+ if ((data.toLowerCase().startsWith("http")) &&
+ (pos >= 0) && (data.indexOf(" ", pos+1) >= 0))
+ {
+ String rcString = data.substring(pos+1, data.indexOf(" ", pos+1));
+ try
+ {
+ responseCode = Integer.parseInt(rcString);
+ } catch (Exception e) {
+ if (debugLevel > 0)
+ debugOut.println("Error parsing response code " + rcString);
+ }
+ }
+ }
+
+ // get the rest of the header info
+ while ((data = readLine(in)) != null)
+ {
+ // the header ends at the first blank line
+ if (data.length() == 0)
+ break;
+ header.append(data + "\r\n");
+
+ // check for the Host header
+ pos = data.toLowerCase().indexOf("host:");
+ if (pos >= 0)
+ {
+ host.setLength(0);
+ host.append(data.substring(pos + 5).trim());
+ }
+
+ // check for the Content-Length header
+ pos = data.toLowerCase().indexOf("content-length:");
+ if (pos >= 0)
+ contentLength = Integer.parseInt(data.substring(pos + 15).trim());
+ }
+
+ // add a blank line to terminate the header info
+ header.append("\r\n");
+
+ // convert the header to a byte array, and write it to our stream
+ out.write(header.toString().getBytes(), 0, header.length());
+
+ // if the header indicated that this was not a 200 response,
+ // just return what we've got if there is no Content-Length,
+ // because we may not be getting anything else
+ if ((responseCode != 200) && (contentLength == 0))
+ {
+ out.flush();
+ return header.length();
+ }
+
+ // get the body, if any; we try to use the Content-Length header to
+ // determine how much data we're supposed to be getting, because
+ // sometimes the client/server won't disconnect after sending us
+ // information...
+ if (contentLength > 0)
+ waitForDisconnect = false;
+
+ if ((contentLength > 0) || (waitForDisconnect))
+ {
+ try {
+ byte[] buf = new byte[4096];
+ int bytesIn = 0;
+ while ( ((byteCount < contentLength) || (waitForDisconnect))
+ && ((bytesIn = in.read(buf)) >= 0) )
+ {
+ out.write(buf, 0, bytesIn);
+ byteCount += bytesIn;
+ }
+ } catch (Exception e) {
+ String errMsg = "Error getting HTTP body: " + e;
+ if (debugLevel > 0)
+ debugOut.println(errMsg);
+ //bs.write(errMsg.getBytes(), 0, errMsg.length());
+ }
+ }
+ } catch (Exception e) {
+ if (debugLevel > 0)
+ debugOut.println("Error getting HTTP data: " + e);
+ }
+
+ //flush the OutputStream and return
+ try { out.flush(); } catch (Exception e) {}
+ return (header.length() + byteCount);
+ }
+
+
+ private String readLine (InputStream in)
+ {
+ // reads a line of text from an InputStream
+ StringBuffer data = new StringBuffer("");
+ int c;
+
+ try
+ {
+ // if we have nothing to read, just return null
+ in.mark(1);
+ if (in.read() == -1)
+ return null;
+ else
+ in.reset();
+
+ while ((c = in.read()) >= 0)
+ {
+ // check for an end-of-line character
+ if ((c == 0) || (c == 10) || (c == 13))
+ break;
+ else
+ data.append((char)c);
+ }
+
+ // deal with the case where the end-of-line terminator is \r\n
+ if (c == 13)
+ {
+ in.mark(1);
+ if (in.read() != 10)
+ in.reset();
+ }
+ } catch (Exception e) {
+ if (debugLevel > 0)
+ debugOut.println("Error getting header: " + e);
+ }
+
+ // and return what we have
+ return data.toString();
+ }
+
+}
diff --git a/src/org/torproject/android/vpn/OrbotVpnService.java b/src/org/torproject/android/vpn/OrbotVpnService.java
index 44a2723..42a8b2b 100644
--- a/src/org/torproject/android/vpn/OrbotVpnService.java
+++ b/src/org/torproject/android/vpn/OrbotVpnService.java
@@ -52,9 +52,11 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
private ParcelFileDescriptor mInterface;
private int mSocksProxyPort = 9999;
- private ProxyServer mProxyServer;
+ private ProxyServer mSocksProxyServer;
private Thread mThreadProxy;
+ private HttpProxy mHttpProxyServer;
+
private final static int VPN_MTU = 1500;
@Override
@@ -112,9 +114,9 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
{
try {
- mProxyServer = new ProxyServer(new ServerAuthenticatorNone(null, null));
+ mSocksProxyServer = new ProxyServer(new ServerAuthenticatorNone(null, null));
ProxyServer.setVpnService(OrbotVpnService.this);
- mProxyServer.start(mSocksProxyPort, 5, InetAddress.getLocalHost());
+ mSocksProxyServer.start(mSocksProxyPort, 5, InetAddress.getLocalHost());
} catch (Exception e) {
Log.d(TAG,"proxy server error: " + e.getLocalizedMessage(),e);
}
@@ -122,6 +124,11 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
};
mThreadProxy.start();
+
+ mHttpProxyServer = new HttpProxy(8888);
+ HttpProxy.setVpnService(OrbotVpnService.this);
+ mHttpProxyServer.setDebug(5, System.out);
+ mHttpProxyServer.start();
}
@Override
@@ -132,10 +139,16 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
private void stopVPN ()
{
- if (mProxyServer != null){
- mProxyServer.stop();
- mProxyServer = null;
+ if (mSocksProxyServer != null){
+ mSocksProxyServer.stop();
+ mSocksProxyServer = null;
+ }
+
+ if (mHttpProxyServer != null)
+ {
+ mHttpProxyServer.closeSocket();
}
+
if (mInterface != null){
onRevoke();
1
0
commit 9c77526f22f6a2bd1a27e0c480f91e28529d8390
Author: Nathan Freitas <nathan(a)freitas.net>
Date: Sat Feb 14 02:30:14 2015 -0500
move HTTP VPN bypass proxy to 9998
---
src/org/torproject/android/service/TorService.java | 10 +++++-----
src/org/torproject/android/vpn/HttpProxy.java | 2 +-
src/org/torproject/android/vpn/OrbotVpnService.java | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java
index 01fa339..c3a771b 100644
--- a/src/org/torproject/android/service/TorService.java
+++ b/src/org/torproject/android/service/TorService.java
@@ -2120,9 +2120,9 @@ public class TorService extends Service implements TorServiceConstants, TorConst
{
if (mUseVPN) //set the proxy here if we aren't using a bridge
{
- String proxyType = "http";//"socks5";
- String proxyHost = "10.0.0.1";
- int proxyPort = 8888;//9999;
+ String proxyType = "socks5";
+ String proxyHost = "127.0.0.1";
+ int proxyPort = 9999;
updateConfiguration(proxyType + "Proxy", proxyHost + ':' + proxyPort, false);
}
@@ -2245,8 +2245,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
if (mUseVPN)
{
proxyType = "http"; //"socks5";
- String proxyHost = "10.0.0.1";
- int proxyPort = 8888; //9999;
+ String proxyHost = "127.0.0.1";
+ int proxyPort = 9998; //9999;
proxyBridge = " proxy=" + proxyType + "://" + proxyHost + ':' + proxyPort;
diff --git a/src/org/torproject/android/vpn/HttpProxy.java b/src/org/torproject/android/vpn/HttpProxy.java
index 617788b..d211342 100644
--- a/src/org/torproject/android/vpn/HttpProxy.java
+++ b/src/org/torproject/android/vpn/HttpProxy.java
@@ -211,7 +211,7 @@ public class HttpProxy extends Thread
try {
// create a server socket, and loop forever listening for
// client connections
- server = new ServerSocket(thisPort);
+ server = new ServerSocket(thisPort,5,InetAddress.getLocalHost());
if (debugLevel > 0)
debugOut.println("Started HttpProxy on port " + thisPort);
diff --git a/src/org/torproject/android/vpn/OrbotVpnService.java b/src/org/torproject/android/vpn/OrbotVpnService.java
index 42a8b2b..dd5ffd9 100644
--- a/src/org/torproject/android/vpn/OrbotVpnService.java
+++ b/src/org/torproject/android/vpn/OrbotVpnService.java
@@ -125,7 +125,7 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
mThreadProxy.start();
- mHttpProxyServer = new HttpProxy(8888);
+ mHttpProxyServer = new HttpProxy(9998);
HttpProxy.setVpnService(OrbotVpnService.this);
mHttpProxyServer.setDebug(5, System.out);
mHttpProxyServer.start();
1
0