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 2011
- 18 participants
- 883 discussions

r24647: {} German translation of getinvolved/en/sidenav.wmi by Sacro (in website/trunk/getinvolved: . de)
by Runa Sandvik 17 Apr '11
by Runa Sandvik 17 Apr '11
17 Apr '11
Author: runa
Date: 2011-04-17 08:01:28 +0000 (Sun, 17 Apr 2011)
New Revision: 24647
Added:
website/trunk/getinvolved/de/
website/trunk/getinvolved/de/sidenav.wmi
Log:
German translation of getinvolved/en/sidenav.wmi by Sacro
Added: website/trunk/getinvolved/de/sidenav.wmi
===================================================================
--- website/trunk/getinvolved/de/sidenav.wmi (rev 0)
+++ website/trunk/getinvolved/de/sidenav.wmi 2011-04-17 08:01:28 UTC (rev 24647)
@@ -0,0 +1,33 @@
+#!/usr/bin/wml
+
+## translation metadata
+# Revision: $Revision$
+# Translation-Priority: 2-medium
+
+# this structure defines the side nav bar for the /getinvolved pages
+# and is the input for include/side.wmi
+
+# fields:
+#
+# url - the path to the wml page, as used the the <page> tag. This tag ensures
+# that links will point to the current language if supported, and alternately
+# the english version
+#
+# txt - the link text to be displayed. Different translations will
+# need to supply alternate txt
+
+<:
+ my $sidenav;
+ $sidenav = [
+ {'url' => 'getinvolved/volunteer',
+ 'txt' => 'Engagiere dich',
+ },
+ {'url' => 'getinvolved/research',
+ 'txt' => 'Forschung',
+ },
+ {'url' => 'donate/donate',
+ 'txt' => 'Spenden',
+ },
+ ];
+:>
+
1
0

r24646: {projects} Updated UI for start/stop notifications and systems preferen (projects/android/trunk/Orbot/src/org/torproject/android)
by Nathan Freitas 17 Apr '11
by Nathan Freitas 17 Apr '11
17 Apr '11
Author: n8fr8
Date: 2011-04-17 06:05:02 +0000 (Sun, 17 Apr 2011)
New Revision: 24646
Modified:
projects/android/trunk/Orbot/src/org/torproject/android/AppManager.java
projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java
projects/android/trunk/Orbot/src/org/torproject/android/SettingsPreferences.java
projects/android/trunk/Orbot/src/org/torproject/android/TorConstants.java
projects/android/trunk/Orbot/src/org/torproject/android/WizardActivity.java
projects/android/trunk/Orbot/src/org/torproject/android/WizardHelper.java
Log:
Updated UI for start/stop notifications and systems preferences
Modified: projects/android/trunk/Orbot/src/org/torproject/android/AppManager.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/AppManager.java 2011-04-17 06:04:27 UTC (rev 24645)
+++ projects/android/trunk/Orbot/src/org/torproject/android/AppManager.java 2011-04-17 06:05:02 UTC (rev 24646)
@@ -69,6 +69,7 @@
private void loadApps ()
{
+ resetApps(this);
final TorifiedApp[] apps = getApps(this);
Arrays.sort(apps, new Comparator<TorifiedApp>() {
@@ -140,12 +141,18 @@
protected void onStop() {
super.onStop();
- //Log.d(getClass().getName(),"Exiting Preferences");
}
-
public static TorifiedApp[] getApps (Context context)
{
+ if (apps == null)
+ resetApps(context);
+
+ return apps;
+ }
+
+ public static TorifiedApp[] resetApps (Context context)
+ {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
@@ -161,7 +168,7 @@
}
Arrays.sort(tordApps);
-
+
//else load the apps up
PackageManager pMgr = context.getPackageManager();
@@ -199,6 +206,7 @@
appIdx++;
}
+
return apps;
}
Modified: projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java 2011-04-17 06:04:27 UTC (rev 24645)
+++ projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java 2011-04-17 06:05:02 UTC (rev 24646)
@@ -33,19 +33,20 @@
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.KeyEvent;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
+import android.view.View.OnLongClickListener;
import android.widget.ImageView;
import android.widget.TextView;
-public class Orbot extends Activity implements OnClickListener, TorConstants
+public class Orbot extends Activity implements OnLongClickListener, TorConstants
{
/* Useful UI bits */
- //private TextView txtMessageLog = null; //the full screen log view of Tor control messages
private TextView lblStatus = null; //the main text display widget
private ImageView imgStatus = null; //the main touchable image for activating Orbot
private ProgressDialog progressDialog;
@@ -53,8 +54,6 @@
/* Some tracking bits */
private int torStatus = STATUS_READY; //latest status reported from the tor service
- private int currentView = 0; //the currently displayed UI view
- private StringBuffer logBuffer = new StringBuffer(); //the output of the service log messages
/* Tor Service interaction */
/* The primary interface we will be calling on the service. */
@@ -63,14 +62,15 @@
SharedPreferences prefs;
- Orbot mOrbot = null;
-
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
- mOrbot = this;
+ //if Tor binary is not running, then start the service up
+ startService(new Intent(INTENT_TOR_SERVICE));
+ bindService ();
+
+
setTheme(android.R.style.Theme_Black_NoTitleBar);
prefs = PreferenceManager.getDefaultSharedPreferences(this);
@@ -96,18 +96,35 @@
mItem = menu.add(0, 7, Menu.NONE, getString(R.string.menu_verify));
mItem.setIcon(R.drawable.ic_menu_check);
- // mItem = menu.add(0,6, Menu.NONE, getString(R.string.menu_log));
- // mItem.setIcon(R.drawable.ic_menu_reports);
-
- mItem = menu.add(0, 3, Menu.NONE, getString(R.string.menu_info));
+ mItem = menu.add(0,6, Menu.NONE, getString(R.string.menu_about));
mItem.setIcon(R.drawable.ic_menu_about);
+
+ mItem = menu.add(0, 3, Menu.NONE, getString(R.string.menu_wizard));
+ mItem.setIcon(R.drawable.ic_menu_goto);
mItem = menu.add(0, 8, Menu.NONE, getString(R.string.menu_exit));
mItem.setIcon(R.drawable.ic_menu_exit);
+
return true;
}
+
+ private void showAbout ()
+ {
+
+ LayoutInflater li = LayoutInflater.from(this);
+ View view = li.inflate(R.layout.layout_about, null);
+
+ TextView versionName = (TextView)view.findViewById(R.id.versionName);
+ versionName.setText(R.string.app_version);
+
+ new AlertDialog.Builder(this)
+ .setTitle(getString(R.string.button_about))
+ .setView(view)
+ .show();
+ }
+
/* When a menu item is selected launch the appropriate view or activity
* (non-Javadoc)
* @see android.app.Activity#onMenuItemSelected(int, android.view.MenuItem)
@@ -128,13 +145,15 @@
}
else if (mService.getStatus() == STATUS_READY)
{
- mItemOnOff.setTitle(R.string.menu_stop);
+ if (mItemOnOff != null)
+ mItemOnOff.setTitle(R.string.menu_stop);
startTor();
}
else
{
- mItemOnOff.setTitle(R.string.menu_start);
+ if (mItemOnOff != null)
+ mItemOnOff.setTitle(R.string.menu_start);
stopTor();
}
@@ -164,6 +183,12 @@
}
+ else if (item.getItemId() == 6)
+ {
+ showAbout();
+
+
+ }
return true;
}
@@ -224,7 +249,6 @@
// Save UI state changes to the savedInstanceState.
// This bundle will be passed to onCreate if the process is
// killed and restarted.
- savedInstanceState.putString("log", logBuffer.toString());
// etc.
super.onSaveInstanceState(savedInstanceState);
}
@@ -234,14 +258,13 @@
// Restore UI state from the savedInstanceState.
// This bundle has also been passed to onCreate.
- String logText = savedInstanceState.getString("log");
- logBuffer.append(logText);
}
private void doTorCheck ()
{
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
+
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which){
@@ -269,7 +292,7 @@
private void enableHiddenServicePort (int hsPort)
{
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mOrbot);
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
Editor pEdit = prefs.edit();
String hsPortString = prefs.getString("pref_hs_ports", "");
@@ -284,20 +307,12 @@
pEdit.commit();
- try {
- processSettings();
-
- String onionHostname = getHiddenServiceHostname();
+ String onionHostname = prefs.getString("pref_hs_hostname","");
+
+ Intent nResult = new Intent();
+ nResult.putExtra("hs_host", onionHostname);
+ setResult(RESULT_OK, nResult);
- Intent nResult = new Intent();
- nResult.putExtra("hs_host", onionHostname);
- setResult(RESULT_OK, nResult);
-
- } catch (RemoteException e) {
- Log.e(TAG, "error accessing hidden service", e);
- }
-
-
}
/* (non-Javadoc)
@@ -307,6 +322,7 @@
super.onResume();
showMain();
+ updateStatus("");
if (getIntent() == null)
return;
@@ -367,8 +383,7 @@
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.cancelAll();
-
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mOrbot);
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean showWizard = prefs.getBoolean("show_wizard",true);
@@ -394,9 +409,6 @@
protected void onStart() {
super.onStart();
- //if Tor binary is not running, then start the service up
- startService(new Intent(INTENT_TOR_SERVICE));
- bindService ();
updateStatus ("");
@@ -419,19 +431,14 @@
*/
private void showMain ()
{
- // bindService(); //connect the UI activity to the remote service
- currentView = R.layout.layout_main;
- setContentView(currentView);
+ setContentView(R.layout.layout_main);
- //add touch listeners for the image and the text label
- findViewById(R.id.imgStatus).setOnClickListener(this);
- findViewById(R.id.lblStatus).setOnClickListener(this);
-
lblStatus = (TextView)findViewById(R.id.lblStatus);
+ lblStatus.setOnLongClickListener(this);
imgStatus = (ImageView)findViewById(R.id.imgStatus);
+ imgStatus.setOnLongClickListener(this);
- updateStatus("");
}
/*
@@ -455,238 +462,45 @@
}
- /*
- * Show the message log UI
- */
- /*
- private void showMessageLog ()
- {
- currentView = R.layout.layout_log;
- setContentView(currentView);
-
- txtMessageLog = (TextView)findViewById(R.id.messageLog);
-
- txtMessageLog.setClickable(true);
- txtMessageLog.setText(logBuffer.toString());
-
-
- }*/
-
-
/*
* Load the basic settings application to display torrc
*/
private void showSettings ()
{
-
startActivityForResult(new Intent(this, SettingsPreferences.class), 1);
}
-
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
- if (requestCode == 1)
+ if (requestCode == 1 && resultCode == 1010 && mService != null)
{
- try {
- processSettings();
- } catch (RemoteException e) {
- e.printStackTrace();
- }
-
+ new ProcessSettingsAsyncTask().execute(mService);
}
}
-
- private void processSettings () throws RemoteException
- {
- try
- {
- if (mService == null)
- return; //nothing to do if the service isn't connected yet
-
- boolean useBridges = prefs.getBoolean(PREF_BRIDGES_ENABLED, false);
-
- //boolean autoUpdateBridges = prefs.getBoolean(PREF_BRIDGES_UPDATED, false);
- boolean becomeRelay = prefs.getBoolean(PREF_OR, false);
-
- boolean ReachableAddresses = prefs.getBoolean(PREF_REACHABLE_ADDRESSES,false);
-
- boolean enableHiddenServices = prefs.getBoolean("pref_hs_enable", false);
-
- boolean enableTransparentProxy = prefs.getBoolean(PREF_TRANSPARENT, false);
- mService.updateTransProxy();
-
-
- String bridgeList = prefs.getString(PREF_BRIDGES_LIST,"");
-
- if (useBridges)
- {
- if (bridgeList == null || bridgeList.length() == 0)
- {
-
- showAlert("Bridge Error","In order to use the bridge feature, you must enter at least one bridge IP address." +
- "Send an email to bridges(a)torproject.org with the line \"get bridges\" by itself in the body of the mail from a gmail account.");
-
-
- return;
- }
-
-
- mService.updateConfiguration("UseBridges", "1", false);
-
- String bridgeDelim = "\n";
-
- if (bridgeList.indexOf(",") != -1)
- {
- bridgeDelim = ",";
- }
-
- StringTokenizer st = new StringTokenizer(bridgeList,bridgeDelim);
- while (st.hasMoreTokens())
- {
-
- mService.updateConfiguration("bridge", st.nextToken(), false);
-
- }
-
- mService.updateConfiguration("UpdateBridgesFromAuthority", "0", false);
-
- }
- else
- {
- mService.updateConfiguration("UseBridges", "0", false);
-
- }
-
- try
- {
- if (ReachableAddresses)
- {
- String ReachableAddressesPorts =
- prefs.getString(PREF_REACHABLE_ADDRESSES_PORTS, "*:80,*:443");
-
- mService.updateConfiguration("ReachableAddresses", ReachableAddressesPorts, false);
-
- }
- else
- {
- mService.updateConfiguration("ReachableAddresses", "", false);
- }
- }
- catch (Exception e)
- {
- showAlert("Config Error","Your ReachableAddresses settings caused an exception!");
- }
-
- try
- {
- if (becomeRelay && (!useBridges) && (!ReachableAddresses))
- {
- int ORPort = Integer.parseInt(prefs.getString(PREF_OR_PORT, "9001"));
- String nickname = prefs.getString(PREF_OR_NICKNAME, "Orbot");
-
- mService.updateConfiguration("ORPort", ORPort + "", false);
- mService.updateConfiguration("Nickname", nickname, false);
- mService.updateConfiguration("ExitPolicy", "reject *:*", false);
-
- }
- else
- {
- mService.updateConfiguration("ORPort", "", false);
- mService.updateConfiguration("Nickname", "", false);
- mService.updateConfiguration("ExitPolicy", "", false);
- }
- }
- catch (Exception e)
- {
- showAlert("Uh-oh!","Your relay settings caused an exception!");
-
- return;
- }
-
- if (enableHiddenServices)
- {
- mService.updateConfiguration("HiddenServiceDir","/data/data/org.torproject.android/", false);
-
- String hsPorts = prefs.getString("pref_hs_ports","");
-
- StringTokenizer st = new StringTokenizer (hsPorts,",");
- String hsPortConfig = null;
-
- while (st.hasMoreTokens())
- {
- hsPortConfig = st.nextToken();
-
- if (hsPortConfig.indexOf(":")==-1) //setup the port to localhost if not specifed
- {
- hsPortConfig = hsPortConfig + " 127.0.0.1:" + hsPortConfig;
- }
-
- mService.updateConfiguration("HiddenServicePort",hsPortConfig, false);
- }
-
- //force save now so the hostname file gets generated
- mService.saveConfiguration();
-
- String onionHostname = getHiddenServiceHostname();
-
- if (onionHostname != null)
- {
-
- Editor pEdit = prefs.edit();
- pEdit.putString("pref_hs_hostname",onionHostname);
- pEdit.commit();
-
- }
- }
- else
- {
- mService.updateConfiguration("HiddenServiceDir","", false);
- }
-
- mService.saveConfiguration();
-
- }
- catch (Exception e)
- {
- showAlert("Uh-oh!","There was an error updating your settings");
-
- Log.w(TAG, "processSettings()", e);
-
- return;
- }
-
- }
-
-
- private String getHiddenServiceHostname ()
+ private void showAlert(String title, String msg, boolean button)
{
- String appHome = "/data/data/" + TorServiceConstants.TOR_APP_USERNAME + "/";
-
- File file = new File(appHome, "hostname");
- try {
- String onionHostname = Utils.readString(new FileInputStream(file));
- return onionHostname.trim();
- } catch (FileNotFoundException e) {
- Log.d(TAG, "unable to read onion hostname file",e);
- return null;
- }
- }
-
-
- private void showAlert(String title, String msg)
- {
-
+ if (button)
+ {
new AlertDialog.Builder(this)
.setIcon(R.drawable.icon)
.setTitle(title)
.setMessage(msg)
.setPositiveButton(android.R.string.ok, null)
.show();
+ }
+ else
+ {
+ new AlertDialog.Builder(this)
+ .setIcon(R.drawable.icon)
+ .setTitle(title)
+ .setMessage(msg)
+ .show();
+ }
}
/*
* Set the state of the running/not running graphic and label
@@ -699,7 +513,6 @@
if (mService != null)
torStatus = mService.getStatus();
-
if (imgStatus != null)
{
@@ -714,11 +527,15 @@
}
- String lblMsg = getString(R.string.status_activated) + "\n" + torServiceMsg;
+ String lblMsg = getString(R.string.status_activated);
+ //+ "\n" + torServiceMsg;
lblStatus.setText(lblMsg);
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mOrbot);
+ if (torServiceMsg.length() > 0)
+ showAlert("Update", torServiceMsg, false);
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean showFirstTime = prefs.getBoolean("connect_first_time",true);
@@ -731,27 +548,12 @@
pEdit.commit();
- showAlert(getString(R.string.status_activated),getString(R.string.connect_first_time));
+ showAlert(getString(R.string.status_activated),getString(R.string.connect_first_time),true);
}
-
- boolean enableHiddenServices = prefs.getBoolean("pref_hs_enable", false);
+ if (mItemOnOff != null)
+ mItemOnOff.setTitle(R.string.menu_stop);
- if (enableHiddenServices)
- {
- String onionHostname = getHiddenServiceHostname();
-
- if (onionHostname != null)
- {
- Editor pEdit = prefs.edit();
- pEdit.putString("pref_hs_hostname",onionHostname);
- pEdit.commit();
-
- }
-
- }
-
-
}
else if (torStatus == STATUS_CONNECTING)
{
@@ -763,25 +565,14 @@
}
else
progressDialog.setMessage(torServiceMsg);
- //lblStatus.setText(torServiceMsg);
-
- /*
- int idx = torServiceMsg.indexOf("%");
-
- if (idx != -1)
- {
- String pComp = torServiceMsg.substring(idx-2,idx).trim();
- int ipComp = Integer.parseInt(pComp);
- // progressDialog.setProgress(ipComp);
-
- }*/
+ if (mItemOnOff != null)
+ mItemOnOff.setTitle(R.string.menu_stop);
}
else if (torStatus == STATUS_OFF)
{
imgStatus.setImageResource(R.drawable.torstopping);
- // imgStatus.clearAnimation();
if (progressDialog != null)
{
@@ -791,6 +582,8 @@
lblStatus.setText(getString(R.string.status_shutting_down));
+ if (mItemOnOff != null)
+ mItemOnOff.setTitle(R.string.menu_start);
}
else
{
@@ -801,20 +594,20 @@
progressDialog = null;
}
- // imgStatus.clearAnimation();
imgStatus.setImageResource(R.drawable.toroff);
lblStatus.setText(getString(R.string.status_disabled) + "\n" + getString(R.string.press_to_start));
+ if (mItemOnOff != null)
+ mItemOnOff.setTitle(R.string.menu_start);
-
}
}
}
catch (RemoteException e)
{
- e.printStackTrace();
+ Log.e(TAG,"remote exception updating status",e);
}
@@ -822,104 +615,71 @@
private void startTor () throws RemoteException
{
- mService.setProfile(PROFILE_ON); //this means turn on
+ if (progressDialog == null)
+ {
+ progressDialog =ProgressDialog.show(this, "", getString(R.string.status_starting_up));
+ }
+
+ mService.setProfile(TorServiceConstants.PROFILE_ON); //this means turn on
imgStatus.setImageResource(R.drawable.torstarting);
lblStatus.setText(getString(R.string.status_starting_up));
- Message msg = mHandler.obtainMessage(ENABLE_TOR_MSG);
+ Message msg = mHandler.obtainMessage(TorServiceConstants.ENABLE_TOR_MSG);
mHandler.sendMessage(msg);
- logBuffer = new StringBuffer();
+
+
}
private void stopTor () throws RemoteException
{
if (mService != null)
{
- mService.setProfile(PROFILE_ONDEMAND); //these means turn off
-
- Message msg = mHandler.obtainMessage(DISABLE_TOR_MSG);
+ mService.setProfile(TorServiceConstants.PROFILE_OFF);
+ Message msg = mHandler.obtainMessage(TorServiceConstants.DISABLE_TOR_MSG);
mHandler.sendMessage(msg);
}
- //unbindService();
-
stopService(new Intent(ITorService.class.getName()));
}
- /*
- @Override
- public boolean onTouchEvent(MotionEvent event) {
-
- if (currentView == R.layout.layout_main)
- {
- try
- {
- if (mService == null)
- {
-
- }
- else if (mService.getStatus() == STATUS_READY)
- {
- startTor();
-
- }
- else
- {
- stopTor();
-
- }
-
- }
- catch (Exception e)
- {
- Log.d(TAG,"error onclick",e);
- }
- }
-
- return super.onTouchEvent(event);
- }*/
-
/*
* (non-Javadoc)
* @see android.view.View.OnClickListener#onClick(android.view.View)
*/
- public void onClick(View view) {
+ public boolean onLongClick(View view) {
- if (currentView == R.layout.layout_main)
- {
- try
+
+ try
+ {
+
+ if (mService == null)
{
+
+ }
+ else if (mService.getStatus() == STATUS_READY)
+ {
- if (mService == null)
- {
+ startTor();
- }
- else if (mService.getStatus() == STATUS_READY)
- {
-
- startTor();
-
- }
- else
- {
-
- stopTor();
-
- }
-
}
- catch (Exception e)
+ else
{
- Log.d(TAG,"error onclick",e);
+
+ stopTor();
+
}
}
-
-
+ catch (Exception e)
+ {
+ Log.d(TAG,"error onclick",e);
+ }
+
+ return true;
}
@@ -937,7 +697,7 @@
*/
public void statusChanged(String value) {
- Message msg = mHandler.obtainMessage(STATUS_MSG);
+ Message msg = mHandler.obtainMessage(TorServiceConstants.STATUS_MSG);
msg.getData().putString(HANDLER_TOR_MSG, value);
mHandler.sendMessage(msg);
}
@@ -945,43 +705,34 @@
@Override
public void logMessage(String value) throws RemoteException {
- Message msg = mHandler.obtainMessage(LOG_MSG);
+ Message msg = mHandler.obtainMessage(TorServiceConstants.LOG_MSG);
msg.getData().putString(HANDLER_TOR_MSG, value);
mHandler.sendMessage(msg);
}
};
- private static final int STATUS_MSG = 1;
- private static final int ENABLE_TOR_MSG = 2;
- private static final int DISABLE_TOR_MSG = 3;
- private static final int LOG_MSG = 4;
private Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
- case STATUS_MSG:
+ case TorServiceConstants.STATUS_MSG:
String torServiceMsg = (String)msg.getData().getString(HANDLER_TOR_MSG);
- logBuffer.append(torServiceMsg);
- logBuffer.append('\n');
-
-
if (torServiceMsg.length() > 0)
updateStatus(torServiceMsg);
break;
- case LOG_MSG:
- //do nothing
+ case TorServiceConstants.LOG_MSG:
break;
- case ENABLE_TOR_MSG:
+ case TorServiceConstants.ENABLE_TOR_MSG:
break;
- case DISABLE_TOR_MSG:
+ case TorServiceConstants.DISABLE_TOR_MSG:
break;
@@ -1006,21 +757,20 @@
// representation of that from the raw service object.
mService = ITorService.Stub.asInterface(service);
- updateStatus ("");
-
// We want to monitor the service for as long as we are
// connected to it.
try {
mService.registerCallback(mCallback);
-
- if (autoStartOnBind)
- {
- autoStartOnBind = false;
-
- startTor();
-
- }
+ updateStatus("");
+
+ if (autoStartOnBind)
+ {
+ autoStartOnBind = false;
+
+ startTor();
+
+ }
} catch (RemoteException e) {
// In this case the service has crashed before we could even
@@ -1029,6 +779,10 @@
// so there is no need to do anything here.
Log.d(TAG,"error registering callback to service",e);
}
+
+
+
+
}
Modified: projects/android/trunk/Orbot/src/org/torproject/android/SettingsPreferences.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/SettingsPreferences.java 2011-04-17 06:04:27 UTC (rev 24645)
+++ projects/android/trunk/Orbot/src/org/torproject/android/SettingsPreferences.java 2011-04-17 06:05:02 UTC (rev 24646)
@@ -37,7 +37,7 @@
if (prefs.contains("has_root"))
{
- hasRoot = prefs.getBoolean("has_root",false);//TorServiceUtils.checkRootAccess();
+ hasRoot = prefs.getBoolean("has_root",false);
}
else
{
@@ -103,10 +103,12 @@
@Override
public boolean onPreferenceClick(Preference preference) {
+ setResult(1010);
if (preference == prefTransProxyApps)
{
startActivity(new Intent(this, AppManager.class));
+
}
else if (preference == prefHiddenServices)
{
Modified: projects/android/trunk/Orbot/src/org/torproject/android/TorConstants.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/TorConstants.java 2011-04-17 06:04:27 UTC (rev 24645)
+++ projects/android/trunk/Orbot/src/org/torproject/android/TorConstants.java 2011-04-17 06:05:02 UTC (rev 24646)
@@ -21,9 +21,6 @@
public final static int STATUS_ON = 1;
public final static int STATUS_CONNECTING = 2;
- public final static int PROFILE_OFF = -1;
- public final static int PROFILE_ONDEMAND = 0;
- public final static int PROFILE_ON = 1;
public final static String NEWLINE = "\n";
Modified: projects/android/trunk/Orbot/src/org/torproject/android/WizardActivity.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/WizardActivity.java 2011-04-17 06:04:27 UTC (rev 24645)
+++ projects/android/trunk/Orbot/src/org/torproject/android/WizardActivity.java 2011-04-17 06:05:02 UTC (rev 24646)
@@ -41,7 +41,7 @@
public void showStep1()
{
- showDialog("Test","this is nathan's test","foo","bar",this);
+ showDialog("Test","","foo","bar",this);
}
private void showDialog (String title, String msg, String button1, String button2, OnClickListener ocListener)
Modified: projects/android/trunk/Orbot/src/org/torproject/android/WizardHelper.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/WizardHelper.java 2011-04-17 06:04:27 UTC (rev 24645)
+++ projects/android/trunk/Orbot/src/org/torproject/android/WizardHelper.java 2011-04-17 06:05:02 UTC (rev 24646)
@@ -48,7 +48,7 @@
View view = li.inflate(R.layout.layout_wizard_welcome, null);
- showCustomDialog(title, view,context.getString(R.string.btn_next),context.getString(R.string.wizard_btn_tell_me_more),new DialogInterface.OnClickListener() {
+ showCustomDialog(title, view,context.getString(R.string.btn_next),null,new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@@ -59,10 +59,11 @@
showWizardStep2();
}
+ /*
else if (which == DialogInterface.BUTTON_POSITIVE)
{
showAbout();
- }
+ }*/
}
});
@@ -116,8 +117,12 @@
currentDialog.getButton(AlertDialog.BUTTON_NEUTRAL).setEnabled(isChecked);
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+
+ Editor pEdit = prefs.edit();
+ pEdit.putBoolean("has_root",false);
+ pEdit.commit();
-
}
});
@@ -380,26 +385,8 @@
}
- private void showAbout ()
- {
-
- LayoutInflater li = LayoutInflater.from(context);
- View view = li.inflate(R.layout.layout_about, null);
-
- TextView versionName = (TextView)view.findViewById(R.id.versionName);
- versionName.setText(R.string.app_version);
-
- new AlertDialog.Builder(context)
- .setTitle(context.getString(R.string.button_about))
- .setView(view)
- .setNeutralButton(context.getString(R.string.btn_back), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- showWizard();
- }
- })
- .show();
- }
+
private void showProxyHelp ()
{
1
0

r24645: {projects} Improved transproxy code for background service (projects/android/trunk/Orbot/src/org/torproject/android/service)
by Nathan Freitas 17 Apr '11
by Nathan Freitas 17 Apr '11
17 Apr '11
Author: n8fr8
Date: 2011-04-17 06:04:27 +0000 (Sun, 17 Apr 2011)
New Revision: 24645
Modified:
projects/android/trunk/Orbot/src/org/torproject/android/service/Api.java
projects/android/trunk/Orbot/src/org/torproject/android/service/ITorService.aidl
projects/android/trunk/Orbot/src/org/torproject/android/service/TorService.java
projects/android/trunk/Orbot/src/org/torproject/android/service/TorServiceConstants.java
projects/android/trunk/Orbot/src/org/torproject/android/service/TorServiceUtils.java
projects/android/trunk/Orbot/src/org/torproject/android/service/TorTransProxy.java
Log:
Improved transproxy code for background service
Modified: projects/android/trunk/Orbot/src/org/torproject/android/service/Api.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/service/Api.java 2011-04-17 06:03:32 UTC (rev 24644)
+++ projects/android/trunk/Orbot/src/org/torproject/android/service/Api.java 2011-04-17 06:04:27 UTC (rev 24645)
@@ -801,23 +801,29 @@
boolean changed = false;
try {
// Check iptables_g1
- File file = new File(ctx.getDir("bin",0), "iptables_g1");
+ File file = new File(ctx.getDir("bin",0), "iptables");
+
if ((!file.exists()) && isARMv6()) {
copyRawFile(ctx, R.raw.iptables_g1, file, "755");
changed = true;
}
+
// Check iptables_n1
- file = new File(ctx.getDir("bin",0), "iptables_n1");
+ file = new File(ctx.getDir("bin",0), "iptables");
if ((!file.exists()) && (!isARMv6())) {
copyRawFile(ctx, R.raw.iptables_n1, file, "755");
changed = true;
}
+
// Check busybox
+ /*
file = new File(ctx.getDir("bin",0), "busybox_g1");
if (!file.exists()) {
copyRawFile(ctx, R.raw.busybox_g1, file, "755");
changed = true;
}
+ */
+
if (changed) {
Toast.makeText(ctx, R.string.status_install_success, Toast.LENGTH_LONG).show();
}
Modified: projects/android/trunk/Orbot/src/org/torproject/android/service/ITorService.aidl
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/service/ITorService.aidl 2011-04-17 06:03:32 UTC (rev 24644)
+++ projects/android/trunk/Orbot/src/org/torproject/android/service/ITorService.aidl 2011-04-17 06:04:27 UTC (rev 24645)
@@ -37,6 +37,11 @@
* Set configuration
**/
boolean updateConfiguration (String name, String value, boolean saveToDisk);
+
+ /**
+ * Set configuration
+ **/
+ void processSettings();
/**
* Set configuration
Modified: projects/android/trunk/Orbot/src/org/torproject/android/service/TorService.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/service/TorService.java 2011-04-17 06:03:32 UTC (rev 24644)
+++ projects/android/trunk/Orbot/src/org/torproject/android/service/TorService.java 2011-04-17 06:04:27 UTC (rev 24645)
@@ -4,6 +4,7 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.Socket;
import java.util.ArrayList;
@@ -18,8 +19,10 @@
import org.torproject.android.AppManager;
import org.torproject.android.Orbot;
+import org.torproject.android.ProcessSettingsAsyncTask;
import org.torproject.android.R;
import org.torproject.android.TorConstants;
+import org.torproject.android.Utils;
import android.app.AlertDialog;
import android.app.Notification;
@@ -31,6 +34,7 @@
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.IBinder;
+import android.os.Looper;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.preference.PreferenceManager;
@@ -39,6 +43,7 @@
public class TorService extends Service implements TorServiceConstants, Runnable, EventHandler
{
+ private static boolean ENABLE_DEBUG_LOG = false;
private static int currentStatus = STATUS_READY;
@@ -48,6 +53,7 @@
private static TorService _torInstance;
private static final int NOTIFY_ID = 1;
+ private static int NOTIFY_ID_ERROR = 2;
private static final int MAX_START_TRIES = 3;
@@ -69,11 +75,23 @@
public void onCreate() {
super.onCreate();
- Log.i(TAG, "serviced created");
+ logMessage("serviced created");
}
+ public static void logMessage(String msg)
+ {
+ if (ENABLE_DEBUG_LOG)
+ Log.d(TAG,msg);
+ }
+ public static void logException(String msg, Exception e)
+ {
+ if (ENABLE_DEBUG_LOG)
+ Log.e(TAG,msg,e);
+ }
+
+
private boolean findExistingProc ()
{
int procId = TorServiceUtils.findProcessId(torBinaryPath);
@@ -96,13 +114,12 @@
} catch (RuntimeException e) {
Log.d(TAG,"Unable to connect to existing Tor instance,",e);
currentStatus = STATUS_OFF;
- this.stopTor();
} catch (Exception e) {
Log.d(TAG,"Unable to connect to existing Tor instance,",e);
currentStatus = STATUS_OFF;
- this.stopTor();
+
}
}
@@ -144,7 +161,7 @@
}
- private void showToolbarNotification (String notifyMsg, int icon)
+ private void showToolbarNotification (String notifyMsg, int notifyId, int icon)
{
@@ -166,7 +183,7 @@
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
- mNotificationManager.notify(NOTIFY_ID, notification);
+ mNotificationManager.notify(notifyId, notification);
}
@@ -196,7 +213,7 @@
} catch (Exception e) {
logNotice("unable to find tor binaries: " + e.getMessage());
- showToolbarNotification(e.getMessage(), R.drawable.tornotificationoff);
+ showToolbarNotification(e.getMessage(), NOTIFY_ID_ERROR, R.drawable.tornotificationoff);
Log.e(TAG, "error checking tor binaries", e);
}
@@ -226,13 +243,12 @@
try
{
initTor();
-
-
+ isRunning = true;
}
catch (Exception e)
{
currentStatus = STATUS_OFF;
- this.showToolbarNotification(getString(R.string.status_disabled), R.drawable.tornotification);
+ this.showToolbarNotification(getString(R.string.status_disabled), NOTIFY_ID_ERROR, R.drawable.tornotification);
Log.d(TAG,"Unable to start Tor: " + e.getMessage(),e);
}
}
@@ -243,10 +259,11 @@
{
super.onDestroy();
+ Log.d(TAG,"onDestroy called");
+
// Unregister all callbacks.
mCallbacks.kill();
- stopTor();
}
private void stopTor ()
@@ -259,7 +276,7 @@
currentStatus = STATUS_READY;
- showToolbarNotification (getString(R.string.status_disabled),R.drawable.tornotificationoff);
+ showToolbarNotification (getString(R.string.status_disabled),NOTIFY_ID,R.drawable.tornotificationoff);
sendCallbackStatusMessage(getString(R.string.status_disabled));
setupTransProxy(false);
@@ -275,7 +292,7 @@
-
+ /*
public void reloadConfig ()
{
try
@@ -294,8 +311,212 @@
{
Log.d(TAG,"Unable to reload configuration",e);
}
- }
+ }*/
+
+ /*
+ private void loadTorSettingsFromPreferences () throws RemoteException
+ {
+ try
+ {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+
+ ENABLE_DEBUG_LOG = prefs.getBoolean("pref_enable_logging",false);
+ Log.i(TAG,"debug logging:" + ENABLE_DEBUG_LOG);
+
+ boolean useBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_ENABLED, false);
+
+ //boolean autoUpdateBridges = prefs.getBoolean(PREF_BRIDGES_UPDATED, false);
+
+ boolean becomeRelay = prefs.getBoolean(TorConstants.PREF_OR, false);
+
+ boolean ReachableAddresses = prefs.getBoolean(TorConstants.PREF_REACHABLE_ADDRESSES,false);
+
+ boolean enableHiddenServices = prefs.getBoolean("pref_hs_enable", false);
+
+ boolean enableTransparentProxy = prefs.getBoolean(TorConstants.PREF_TRANSPARENT, false);
+ mBinder.updateTransProxy();
+
+ String bridgeList = prefs.getString(TorConstants.PREF_BRIDGES_LIST,"");
+
+ if (useBridges)
+ {
+ if (bridgeList == null || bridgeList.length() == 0)
+ {
+
+ showAlert("Bridge Error","In order to use the bridge feature, you must enter at least one bridge IP address." +
+ "Send an email to bridges(a)torproject.org with the line \"get bridges\" by itself in the body of the mail from a gmail account.");
+
+
+ return;
+ }
+
+
+ mBinder.updateConfiguration("UseBridges", "1", false);
+
+ String bridgeDelim = "\n";
+
+ if (bridgeList.indexOf(",") != -1)
+ {
+ bridgeDelim = ",";
+ }
+
+ StringTokenizer st = new StringTokenizer(bridgeList,bridgeDelim);
+ while (st.hasMoreTokens())
+ {
+
+ mBinder.updateConfiguration("bridge", st.nextToken(), false);
+
+ }
+
+ mBinder.updateConfiguration("UpdateBridgesFromAuthority", "0", false);
+
+ }
+ else
+ {
+ mBinder.updateConfiguration("UseBridges", "0", false);
+
+ }
+
+ try
+ {
+ if (ReachableAddresses)
+ {
+ String ReachableAddressesPorts =
+ prefs.getString(TorConstants.PREF_REACHABLE_ADDRESSES_PORTS, "*:80,*:443");
+
+ mBinder.updateConfiguration("ReachableAddresses", ReachableAddressesPorts, false);
+
+ }
+ else
+ {
+ mBinder.updateConfiguration("ReachableAddresses", "", false);
+ }
+ }
+ catch (Exception e)
+ {
+ showAlert("Config Error","Your ReachableAddresses settings caused an exception!");
+ }
+
+ try
+ {
+ if (becomeRelay && (!useBridges) && (!ReachableAddresses))
+ {
+ int ORPort = Integer.parseInt(prefs.getString(TorConstants.PREF_OR_PORT, "9001"));
+ String nickname = prefs.getString(TorConstants.PREF_OR_NICKNAME, "Orbot");
+
+ mBinder.updateConfiguration("ORPort", ORPort + "", false);
+ mBinder.updateConfiguration("Nickname", nickname, false);
+ mBinder.updateConfiguration("ExitPolicy", "reject *:*", false);
+
+ }
+ else
+ {
+ mBinder.updateConfiguration("ORPort", "", false);
+ mBinder.updateConfiguration("Nickname", "", false);
+ mBinder.updateConfiguration("ExitPolicy", "", false);
+ }
+ }
+ catch (Exception e)
+ {
+ showAlert("Uh-oh!","Your relay settings caused an exception!");
+
+ return;
+ }
+
+ if (enableHiddenServices)
+ {
+ mBinder.updateConfiguration("HiddenServiceDir","/data/data/org.torproject.android/", false);
+
+ String hsPorts = prefs.getString("pref_hs_ports","");
+
+ StringTokenizer st = new StringTokenizer (hsPorts,",");
+ String hsPortConfig = null;
+
+ while (st.hasMoreTokens())
+ {
+ hsPortConfig = st.nextToken();
+
+ if (hsPortConfig.indexOf(":")==-1) //setup the port to localhost if not specifed
+ {
+ hsPortConfig = hsPortConfig + " 127.0.0.1:" + hsPortConfig;
+ }
+
+ mBinder.updateConfiguration("HiddenServicePort",hsPortConfig, false);
+ }
+
+ //force save now so the hostname file gets generated
+ mBinder.saveConfiguration();
+
+ String onionHostname = getHiddenServiceHostname();
+
+ if (onionHostname != null)
+ {
+
+ Editor pEdit = prefs.edit();
+ pEdit.putString("pref_hs_hostname",onionHostname);
+ pEdit.commit();
+
+ }
+ }
+ else
+ {
+ mBinder.updateConfiguration("HiddenServiceDir","", false);
+ }
+
+ mBinder.saveConfiguration();
+
+ }
+ catch (Exception e)
+ {
+ showAlert("Uh-oh!","There was an error updating your settings");
+
+ Log.w(TAG, "processSettings()", e);
+
+ return;
+ }
+
+ }*/
+
+ private void getHiddenServiceHostname ()
+ {
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+
+ boolean enableHiddenServices = prefs.getBoolean("pref_hs_enable", false);
+
+ if (enableHiddenServices)
+ {
+ File file = new File(appDataHome, "hostname");
+
+ if (file.exists())
+ {
+ try {
+ String onionHostname = Utils.readString(new FileInputStream(file));
+ showToolbarNotification("hidden service on: " + onionHostname, NOTIFY_ID_ERROR, R.drawable.tornotification);
+ Editor pEdit = prefs.edit();
+ pEdit.putString("pref_hs_hostname",onionHostname);
+ pEdit.commit();
+
+
+ } catch (FileNotFoundException e) {
+ logException("unable to read onion hostname file",e);
+ showToolbarNotification("unable to read hidden service name", NOTIFY_ID_ERROR, R.drawable.tornotification);
+ return;
+ }
+ }
+ else
+ {
+ showToolbarNotification("unable to read hidden service name", NOTIFY_ID_ERROR, R.drawable.tornotification);
+
+
+ }
+ }
+
+ return;
+ }
+
+
private void killTorProcess () throws Exception
{
//android.os.Debug.waitForDebugger();
@@ -348,96 +569,15 @@
{
if (msg != null && msg.trim().length() > 0)
{
- if (LOG_OUTPUT_TO_DEBUG)
+ if (ENABLE_DEBUG_LOG)
Log.d(TAG, msg);
sendCallbackLogMessage(msg);
}
}
- /*
- private String findAPK ()
- {
-
- String apkBase = "/data/app/";
-
- String APK_EXT = ".apk";
-
- int MAX_TRIES = 10;
-
- String buildPath = apkBase + TOR_APP_USERNAME + APK_EXT;
- logNotice("Checking APK location: " + buildPath);
-
- File fileApk = new File(buildPath);
-
- if (fileApk.exists())
- return fileApk.getAbsolutePath();
-
- for (int i = 0; i < MAX_TRIES; i++)
- {
- buildPath = apkBase + TOR_APP_USERNAME + '-' + i + APK_EXT;
- fileApk = new File(buildPath);
-
- logNotice( "Checking APK location: " + buildPath);
-
- if (fileApk.exists())
- return fileApk.getAbsolutePath();
- }
-
- String apkBaseExt = "/mnt/asec/" + TOR_APP_USERNAME;
- String pkgFile = "/pkg.apk";
-
- buildPath = apkBaseExt + pkgFile;
- fileApk = new File(buildPath);
-
- logNotice( "Checking external storage APK location: " + buildPath);
-
- if (fileApk.exists())
- return fileApk.getAbsolutePath();
-
- for (int i = 0; i < MAX_TRIES; i++)
- {
- buildPath = apkBaseExt + '-' + i + pkgFile;
- fileApk = new File(buildPath);
-
- logNotice( "Checking external storage APK location: " + buildPath);
-
- if (fileApk.exists())
- return fileApk.getAbsolutePath();
- }
-
- apkBase = "/sd-ext/app/";
-
- APK_EXT = ".apk";
-
- MAX_TRIES = 10;
-
- buildPath = apkBase + TOR_APP_USERNAME + APK_EXT;
- logNotice("Checking Apps2SD APK location: " + buildPath);
-
- fileApk = new File(buildPath);
-
- if (fileApk.exists())
- return fileApk.getAbsolutePath();
-
- for (int i = 0; i < MAX_TRIES; i++)
- {
- buildPath = apkBase + TOR_APP_USERNAME + '-' + i + APK_EXT;
- fileApk = new File(buildPath);
-
- logNotice( "Checking Apps2SD location: " + buildPath);
-
- if (fileApk.exists())
- return fileApk.getAbsolutePath();
- }
-
-
-
- return null;
- }*/
-
private boolean checkTorBinaries () throws Exception
{
//android.os.Debug.waitForDebugger();
@@ -475,7 +615,7 @@
{
logNotice(getString(R.string.status_install_success));
- showToolbarNotification(getString(R.string.status_install_success), R.drawable.tornotification);
+ showToolbarNotification(getString(R.string.status_install_success), NOTIFY_ID, R.drawable.tornotification);
}
else
@@ -522,30 +662,100 @@
killTorProcess ();
-
- new Thread()
- {
- public void run ()
- {
- try {
- runTorShellCmd();
-
- setupTransProxy(true);
-
- runPrivoxyShellCmd();
+ try {
+ runTorShellCmd();
+ runPrivoxyShellCmd();
+ setupTransProxy(true);
- } catch (Exception e) {
- Log.d(TAG,"Unable to start Tor: " + e.getMessage(),e);
- sendCallbackStatusMessage("Unable to start Tor: " + e.getMessage());
- stopTor();
- }
- }
- }.start();
+ } catch (Exception e) {
+ logException("Unable to start Tor: " + e.getMessage(),e);
+ sendCallbackStatusMessage("Unable to start Tor: " + e.getMessage());
+
+ }
-
}
+
+ private boolean setupTransProxy (boolean activate) throws Exception
+ {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+ boolean hasRoot;
+
+ if (prefs.contains("has_root"))
+ {
+ hasRoot = prefs.getBoolean("has_root",false);
+ }
+ else
+ {
+ hasRoot = TorServiceUtils.checkRootAccess();
+ Editor pEdit = prefs.edit();
+ pEdit.putBoolean("has_root",hasRoot);
+ pEdit.commit();
+ }
+
+ if (!hasRoot)
+ return false;
+
+ if (activate)
+ {
+
+ boolean enableTransparentProxy = prefs.getBoolean("pref_transparent", false);
+ boolean transProxyAll = prefs.getBoolean("pref_transparent_all", false);
+ boolean transProxyPortFallback = prefs.getBoolean("pref_transparent_port_fallback", false);
+
+ TorService.logMessage ("Transparent Proxying: " + enableTransparentProxy);
+
+ String portProxyList = prefs.getString("pref_port_list", "");
+
+ if (enableTransparentProxy)
+ {
+ showAlert("Status", "Setting up transparent proxying...");
+
+ //TorTransProxy.setDNSProxying();
+ int code = TorTransProxy.setTransparentProxyingByApp(this,AppManager.getApps(this),transProxyAll);
+
+ TorService.logMessage ("TorTransProxy resp code: " + code);
+
+ if (code == 0)
+ {
+ showAlert("Status", "Transparent proxying ENABLED");
+ }
+ else
+ {
+ showAlert("Status", "WARNING: error starting transparent proxying!");
+ }
+
+ //this is for Androids w/o owner module support as a circumvention only fallback
+ if (transProxyPortFallback)
+ {
+ StringTokenizer st = new StringTokenizer(portProxyList, ",");
+
+ while (st.hasMoreTokens())
+ TorTransProxy.setTransparentProxyingByPort(this, Integer.parseInt(st.nextToken()));
+
+ }
+
+ return true;
+
+ }
+ else
+ {
+ TorTransProxy.purgeIptables(this);
+ showAlert("Status", "Transparent proxying DISABLED");
+
+ }
+ }
+ else
+ {
+ TorTransProxy.purgeIptables(this);
+ showAlert("Status", "Transparent proxying DISABLED");
+
+ }
+
+ return true;
+ }
+
private void runTorShellCmd() throws Exception
{
@@ -598,9 +808,11 @@
logNotice("Tor process id=" + procId);
- showToolbarNotification(getString(R.string.status_starting_up), R.drawable.tornotification);
+ showToolbarNotification(getString(R.string.status_starting_up), NOTIFY_ID, R.drawable.tornotification);
initControlConnection ();
+
+ applyPreferences();
}
}
@@ -644,7 +856,6 @@
}
sendCallbackLogMessage("Privoxy is running on port: " + PORT_HTTP);
- Thread.sleep(100);
logNotice("Privoxy process id=" + privoxyProcId);
@@ -699,7 +910,6 @@
addEventHandler();
- applyPreferences();
}
break; //don't need to retry
@@ -811,9 +1021,9 @@
Thread thread = new Thread(this);
thread.start();
-
+
}
- else
+ else if (profile == PROFILE_OFF)
{
currentStatus = STATUS_OFF;
sendCallbackStatusMessage ("shutting down...");
@@ -828,29 +1038,37 @@
public void message(String severity, String msg) {
+
logNotice( "[Tor Control Port] " + severity + ": " + msg);
if (msg.indexOf(TOR_CONTROL_PORT_MSG_BOOTSTRAP_DONE)!=-1)
{
currentStatus = STATUS_ON;
- showToolbarNotification (getString(R.string.status_activated),R.drawable.tornotificationon);
-
+
+
+ getHiddenServiceHostname ();
+
}
-
+
+
+ showToolbarNotification (getString(R.string.status_activated),NOTIFY_ID,R.drawable.tornotificationon);
+
sendCallbackStatusMessage (msg);
}
private void showAlert(String title, String msg)
{
-
+ /*
new AlertDialog.Builder(this)
.setTitle(title)
.setMessage(msg)
.setPositiveButton(android.R.string.ok, null)
.show();
+ */
+ showToolbarNotification(msg, NOTIFY_ID_ERROR, R.drawable.tornotification);
}
-
+
public void newDescriptors(List<String> orList) {
}
@@ -858,7 +1076,7 @@
public void orConnStatus(String status, String orName) {
- if (LOG_OUTPUT_TO_DEBUG)
+ if (ENABLE_DEBUG_LOG)
{
StringBuilder sb = new StringBuilder();
sb.append("orConnStatus (");
@@ -873,7 +1091,7 @@
public void streamStatus(String status, String streamID, String target) {
- if (LOG_OUTPUT_TO_DEBUG)
+ if (ENABLE_DEBUG_LOG)
{
StringBuilder sb = new StringBuilder();
sb.append("StreamStatus (");
@@ -888,7 +1106,7 @@
public void unrecognized(String type, String msg) {
- if (LOG_OUTPUT_TO_DEBUG)
+ if (ENABLE_DEBUG_LOG)
{
StringBuilder sb = new StringBuilder();
sb.append("Message (");
@@ -903,20 +1121,23 @@
public void bandwidthUsed(long read, long written) {
- StringBuilder sb = new StringBuilder();
- sb.append("Bandwidth used: ");
- sb.append(read/1000);
- sb.append("kb read / ");
- sb.append(written/1000);
- sb.append("kb written");
-
- logNotice(sb.toString());
+ if (ENABLE_DEBUG_LOG)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Bandwidth used: ");
+ sb.append(read/1000);
+ sb.append("kb read / ");
+ sb.append(written/1000);
+ sb.append("kb written");
+
+ logNotice(sb.toString());
+ }
}
public void circuitStatus(String status, String circID, String path) {
- if (LOG_OUTPUT_TO_DEBUG)
+ if (ENABLE_DEBUG_LOG)
{
StringBuilder sb = new StringBuilder();
sb.append("Circuit (");
@@ -947,7 +1168,7 @@
catch (Exception e)
{
logNotice("unable to find tor binaries: " + e.getMessage());
- showToolbarNotification(e.getMessage(), R.drawable.tornotificationoff);
+ showToolbarNotification(e.getMessage(), NOTIFY_ID_ERROR, R.drawable.tornotificationoff);
Log.d(TAG,"Unable to check for Tor binaries",e);
return null;
@@ -977,7 +1198,8 @@
*/
private final ITorService.Stub mBinder = new ITorService.Stub() {
- public void registerCallback(ITorServiceCallback cb) {
+
+ public void registerCallback(ITorServiceCallback cb) {
if (cb != null) mCallbacks.register(cb);
}
public void unregisterCallback(ITorServiceCallback cb) {
@@ -993,6 +1215,18 @@
}
+ public void processSettings ()
+ {
+
+
+ try {
+ applyPreferences();
+ } catch (RemoteException e) {
+ logException ("error applying prefs",e);
+ }
+
+ }
+
public boolean updateTransProxy ()
{
@@ -1044,6 +1278,7 @@
return null;
}
+
/**
* Set configuration
**/
@@ -1057,7 +1292,7 @@
if (value == null || value.length() == 0)
{
-
+ resetBuffer.add(name);
/*
if (conn != null)
{
@@ -1066,10 +1301,7 @@
} catch (IOException e) {
Log.w(TAG, "Unable to reset conf",e);
}
- }
- */
-
- resetBuffer.add(name);
+ }*/
}
else
configBuffer.add(name + ' ' + value);
@@ -1083,13 +1315,13 @@
{
if (conn != null)
{
+
if (resetBuffer != null && resetBuffer.size() > 0)
{
conn.resetConf(resetBuffer);
resetBuffer = null;
}
-
if (configBuffer != null && configBuffer.size() > 0)
{
@@ -1117,24 +1349,21 @@
private ArrayList<String> callbackBuffer = new ArrayList<String>();
private boolean inCallbackStatus = false;
- private boolean inCallbackLog = false;
+ private boolean inCallback = false;
- private void sendCallbackStatusMessage (String newStatus)
+ private synchronized void sendCallbackStatusMessage (String newStatus)
{
if (mCallbacks == null)
return;
-
-
// Broadcast to all clients the new value.
final int N = mCallbacks.beginBroadcast();
- inCallbackStatus = true;
+ inCallback = true;
if (N > 0)
{
-
for (int i=0; i<N; i++) {
try {
mCallbacks.getBroadcastItem(i).statusChanged(newStatus);
@@ -1148,58 +1377,58 @@
}
mCallbacks.finishBroadcast();
- inCallbackStatus = false;
+ inCallback = false;
}
- private void sendCallbackLogMessage (String logMessage)
+ private synchronized void sendCallbackLogMessage (String logMessage)
{
if (mCallbacks == null)
return;
callbackBuffer.add(logMessage);
-
-
- // Broadcast to all clients the new value.
- final int N = mCallbacks.beginBroadcast();
-
- inCallbackLog = true;
+ if (!inCallback)
+ {
+
+ inCallback = true;
+ // Broadcast to all clients the new value.
+ final int N = mCallbacks.beginBroadcast();
+
+
+ if (N > 0)
+ {
+
+ Iterator<String> it = callbackBuffer.iterator();
+ String status = null;
+
+ while (it.hasNext())
+ {
+ status = it.next();
+
+ for (int i=0; i<N; i++) {
+ try {
+ mCallbacks.getBroadcastItem(i).logMessage(status);
+
+ } catch (RemoteException e) {
+ // The RemoteCallbackList will take care of removing
+ // the dead object for us.
+ }
+ }
+ }
+
+ callbackBuffer.clear();
+ }
+
+ mCallbacks.finishBroadcast();
+ inCallback = false;
+ }
- if (N > 0)
- {
-
- Iterator<String> it = callbackBuffer.iterator();
- String status = null;
-
- while (it.hasNext())
- {
- status = it.next();
-
- for (int i=0; i<N; i++) {
- try {
- mCallbacks.getBroadcastItem(i).logMessage(status);
-
-
- } catch (RemoteException e) {
- // The RemoteCallbackList will take care of removing
- // the dead object for us.
- }
- }
- }
-
- callbackBuffer.clear();
- }
-
- mCallbacks.finishBroadcast();
- inCallbackLog = false;
}
- private void applyPreferences () throws RemoteException
+ private boolean applyPreferences () throws RemoteException
{
-
-
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean useBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_ENABLED, false);
@@ -1214,11 +1443,19 @@
boolean enableTransparentProxy = prefs.getBoolean(TorConstants.PREF_TRANSPARENT, false);
+ try
+ {
+ setupTransProxy(currentStatus != STATUS_OFF);
+ }
+ catch (Exception e)
+ {
+ logException("unable to setup transproxy",e);
+ }
- String bridgeList = prefs.getString(TorConstants.PREF_BRIDGES_LIST,"");
-
if (useBridges)
{
+ String bridgeList = prefs.getString(TorConstants.PREF_BRIDGES_LIST,"");
+
if (bridgeList == null || bridgeList.length() == 0)
{
@@ -1226,7 +1463,7 @@
"Send an email to bridges(a)torproject.org with the line \"get bridges\" by itself in the body of the mail from a gmail account.");
- return;
+ return false;
}
@@ -1274,6 +1511,8 @@
catch (Exception e)
{
showAlert("Config Error","Your ReachableAddresses settings caused an exception!");
+
+ return false;
}
try
@@ -1299,12 +1538,12 @@
{
showAlert("Uh-oh!","Your relay settings caused an exception!");
- return;
+ return false;
}
if (enableHiddenServices)
{
- mBinder.updateConfiguration("HiddenServiceDir","/data/data/org.torproject.android/", false);
+ mBinder.updateConfiguration("HiddenServiceDir",appDataHome, false);
String hsPorts = prefs.getString("pref_hs_ports","");
@@ -1332,77 +1571,10 @@
}
mBinder.saveConfiguration();
-
+
+ return true;
}
- private boolean setupTransProxy (boolean enabled) throws Exception
- {
-
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplication());
-
- if (prefs.contains("has_root"))
- {
- hasRoot = prefs.getBoolean("has_root",false);//TorServiceUtils.checkRootAccess();
- }
- else
- {
- hasRoot = TorServiceUtils.checkRootAccess();
- Editor pEdit = prefs.edit();
- pEdit.putBoolean("has_root",hasRoot);
- pEdit.commit();
- }
-
- boolean enableTransparentProxy = prefs.getBoolean("pref_transparent", false);
- boolean transProxyAll = prefs.getBoolean("pref_transparent_all", false);
-
- boolean transProxyPortFallback = prefs.getBoolean("pref_transparent_port_fallback", false);
-
- logNotice ("Transparent Proxying: " + enableTransparentProxy);
-
- String portProxyList = prefs.getString("pref_port_list", "");
-
- if (enabled)
- {
-
-
- if (hasRoot)
- {
- if (enableTransparentProxy)
- {
-
-
- //TorTransProxy.setDNSProxying();
- int code = TorTransProxy.setTransparentProxyingByApp(this,AppManager.getApps(this),transProxyAll);
-
- logNotice ("TorTransProxy resp code: " + code);
-
- //this is for Androids w/o owner module support as a circumvention only fallback
- if (transProxyPortFallback)
- {
- StringTokenizer st = new StringTokenizer(portProxyList, ",");
-
- while (st.hasMoreTokens())
- TorTransProxy.setTransparentProxyingByPort(this, Integer.parseInt(st.nextToken()));
-
- }
-
- return true;
-
-
- }
- else
- {
- TorTransProxy.purgeIptables(this);
-
- }
- }
- }
- else if (hasRoot)
- {
- TorTransProxy.purgeIptables(this);
- }
-
- return true;
- }
+
}
Modified: projects/android/trunk/Orbot/src/org/torproject/android/service/TorServiceConstants.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/service/TorServiceConstants.java 2011-04-17 06:03:32 UTC (rev 24644)
+++ projects/android/trunk/Orbot/src/org/torproject/android/service/TorServiceConstants.java 2011-04-17 06:04:27 UTC (rev 24645)
@@ -6,8 +6,6 @@
public final static String TAG = "ORBOT";
- public static boolean LOG_OUTPUT_TO_DEBUG = true;
-
public final static String TOR_APP_USERNAME = "org.torproject.android";
public final static String ASSETS_BASE = "assets/";
@@ -78,4 +76,9 @@
public final static int PROFILE_OFF = -1;
public final static int PROFILE_ON = 1;
+
+ public static final int STATUS_MSG = 1;
+ public static final int ENABLE_TOR_MSG = 2;
+ public static final int DISABLE_TOR_MSG = 3;
+ public static final int LOG_MSG = 4;
}
Modified: projects/android/trunk/Orbot/src/org/torproject/android/service/TorServiceUtils.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/service/TorServiceUtils.java 2011-04-17 06:03:32 UTC (rev 24644)
+++ projects/android/trunk/Orbot/src/org/torproject/android/service/TorServiceUtils.java 2011-04-17 06:04:27 UTC (rev 24645)
@@ -34,22 +34,19 @@
} catch (IOException e) {
//this means that there is no root to be had (normally) so we won't log anything
+ TorService.logException("Error checking for root access",e);
+
}
catch (Exception e) {
- Log.w(TAG,"Error checking for root access: " + e.getMessage());
+ TorService.logException("Error checking for root access",e);
//this means that there is no root to be had (normally)
}
- logNotice("Could not acquire root permissions");
+ TorService.logMessage("Could not acquire root permissions");
return false;
}
- private static void logNotice (String msg)
- {
- if (LOG_OUTPUT_TO_DEBUG)
- Log.d(TAG, msg);
- }
public static int findProcessId(String command)
{
@@ -106,7 +103,7 @@
}
catch (NumberFormatException e)
{
- logNotice("unable to parse process pid: " + line);
+ TorService.logException("unable to parse process pid: " + line,e);
}
}
@@ -153,7 +150,7 @@
public static int doShellCommand(String[] cmds, StringBuilder log, boolean runAsRoot, boolean waitFor) throws Exception
{
- logNotice("executing shell cmds: " + cmds[0] + "; runAsRoot=" + runAsRoot);
+ TorService.logMessage("executing shell cmds: " + cmds[0] + "; runAsRoot=" + runAsRoot);
Process proc = null;
@@ -201,7 +198,7 @@
log.append(exitCode);
log.append("\n");
- logNotice("command process exit value: " + exitCode);
+ TorService.logMessage("command process exit value: " + exitCode);
}
Modified: projects/android/trunk/Orbot/src/org/torproject/android/service/TorTransProxy.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/service/TorTransProxy.java 2011-04-17 06:03:32 UTC (rev 24644)
+++ projects/android/trunk/Orbot/src/org/torproject/android/service/TorTransProxy.java 2011-04-17 06:04:27 UTC (rev 24645)
@@ -11,55 +11,11 @@
private final static String TAG = TorServiceConstants.TAG;
- //private static String BASE_DIR = "/data/data/" + TorServiceConstants.TOR_APP_USERNAME + "/";
- private static void logNotice (String msg)
- {
- if (LOG_OUTPUT_TO_DEBUG)
- Log.d(TAG, msg);
- }
-
- /**
- * Check if we have root access
- * @return boolean true if we have root
- */
- /*
- public static String getIPTablesVersion() {
-
- StringBuilder log = new StringBuilder();
-
- try {
-
- // Run an empty script just to check root access
- String[] cmd = {"iptables -v"};
- int code = TorServiceUtils.doShellCommand(cmd, log, true, true);
- String msg = log.toString();
- logNotice(cmd[0] + ";errCode=" + code + ";resp=" + msg);
-
-
- String out = log.toString();
- if (out.indexOf(" v")!=-1)
- {
-
- out = out.substring(out.indexOf(" v")+2);
- out = out.substring(0,out.indexOf(":"));
-
- return out.trim();
- }
-
-
- } catch (Exception e) {
- Log.w(TAG,"Error checking iptables version: " + e.getMessage() ,e);
- }
-
- logNotice("Could not acquire check iptables: " + log.toString());
- return null;
- }*/
-
public static int purgeIptables(Context context) throws Exception {
- String ipTablesPath = new File(context.getDir("bin", 0),"iptables_n1").getAbsolutePath();
+ String ipTablesPath = new File(context.getDir("bin", 0),"iptables").getAbsolutePath();
final StringBuilder script = new StringBuilder();
@@ -78,7 +34,8 @@
String[] cmd = {script.toString()};
code = TorServiceUtils.doShellCommand(cmd, res, true, true);
String msg = res.toString();
- logNotice(cmd[0] + ";errCode=" + code + ";resp=" + msg);
+
+ TorService.logMessage(cmd[0] + ";errCode=" + code + ";resp=" + msg);
return code;
@@ -90,7 +47,7 @@
//restoreDNSResolvConf(); //not working yet
- String ipTablesPath = new File(context.getDir("bin", 0),"iptables_n1").getAbsolutePath();
+ String ipTablesPath = new File(context.getDir("bin", 0),"iptables").getAbsolutePath();
final StringBuilder script = new StringBuilder();
@@ -171,12 +128,14 @@
public static int setTransparentProxyingByApp(Context context, TorifiedApp[] apps, boolean forceAll) throws Exception
{
+ boolean runRoot = true;
+ boolean waitFor = true;
+
//android.os.Debug.waitForDebugger();
//redirectDNSResolvConf(); //not working yet
- //String baseDir = context.getDir("bin", 0).getAbsolutePath() + "/";
- String ipTablesPath = new File(context.getDir("bin", 0),"iptables_n1").getAbsolutePath();
+ String ipTablesPath = new File(context.getDir("bin", 0),"iptables").getAbsolutePath();
boolean ipTablesOld = false;
@@ -202,17 +161,8 @@
continue;
}
- logNotice("enabling transproxy for app: " + apps[i].getUsername() + "(" + apps[i].getUid() + ")");
+ TorService.logMessage("enabling transproxy for app: " + apps[i].getUsername() + "(" + apps[i].getUid() + ")");
- /*
- * iptables -t nat -A OUTPUT -p tcp -m owner --uid-owner anonymous -m tcp --syn -j REDIRECT --to-ports 9040
-iptables -t nat -A OUTPUT -p udp -m owner --uid-owner anonymous -m udp --dport 53 -j REDIRECT --to-ports 53
-iptables -t nat -A OUTPUT -m owner --uid-owner anonymous -j DROP
- */
-
-
- //iptables -t nat -A output -p tcp -m owner --uid-owner 100 -m tcp --sync -j REDIRECT --to-ports 9040
-
//TCP
script.append(ipTablesPath);
script.append(" -t nat");
@@ -248,7 +198,6 @@
script.append(" || exit\n");
- //EVERYTHING ELSE - DROP!
if (ipTablesOld) //for some reason this doesn't work on iptables 1.3.7
{
script.append(ipTablesPath);
@@ -288,18 +237,17 @@
}
+
}
- else
- {
- }
}
+ String[] cmdAdd = {script.toString()};
- String[] cmdAdd = {script.toString()};
- code = TorServiceUtils.doShellCommand(cmdAdd, res, true, true);
+ code = TorServiceUtils.doShellCommand(cmdAdd, res, runRoot, waitFor);
String msg = res.toString();
- logNotice(cmdAdd[0] + ";errCode=" + code + ";resp=" + msg);
+ TorService.logMessage(cmdAdd[0] + ";errCode=" + code + ";resp=" + msg);
+
return code;
}
@@ -311,7 +259,7 @@
//redirectDNSResolvConf(); //not working yet
//String baseDir = context.getDir("bin",0).getAbsolutePath() + '/';
- String ipTablesPath = new File(context.getDir("bin", 0),"iptables_n1").getAbsolutePath();
+ String ipTablesPath = new File(context.getDir("bin", 0),"iptables").getAbsolutePath();
boolean ipTablesOld = false;
@@ -380,7 +328,7 @@
String[] cmdAdd = {script.toString()};
code = TorServiceUtils.doShellCommand(cmdAdd, res, true, true);
String msg = res.toString();
- logNotice(cmdAdd[0] + ";errCode=" + code + ";resp=" + msg);
+ TorService.logMessage(cmdAdd[0] + ";errCode=" + code + ";resp=" + msg);
return code;
}
1
0

r24644: {projects} modified layout of main and about dialogs (projects/android/trunk/Orbot/res/layout)
by Nathan Freitas 17 Apr '11
by Nathan Freitas 17 Apr '11
17 Apr '11
Author: n8fr8
Date: 2011-04-17 06:03:32 +0000 (Sun, 17 Apr 2011)
New Revision: 24644
Modified:
projects/android/trunk/Orbot/res/layout/layout_about.xml
projects/android/trunk/Orbot/res/layout/layout_main.xml
Log:
modified layout of main and about dialogs
Modified: projects/android/trunk/Orbot/res/layout/layout_about.xml
===================================================================
--- projects/android/trunk/Orbot/res/layout/layout_about.xml 2011-04-16 20:56:02 UTC (rev 24643)
+++ projects/android/trunk/Orbot/res/layout/layout_about.xml 2011-04-17 06:03:32 UTC (rev 24644)
@@ -100,6 +100,13 @@
android:autoLink="web"
android:textColorLink="#ffffff"
android:paddingLeft="15px"
+ android:textColor="#ffffff" />
+ <TextView android:text="Iptables v1.4.7: http://www.netfilter.org"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:autoLink="web"
+ android:textColorLink="#ffffff"
+ android:paddingLeft="15px"
android:textColor="#ffffff" />
</LinearLayout>
</ScrollView>
Modified: projects/android/trunk/Orbot/res/layout/layout_main.xml
===================================================================
--- projects/android/trunk/Orbot/res/layout/layout_main.xml 2011-04-16 20:56:02 UTC (rev 24643)
+++ projects/android/trunk/Orbot/res/layout/layout_main.xml 2011-04-17 06:03:32 UTC (rev 24644)
@@ -3,7 +3,9 @@
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
- android:background="@drawable/bgtitanium">
+ android:background="@drawable/bgtitanium"
+ android:id="@+id/viewMain"
+ >
<RelativeLayout android:id="@+id/layoutHeaderMain"
android:layout_width="fill_parent"
@@ -59,7 +61,7 @@
android:gravity="center_horizontal"
android:textStyle="bold"
android:width="330px"
- android:height="75px"
+ android:height="125px"
android:textColor="#ffffff"
/>
</TableRow>
1
0

[torspec/master] Clarify that the client- and server-versions fields
by arma@torproject.org 17 Apr '11
by arma@torproject.org 17 Apr '11
17 Apr '11
commit 9a7bc15df331fe4eb5567193c7de62066ad03c6b
Author: Sebastian Hahn <sebastian(a)torproject.org>
Date: Sun Apr 17 02:01:54 2011 +0200
Clarify that the client- and server-versions fields
We only mean Tor versions there
---
dir-spec.txt | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/dir-spec.txt b/dir-spec.txt
index 3b8465f..589b0e9 100644
--- a/dir-spec.txt
+++ b/dir-spec.txt
@@ -1129,16 +1129,18 @@
[At most once.]
- A comma-separated list of recommended client versions, in
- ascending order. If absent, no opinion is held about client
+ A comma-separated list of recommended Tor versions for client
+ usage, in ascending order. The versions are given as defined by
+ version-spec.txt. If absent, no opinion is held about client
versions.
"server-versions" SP VersionList NL
[At most once.]
- A comma-separated list of recommended server versions, in
- ascending order. If absent, no opinion is held about server
+ A comma-separated list of recommended Tor versions for server
+ usage, in ascending order. The versions are given as defined by
+ version-spec.txt. If absent, no opinion is held about server
versions.
"known-flags" SP FlagList NL
1
0

[torbutton/master] Move JS hooks to new JS1.8.5 hooking support.
by mikeperry@torproject.org 17 Apr '11
by mikeperry@torproject.org 17 Apr '11
17 Apr '11
commit a090ed22b28dd460661f97529378a73aa97009f7
Author: Mike Perry <mikeperry-git(a)fscked.org>
Date: Fri Apr 15 00:51:04 2011 -0700
Move JS hooks to new JS1.8.5 hooking support.
The new JS1.8.5 hooking method appear more stable than the old ways, but
they're not perfect...
---
src/chrome/content/jshooks4.js | 264 +++++++++++++++++++++++++++++++++++++++
src/chrome/content/torbutton.js | 9 ++-
2 files changed, 272 insertions(+), 1 deletions(-)
diff --git a/src/chrome/content/jshooks4.js b/src/chrome/content/jshooks4.js
new file mode 100644
index 0000000..60a4e1c
--- /dev/null
+++ b/src/chrome/content/jshooks4.js
@@ -0,0 +1,264 @@
+window.__HookObjects = function() {
+ if (typeof(window.__tb_hooks_ran) === "boolean") {
+ return false;
+ }
+
+ // No pref for this.. Should be mostly harmless..
+ if(true) {
+ // Wrap in anonymous function to protect scr variables just in case.
+ (function () {
+ var origHeight = window.innerHeight;
+ var origWidth = window.innerWidth;
+
+ Object.defineProperty(window.__proto__, "innerWidth",
+ {get: function() { return Math.round(origWidth/50.0)*50;},
+ configurable: false});
+ Object.defineProperty(window.__proto__, "innerHeight",
+ {get: function() { return Math.round(origHeight/50.0)*50;},
+ configurable: false});
+ Object.defineProperty(window.__proto__, "outerWidth",
+ {get: function() { return Math.round(origWidth/50.0)*50;},
+ configurable: false});
+ Object.defineProperty(window.__proto__, "outerHeight",
+ {get: function() { return Math.round(origHeight/50.0)*50;},
+ configurable: false});
+ Object.defineProperty(window.__proto__, "screenX",
+ {get: function() { return 0;},
+ configurable: false});
+ Object.defineProperty(window.__proto__, "screenY",
+ {get: function() { return 0;},
+ configurable: false});
+ Object.defineProperty(window.__proto__, "pageXOffset",
+ {get: function() { return 0;},
+ configurable: false});
+ Object.defineProperty(window.__proto__, "pageYOffset",
+ {get: function() { return 0;},
+ configurable: false});
+
+ // We can't define individual getters/setters for window.screen
+ // for some reason. works in html but not in these hooks.. No idea why
+
+ var scr = new Object();
+ var origScr = window.screen;
+ scr.__defineGetter__("height", function() { return window.innerHeight; });
+ scr.__defineGetter__("width", function() { return window.innerWidth; });
+
+ scr.__defineGetter__("availTop", function() { return 0;});
+ scr.__defineGetter__("availLeft", function() { return 0;});
+
+ scr.__defineGetter__("top", function() { return 0;});
+ scr.__defineGetter__("left", function() { return 0;});
+
+ scr.__defineGetter__("availHeight", function() { return window.innerHeight;});
+ scr.__defineGetter__("availWidth", function() { return window.innerWidth;});
+
+ scr.__defineGetter__("colorDepth", function() { return origScr.colorDepth;});
+ scr.__defineGetter__("pixelDepth", function() { return origScr.pixelDepth;});
+
+ scr.__defineGetter__("availTop", function() { return 0;});
+ scr.__defineGetter__("availLeft", function() { return 0;});
+
+ Object.defineProperty(window.__proto__, "screen",
+ {get: function() { return scr;},
+ configurable: false});
+
+ })();
+
+ }
+
+ if(window.__tb_hook_date == true) { // don't feel like indenting this
+ // XXX: events should not have timeStamp, unless they are of type MozBeforePaint?
+
+ /* Timezone fix for http://gemal.dk/browserspy/css.html */
+ var reparseDate = function(d, str) {
+ /* Rules:
+ * - If they specify a timezone, it is converted to local
+ * time. All getter fucntions then convert properly to
+ * UTC. No mod needed.
+ * - If they specify UTC timezone, then it is converted
+ * to local time. All getter functions then convert back.
+ * No mod needed.
+ * - If they specify NO timezone, it is local time.
+ * The UTC conversion then reveals the offset. Fix.
+ */
+
+ /* Step 1: Remove everything inside ()'s (they are "comments") */
+ var s = str.toLowerCase();
+ var re = new RegExp('\\(.*\\)', "gm");
+ s = s.replace(re, "");
+
+ /* Step 2: Look for +/-. If found, do nothing */
+ if(s.indexOf("+") == -1 && s.indexOf("-") == -1) {
+ /* Step 3: Look for timezone string from
+ * http://lxr.mozilla.org/seamonkey/source/js/src/jsdate.c
+ */
+ if(s.indexOf(" gmt") == -1 && s.indexOf(" ut") == -1 &&
+ s.indexOf(" est") == -1 && s.indexOf(" edt") == -1 &&
+ s.indexOf(" cst") == -1 && s.indexOf(" cdt") == -1 &&
+ s.indexOf(" mst") == -1 && s.indexOf(" mdt") == -1 &&
+ s.indexOf(" pst") == -1 && s.indexOf(" pdt")) {
+ /* No timezone specified. Adjust. */
+ d.setTime(d.getTime()-(d.getTimezoneOffset()*60000));
+ }
+ }
+ }
+
+ // XXX: Each origin should have its own unique offset from the real date
+ // XXX: Subsequent calls to the ms timer should be monotonically increasing, but randomized
+
+ var origDate = window.Date;
+ var newDate = function() {
+ /* DO NOT make 'd' a member! EvilCode will use it! */
+ var d;
+ var a = arguments;
+ /* apply doesn't seem to work for constructors :( */
+ if(arguments.length == 0) d=new origDate();
+ if(arguments.length == 1) d=new origDate(a[0]);
+ if(arguments.length == 3) d=new origDate(a[0],a[1],a[2]);
+ if(arguments.length == 4) d=new origDate(a[0],a[1],a[2],a[3]);
+ if(arguments.length == 5) d=new origDate(a[0],a[1],a[2],a[3],a[4]);
+ if(arguments.length == 6) d=new origDate(a[0],a[1],a[2],a[3],a[4],a[5]);
+ if(arguments.length == 7) d=new origDate(a[0],a[1],a[2],a[3],a[4],a[5],a[6]);
+ if(arguments.length > 7) d=new origDate();
+
+ if(arguments.length > 0) {
+ if((arguments.length == 1) && typeof(a[0]) == "string") {
+ reparseDate(d,a[0]);
+ } else if(arguments.length > 1) {
+ /* Numerical value. No timezone given, adjust. */
+ d.setTime(d.getTime()-(d.getTimezoneOffset()*60000));
+ }
+ }
+
+ // XXX: the native valueOf seems to sometimes return toString and
+ // sometimes return getTime depending on context (which we can't detect)
+ // It seems as though we can't win here..
+ window.Date.prototype.valueOf=function(){return d.getTime()};
+ window.Date.prototype.getTime=function(){return d.getTime();} /* UTC already */
+ window.Date.prototype.getFullYear=function(){return d.getUTCFullYear();}
+ window.Date.prototype.getYear=function() {return d.getYear();}
+ window.Date.prototype.getMonth=function(){return d.getUTCMonth();}
+ window.Date.prototype.getDate=function() {return d.getUTCDate();}
+ window.Date.prototype.getDay=function() {return d.getUTCDay();}
+ window.Date.prototype.getHours=function(){return d.getUTCHours();}
+ window.Date.prototype.getMinutes=function(){return d.getUTCMinutes();}
+ window.Date.prototype.getSeconds=function(){return d.getUTCSeconds();}
+ window.Date.prototype.getMilliseconds=function(){return d.getUTCMilliseconds();}
+ window.Date.prototype.getTimezoneOffset=function(){return 0;}
+
+ window.Date.prototype.setTime =
+ function(x) {return d.setTime(x);}
+ window.Date.prototype.setFullYear=function(x){return d.setUTCFullYear(x);}
+ window.Date.prototype.setYear=function(x){return d.setYear(x);}
+ window.Date.prototype.setMonth=function(x){return d.setUTCMonth(x);}
+ window.Date.prototype.setDate=function(x){return d.setUTCDate(x);}
+ window.Date.prototype.setDay=function(x){return d.setUTCDay(x);}
+ window.Date.prototype.setHours=function(x){return d.setUTCHours(x);}
+ window.Date.prototype.setMinutes=function(x){return d.setUTCMinutes(x);}
+ window.Date.prototype.setSeconds=function(x){return d.setUTCSeconds(x);}
+ window.Date.prototype.setMilliseconds=
+ function(x) {return d.setUTCMilliseconds(x);}
+
+ window.Date.prototype.getUTCFullYear=function(){return d.getUTCFullYear();}
+ window.Date.prototype.getUTCMonth=function(){return d.getUTCMonth();}
+ window.Date.prototype.getUTCDate=function() {return d.getUTCDate();}
+ window.Date.prototype.getUTCDay=function() {return d.getUTCDay();}
+ window.Date.prototype.getUTCHours=function(){return d.getUTCHours();}
+ window.Date.prototype.getUTCMinutes=function(){return d.getUTCMinutes();}
+ window.Date.prototype.getUTCSeconds=function(){return d.getUTCSeconds();}
+ window.Date.prototype.getUTCMilliseconds=
+ function(){return d.getUTCMilliseconds();}
+
+ window.Date.prototype.setUTCFullYear=function(x){return d.setUTCFullYear(x);}
+ window.Date.prototype.setUTCMonth=function(x){return d.setUTCMonth(x);}
+ window.Date.prototype.setUTCDate=function(x){return d.setUTCDate(x);}
+ window.Date.prototype.setUTCDay=function(x){return d.setUTCDay(x);}
+ window.Date.prototype.setUTCHours=function(x){return d.setUTCHours(x);}
+ window.Date.prototype.setUTCMinutes=function(x){return d.setUTCMinutes(x);}
+ window.Date.prototype.setUTCSeconds=function(x){return d.setUTCSeconds(x);}
+ window.Date.prototype.setUTCMilliseconds=
+ function(x) {return d.setUTCMilliseconds(x);}
+
+ window.Date.prototype.toUTCString=function(){return d.toUTCString();}
+ window.Date.prototype.toGMTString=function(){return d.toGMTString();}
+ window.Date.prototype.toString=function(){return d.toUTCString();}
+ window.Date.prototype.toLocaleString=function(){return d.toUTCString();}
+
+ /* Fuck 'em if they can't take a joke: */
+ window.Date.prototype.toLocaleTimeString=function(){return d.toUTCString();}
+ window.Date.prototype.toLocaleDateString=function(){return d.toUTCString();}
+ window.Date.prototype.toDateString=function(){return d.toUTCString();}
+ window.Date.prototype.toTimeString=function(){return d.toUTCString();}
+
+ /* Hack to solve the problem of multiple date objects
+ * all sharing the same lexically scoped d every time a new one is
+ * created. This hack creates a fresh new prototype reference for
+ * the next object to use with a different d binding.
+ * It doesn't break stuff because at the start of this function,
+ * the interpreter grabbed a reference to Date.prototype. During
+ * this function we modified Date.prototype to create the new methods
+ * with the lexically scoped d reference.
+ */
+
+ // valueOf gets called for implicit string conversion??
+ window.Date.prototype = window.eval(window.Object.prototype.toSource());
+ return d.toUTCString();
+ }
+
+ // Need to do this madness so that we use the window's notion of Function
+ // for the constructor. If this is not done, then changes to Function
+ // and Object in the real window are not propogated to Date (for example,
+ // to extend the Date class with extra functions via a generic inheritance
+ // framework added onto Object - this is done by livejournal and others)
+ var newWrappedDate = window.eval("function() { return newDate(); }");
+
+ newWrappedDate.parse=function(s) {
+ var d = new origDate(s);
+ if(typeof(s) == "string") reparseDate(d, s);
+ return d.getTime();
+ }
+
+ newWrappedDate.now=function(){return origDate.now();}
+ newWrappedDate.UTC=function(){return origDate.apply(origDate, arguments); }
+
+ // d = new Date();
+ // d.__proto__ === Date.prototype
+ // d.constructor === Date
+ // d.__proto__ === d.constructor.prototype
+ // Date.prototype.__proto__ === Date.prototype.constructor.prototype
+ // window.__proto__ === Window.prototypea
+
+ Object.defineProperty(window.__proto__, "Date",
+ {get: function() { return newWrappedDate;},
+ configurable: false});
+
+ } // window.__tb_hook_date == true
+
+ //Object.defineProperty(window.Components.__proto__, "lookupMethod",
+ // {get: function() { return function (a,b) { return function() { return a[b]; }; };},
+ // configurable: false});
+
+ return true;
+}
+
+if (typeof(window.__HookObjects) != "undefined") {
+ var res = 23;
+
+ if(!window.__HookObjects()) {
+ res = 13;
+ }
+
+ window.__HookObjects = undefined;
+ delete window['__HookObjects'];
+ delete window['__CheckFlag'];
+ delete window['__tb_set_uagent'];
+ delete window['__tb_oscpu'];
+ delete window['__tb_platform'];
+ delete window['__tb_productSub'];
+
+ window.__tb_hooks_ran = true;
+
+ res; // Secret result code.
+} else {
+ 42;
+}
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 676c311..9f5c5fe 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -3431,6 +3431,7 @@ function torbutton_do_startup()
}
var tor_enabled = torbutton_check_status();
+ // XXX: There is a timer at startup. this is not enough..
if(m_tb_ff35 &&
m_tb_prefs.getBoolPref("extensions.torbutton.disable_livemarks")) {
var livemarks = Cc["@mozilla.org/browser/livemark-service;2"].
@@ -3668,8 +3669,14 @@ function torbutton_init_jshooks() {
torbutton_log(2, "torbutton_init_jshooks()");
var nsio = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
- var chan = nsio.newChannel("chrome://torbutton/content/jshooks.js",
+ var chan = null;
+ if (m_tb_ff4) {
+ chan = nsio.newChannel("chrome://torbutton/content/jshooks4.js",
null, null);
+ } else {
+ chan = nsio.newChannel("chrome://torbutton/content/jshooks.js",
+ null, null);
+ }
var istream = Components.classes["@mozilla.org/scriptableinputstream;1"].
createInstance(Components.interfaces.nsIScriptableInputStream);
1
0

16 Apr '11
commit a8219b9406daa19b97ceb7e9975365659c805cc3
Merge: 0f11e4f 71609c1
Author: Roger Dingledine <arma(a)torproject.org>
Date: Sat Apr 16 19:22:03 2011 -0400
Merge remote-tracking branch 'asn/gitorious'
proposals/180-pluggable-transport.txt | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
1
0

16 Apr '11
commit 71609c11e48086a341e9248b7bc8cd30bd08878b
Author: George Kadianakis <desnacked(a)gmail.com>
Date: Tue Apr 12 22:02:57 2011 +0200
Cleared up example. Fixed two small errors.
---
proposals/180-pluggable-transport.txt | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/proposals/180-pluggable-transport.txt b/proposals/180-pluggable-transport.txt
index 5e9e5b1..f51a9ff 100644
--- a/proposals/180-pluggable-transport.txt
+++ b/proposals/180-pluggable-transport.txt
@@ -145,7 +145,7 @@ Specifications: Client behavior
bridge method address:port [[keyid=]id-fingerprint] [k=v] [k=v] [k=v]
To connect to such a bridge, the Tor program needs to know which
- local SOCKS proxy will support the transport called "method". It
+ SOCKS proxy will support the transport called "method". It
then connects to this proxy, and asks it to connect to
address:port. If [id-fingerprint] is provided, Tor should expect
the public identity key on the TLS connection to match the digest
@@ -156,8 +156,7 @@ Specifications: Client behavior
as necessary. If a key or value value must contain a semicolon or
a backslash, it is escaped with a backslash.
- The "id-fingerprint" field is always provided in a field named
- "keyid", if it was given. Method names must be C identifiers.
+ Method names must be C identifiers.
For reference, the old bridge format was
bridge address[:port] [id-fingerprint]
@@ -168,11 +167,11 @@ Specifications: Client behavior
optionally include whitespace in the old format, whitespace in the
id-fingerprint is not permitted in the new format.
- Example: if the bridge line is "bridge trebuchet www.example.com:3333
- rocks=20 height=5.6m" AND if the Tor client knows that the
- 'trebuchet' method is provided by a SOCKS5 proxy on
- 127.0.0.1:19999, the client should connect to that proxy, ask it to
- connect to www.example.com, and provide the string
+ Example: if the bridge line is "bridge trebuchet www.example.com:3333
+ keyid=09F911029D74E35BD84156C5635688C009F909F9 rocks=20 height=5.6m"
+ AND if the Tor client knows that the 'trebuchet' method is supported,
+ the client should connect to the proxy that provides the 'trebuchet'
+ method, ask it to connect to www.example.com, and provide the string
"rocks=20;height=5.6m" as the username, the password, or split
across the username and password.
1
0

16 Apr '11
Author: runa
Date: 2011-04-16 20:56:02 +0000 (Sat, 16 Apr 2011)
New Revision: 24643
Removed:
website/trunk/getinvolved/pl_PL/
Log:
Delete pl_PL/ because we have pl/
1
0

r24642: {} Delete pl_PL/ because we already have pl/ (website/trunk/projects)
by Runa Sandvik 16 Apr '11
by Runa Sandvik 16 Apr '11
16 Apr '11
Author: runa
Date: 2011-04-16 20:55:15 +0000 (Sat, 16 Apr 2011)
New Revision: 24642
Removed:
website/trunk/projects/pl_PL/
Log:
Delete pl_PL/ because we already have pl/
1
0