multiple updates related to pending 0.0.8 including fixes for trac #1388 #1509 #1530 #1513 #1333

svn:r22666
This commit is contained in:
Nathan Freitas 2010-07-19 22:34:15 +00:00
parent ca2123f780
commit 200c6ec236
28 changed files with 568 additions and 143 deletions

View File

@ -3,7 +3,7 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry combineaccessrules="false" kind="src" path="/jtorctrl"/>
<classpathentry kind="lib" path="libs/asocks.jar"/>
<classpathentry kind="lib" path="libs/jtorctrl.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -4,11 +4,11 @@
android:versionName="0.2.2.13-orbot-alpha-0.0.8" android:versionCode="2">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- <uses-permission android:name="android.permission.WRITE_SETTINGS" /> -->
<!-- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> -->
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="false">
<activity android:name=".Orbot"
android:theme="@android:style/Theme.NoTitleBar"
>
@ -22,9 +22,9 @@
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
<activity android:name=".SettingsPreferences" android:label="@string/app_name">
</activity>
<activity android:name=".SettingsPreferences" android:label="@string/app_name"/>
<activity android:name=".AppManager" android:label="@string/app_name"/>
<service android:name=".service.TorService" android:process=":remote" android:debuggable="false">
<intent-filter>
@ -33,8 +33,17 @@
</intent-filter>
</service>
<receiver android:name=".OnBootReceiver">
<intent-filter>
<action
android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
</application>
<uses-sdk android:minSdkVersion="3"/>

View File

@ -1,4 +1,4 @@
This document explains how to properly build an Android package of Orbot from
nThis document explains how to properly build an Android package of Orbot from
source. It covers building on Debian Lenny (5.0.3).
Please install the following prerequisites (instructions for each follows):

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="Orbot" default="help">
<project name="Orbot">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked in in Version

View File

@ -10,5 +10,5 @@
# Indicates whether an apk should be generated for each density.
split.density=false
# Project target.
target=android-2
target=android-8
apk-configurations=

View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bgtitanium">
<RelativeLayout android:id="@+id/layoutHeaderMain"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_gravity="center_horizontal"
android:background="#A0909090">
<ImageView android:id="@+id/radioModeImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3px"
android:layout_marginRight="3px"
android:gravity="right"
android:layout_toRightOf="@+id/radioModeLabel"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/tor25"
/>
<TextView android:id="@+id/radioModeText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="powered by The Tor Project "
android:layout_marginTop="8px"
android:layout_marginRight="0px"
android:gravity="right"
android:layout_toLeftOf="@+id/radioModeImage"
android:textColor="#cccccc" />
</RelativeLayout>
<ScrollView android:id="@+id/mainview"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout android:id="@+id/mainLayout"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<TableRow android:id="@+id/startRow">
<TableLayout
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<TableRow>
<ImageView
android:id="@+id/imgStatus"
android:layout_width="wrap_content"
android:layout_height="175px"
android:src="@drawable/toroff"/>
</TableRow>
<TableRow>
<TextView android:id="@+id/lblStatus"
android:text="- Press to enable - "
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:textStyle="bold"
android:width="240px"
android:height="50px"
android:textColor="#ffffff"
/>
</TableRow>
</TableLayout>
</TableRow>
</TableLayout>
</ScrollView>
</LinearLayout>

View File

@ -18,7 +18,7 @@
android:paddingLeft="15px"
android:textStyle="bold"
android:textColor="#ffffff" />
<TextView android:text="- Unkown -"
<TextView android:text="- Unknown -"
android:id="@+id/versionName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
@ -32,14 +32,12 @@
android:paddingLeft="15px"
android:textStyle="bold"
android:textColor="#ffffff" />
<TextView android:text="https://www.torproject.org/docs/android \n
http://guardianproject.info/apps/orbot/"
<TextView android:text="https://www.torproject.org/docs/android\nhttps://guardianproject.info/apps/orbot/"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:textColorLink="#ffffff"
android:paddingLeft="15px"
android:textSize="12sp"
android:textColor="#ffffff" />
<TextView android:text="License: "
android:layout_width="fill_parent"
@ -59,7 +57,6 @@ http://guardianproject.info/apps/orbot/"
android:autoLink="web"
android:textColorLink="#ffffff"
android:paddingLeft="15px"
android:textSize="12sp"
android:textColor="#ffffff" />
<TextView android:text="3rd-Party-Software: "
android:layout_width="fill_parent"
@ -74,7 +71,6 @@ http://guardianproject.info/apps/orbot/"
android:autoLink="web"
android:textColorLink="#ffffff"
android:paddingLeft="15px"
android:textSize="12sp"
android:textColor="#ffffff" />
<TextView android:text="LibEvent v1.4.13: http://www.monkey.org/~provos/libevent/"
android:layout_width="fill_parent"
@ -82,7 +78,6 @@ http://guardianproject.info/apps/orbot/"
android:autoLink="web"
android:textColorLink="#ffffff"
android:paddingLeft="15px"
android:textSize="12sp"
android:textColor="#ffffff" />
</LinearLayout>

View File

@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:duplicateParentState="false">
<TextView android:text="Check the apps you wish to route through Tor:"
<TextView android:text="Select apps for Tor:"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:textColor="#00ff00"
android:padding="3px" />
<ListView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/applistview"></ListView>
</LinearLayout>

View File

@ -4,9 +4,11 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/itemcheck"></CheckBox>
<TextView android:layout_height="wrap_content" android:id="@+id/itemtext" android:text="uid:packages" android:layout_width="fill_parent"
android:textSize="18sp"
></TextView>
<ImageView android:id="@+id/itemicon" android:layout_width="48px" android:layout_height="48px"></ImageView>
<TextView android:layout_height="wrap_content" android:id="@+id/itemtext" android:text="uid:packages" android:layout_width="wrap_content"
android:textSize="18sp"></TextView>
</LinearLayout>

View File

@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:layout_height="wrap_content">
<ScrollView android:id="@+id/helpscrollview"
android:orientation="vertical"
android:layout_width="fill_parent"
@ -14,8 +14,6 @@
<TextView android:text=""
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="5px"
android:paddingLeft="5px"
android:textColor="#ffffff" />
</LinearLayout>
</ScrollView>

View File

@ -1,19 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:orientation="vertical"
android:layout_height="480px"
android:layout_height="fill_parent"
android:layout_width="fill_parent" android:id="@+id/logScrollView"
xmlns:android="http://schemas.android.com/apk/res/android"
>
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:id="@+id/messageLog"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_x="2px"
android:layout_y="2px"
android:layout_y="2px"
android:textSize="12px"
/>
</ScrollView>

View File

@ -3,7 +3,7 @@
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background">
android:background="@drawable/bgtitanium">
<RelativeLayout android:id="@+id/layoutHeaderMain"
android:layout_width="fill_parent"
@ -13,7 +13,7 @@
<ImageView android:id="@+id/radioModeImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3px"
android:layout_marginTop="0px"
android:layout_marginRight="3px"
android:gravity="right"
android:layout_toRightOf="@+id/radioModeLabel"
@ -24,12 +24,12 @@
<TextView android:id="@+id/radioModeText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="powered by The Tor Project "
android:layout_marginTop="8px"
android:text="@string/powered_by"
android:layout_marginTop="9px"
android:layout_marginRight="0px"
android:gravity="right"
android:layout_toLeftOf="@+id/radioModeImage"
android:textColor="#cccccc" />
android:textColor="#333333" />
</RelativeLayout>
<ScrollView android:id="@+id/mainview"
@ -54,7 +54,7 @@
</TableRow>
<TableRow>
<TextView android:id="@+id/lblStatus"
android:text="- Press to enable - "
android:text="@string/press_to_start"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:textStyle="bold"

View File

@ -45,4 +45,7 @@
<string name="help_text_5">Auf gerooteten Geräten (egal ob Android 1.x oder 2x) kann Orbot sämtliche Apps und alle DNS-Abfragen anonymisieren. Dies gilt auch für den eingebauten Browser, Gmail, YouTube und Maps, sowie jegliche Anwendung von Drittanbietern.</string>
<string name="menu_verify">Check</string>
<string name="menu_exit">Exit</string>
</resources>

View File

@ -49,4 +49,7 @@ para configurar el proxy SOCKS5 a 127.0.0.1 y el puerto 9050. También debe habi
<string name="help_text_5">Si la raíz del dispositivo, ya sea 1.xo 2.x base, puede proxy transparente Orbot cualquier applicatons selecciona y todas las peticiones DNS.
Esto incluye el built-in del navegador, Gmail, YouTube y mapas, así como cualquier aplicación de terceros.</string>
<string name="menu_verify">Check</string>
<string name="menu_exit">Exit</string>
</resources>

View File

@ -47,4 +47,7 @@ HTTP Proxy til 127.0.0.1 og port 8118 for kun HTTP trafikk (HTTP/S vil ikke fung
<string name="help_text_5">Hvis du rooter telefonen, uansett om den er en 1.x eller 2.x enhet, så vil Orbot kunne fungere med alle aplikasjoner du velger, i tillegg til alle DNS-forespørsler. Dette inkluderer den innebyggede nettleseren, Gmail, Youtube og Kart, og mange tredjeparts-applikasjoner.</string>
<string name="menu_verify">Check</string>
<string name="menu_exit">Exit</string>
</resources>

View File

@ -49,4 +49,7 @@ dat je de SOCKS5 proxy op 127.0.0.1 poort 9050 zet. Zet ook SSL aan om je gebrui
<string name="help_text_5">Als je je apparaat root, of het een 1.x of een 2.x gebaseerde versie is, Orbot kan transparant elke applicatie proxien die je selecteert
en ook alle DNS aanvragen. Dit omvat ook de ingebouwde browser, Gmail, Youtube en Maps, naast elke andere applicatie van derde partijen.</string>
<string name="menu_verify">Check</string>
<string name="menu_exit">Exit</string>
</resources>

View File

@ -49,4 +49,7 @@ you to set the SOCKS5 proxy to 127.0.0.1 and port 9050. You should also enable S
<string name="help_text_5">If you root your device, whether it is 1.x or 2.x based, Orbot can transparently proxy any applicatons you select
and all DNS requests. This includes the built-in Browser, Gmail, YouTube and Maps, as well as any third-party app.</string>
<string name="menu_verify">Check</string>
<string name="menu_exit">Exit</string>
</resources>

View File

@ -49,4 +49,7 @@ que o permite definir o Proxy para 127.0.0.1 e porto 9050. Deve também activar
<string name="help_text_5">Se tiver acesso root no seu dispositivo, quer seja 1.x ou 2.x, o Orbot pode, de uma forma transparente, funcionar com todas as aplicações
e pedidos de DNS. Isto inclui o navegador. Gmail, YouTube e Maps, como também aplicações de terceiros.</string>
<string name="menu_verify">Check</string>
<string name="menu_exit">Exit</string>
</resources>

View File

@ -30,7 +30,6 @@
<string name="menu_stop">Stop</string>
<string name="button_help">Help</string>
<string name="button_close">Close</string>
<string name="button_about">About</string>
@ -49,4 +48,8 @@ you to set the SOCKS5 proxy to 127.0.0.1 and port 9050. You should also enable S
<string name="help_text_5">If you root your device, whether it is 1.x or 2.x based, Orbot can transparently proxy any applicatons you select
and all DNS requests. This includes the built-in Browser, Gmail, YouTube and Maps, as well as any third-party app.</string>
<string name="menu_verify">Check</string>
<string name="menu_exit">Exit</string>
<string name="powered_by">powered by the Tor Project</string>
<string name="press_to_start">- press to start -</string>
</resources>

View File

@ -0,0 +1,76 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="Transparent Proxying">
<CheckBoxPreference
android:defaultValue="false"
android:key="pref_transparent"
android:title="Transparent Proxying"
android:summary="Root Devices Only: Per App Torification"
android:enabled="true"/>
</PreferenceCategory>
<PreferenceCategory android:title="Bridges">
<CheckBoxPreference android:defaultValue="false"
android:title="Use Bridges" android:key="pref_bridges_enabled"
android:summary="Enable alternate entrance nodes into the Tor Network"></CheckBoxPreference>
<!-- 5/8/2010 NF: Arma says this doesn't actually work, so commenting out for now
<CheckBoxPreference android:defaultValue="false"
android:title="Update from Authority" android:key="pref_bridges_update"
android:summary="Modify bridge list automatically"></CheckBoxPreference>
-->
<EditTextPreference android:key="pref_bridges_list"
android:title="Bridges"
android:summary="IP address and port of bridges"
android:dialogTitle="Enter Bridge Addresses"
/>
</PreferenceCategory>
<PreferenceCategory android:title="Relays">
<CheckBoxPreference android:key="pref_or"
android:defaultValue="false"
android:title="Relaying"
android:summary="Enable your device to be a non-exit relay"
android:enabled="true"
/>
<EditTextPreference android:key="pref_or_port"
android:defaultValue="9001"
android:title="Relay Port"
android:summary="Listening port for your Tor relay"
android:dialogTitle="Enter OR port"
/>
<EditTextPreference android:key="pref_or_nickname"
android:defaultValue="Orbot"
android:title="Relay nickname"
android:summary="The nickname for your Tor relay"
android:dialogTitle="Enter a custom relay nickname"
/>
</PreferenceCategory>
<PreferenceCategory android:title="ReachableAddresses">
<CheckBoxPreference
android:key="pref_reachable_addresses"
android:defaultValue="false"
android:title="ReachableAddresses"
android:summary="Run as a client behind a firewall with restrictive policies"
android:enabled="true"></CheckBoxPreference>
<EditTextPreference
android:key="pref_reachable_addresses_ports"
android:defaultValue="*:80,*:443"
android:title="Reachable ports"
android:summary="Ports reachable behind a restrictive firewall"
android:dialogTitle="Enter ports"
/>
</PreferenceCategory>
</PreferenceScreen>

View File

@ -1,14 +1,30 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="Transparent Proxying">
<PreferenceCategory android:title="Transparent Proxying (Requires Root)">
<CheckBoxPreference
android:defaultValue="false"
android:key="pref_transparent"
android:title="Transparent Proxying"
android:summary="Root Devices Only: Per App Torification"
android:summary="Auto-Tor Proxying"
android:enabled="true"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="pref_transparent_all"
android:title="Auto-Proxy All Apps"
android:summary="Route All Traffic Through Tor"
android:enabled="true"/>
<Preference
android:defaultValue=""
android:key="pref_transparent_app_list"
android:title="Select Apps"
android:summary="Choose Apps to Route Through Tor"
android:enabled="true"/>
</PreferenceCategory>
<PreferenceCategory android:title="Bridges">

View File

@ -15,6 +15,7 @@ import org.torproject.android.service.TorServiceConstants;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.NotificationManager;
import android.app.ProgressDialog;
import android.content.ComponentName;
import android.content.Context;
@ -87,30 +88,24 @@ public class Orbot extends Activity implements OnClickListener, TorConstants, On
MenuItem mItem = null;
mItemOnOff = menu.add(0, 1, Menu.NONE, getString(R.string.menu_start));
mItemOnOff.setIcon(android.R.drawable.ic_menu_share);
mItemOnOff.setAlphabeticShortcut('t');
mItem = menu.add(0, 4, Menu.NONE, getString(R.string.menu_settings));
mItem.setIcon(R.drawable.ic_menu_register);
mItem = menu.add(0, 5, Menu.NONE, getString(R.string.menu_apps));
mItem = menu.add(0, 7, Menu.NONE, getString(R.string.menu_verify));
mItem.setIcon(R.drawable.ic_menu_goto);
if (!TorServiceUtils.hasRoot())
{
mItem.setEnabled(false);
}
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.setIcon(R.drawable.ic_menu_about);
mItem = menu.add(0, 8, Menu.NONE, getString(R.string.menu_exit));
mItem.setIcon(R.drawable.ic_menu_exit);
return true;
}
@ -172,10 +167,41 @@ public class Orbot extends Activity implements OnClickListener, TorConstants, On
{
showApps();
}
else if (item.getItemId() == 7)
{
//launch check.torproject.org
openBrowser(URL_TOR_CHECK);
}
else if (item.getItemId() == 8)
{
//exit app
doExit();
}
return true;
}
private void doExit ()
{
try {
stopTor();
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.cancelAll();
unbindService();
} catch (RemoteException e) {
Log.w(TAG, e);
}
finish();
}
/* Return to the main view when the back key is pressed
* (non-Javadoc)
* @see android.app.Activity#onKeyDown(int, android.view.KeyEvent)
@ -231,6 +257,10 @@ public class Orbot extends Activity implements OnClickListener, TorConstants, On
protected void onResume() {
super.onResume();
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.cancelAll();
updateStatus (""); //update the status, which checks the service status
if (showingSettings)
@ -352,6 +382,8 @@ public class Orbot extends Activity implements OnClickListener, TorConstants, On
entry = (ListEntry) convertView.getTag();
}
final TorifiedApp app = apps[position];
entry.text.setText(app.getName());
final CheckBox box = entry.box;
box.setTag(app);
@ -432,7 +464,6 @@ public class Orbot extends Activity implements OnClickListener, TorConstants, On
new AlertDialog.Builder(this)
.setTitle(getString(R.string.menu_info))
.setMessage(msg.toString())
.setView(view)
.setNeutralButton(getString(R.string.button_about), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
@ -466,6 +497,8 @@ public class Orbot extends Activity implements OnClickListener, TorConstants, On
setContentView(currentView);
txtMessageLog = (TextView)findViewById(R.id.messageLog);
txtMessageLog.setClickable(true);
txtMessageLog.setText(logBuffer.toString());
}
@ -633,6 +666,12 @@ public class Orbot extends Activity implements OnClickListener, TorConstants, On
if (mService != null)
torStatus = mService.getStatus();
if (this.currentView == R.layout.layout_log)
{
txtMessageLog.append(torServiceMsg);
txtMessageLog.append("\n");
}
if (imgStatus != null)
{
@ -755,6 +794,7 @@ public class Orbot extends Activity implements OnClickListener, TorConstants, On
mHandler.sendMessage(msg);
updateStatus("");
}
/*
@ -857,6 +897,8 @@ public class Orbot extends Activity implements OnClickListener, TorConstants, On
logBuffer.append(torServiceMsg);
logBuffer.append('\n');
if (torServiceMsg.length() > 0 && torServiceMsg.charAt(0)!='>')
updateStatus(torServiceMsg);
break;

View File

@ -5,20 +5,52 @@ package org.torproject.android;
import org.torproject.android.service.TorServiceUtils;
import android.content.Intent;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;
import android.util.Log;
import android.preference.PreferenceCategory;
public class SettingsPreferences
extends PreferenceActivity {
extends PreferenceActivity implements OnPreferenceClickListener {
private CheckBoxPreference prefCBTransProxy = null;
private CheckBoxPreference prefcBTransProxyAll = null;
private Preference prefTransProxyApps = null;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
if (!TorServiceUtils.hasRoot())
{
getPreferenceScreen().getPreference(0).setEnabled(false);
}
else
{
prefCBTransProxy = ((CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(0)).getPreference(0));
prefcBTransProxyAll = (CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(0)).getPreference(1);
prefTransProxyApps = ((PreferenceCategory)this.getPreferenceScreen().getPreference(0)).getPreference(2);
prefcBTransProxyAll.setEnabled(prefCBTransProxy.isChecked());
prefTransProxyApps.setEnabled(prefCBTransProxy.isChecked() && (!prefcBTransProxyAll.isChecked()));
prefCBTransProxy.setOnPreferenceClickListener(this);
prefcBTransProxyAll.setOnPreferenceClickListener(this);
prefTransProxyApps.setOnPreferenceClickListener(this);
}
}
/* (non-Javadoc)
* @see android.app.Activity#onStop()
@ -27,7 +59,27 @@ public class SettingsPreferences
protected void onStop() {
super.onStop();
Log.i(getClass().getName(),"Exiting Preferences");
//Log.i(getClass().getName(),"Exiting Preferences");
}
@Override
public boolean onPreferenceClick(Preference preference) {
if (preference == prefTransProxyApps)
{
startActivity(new Intent(this, AppManager.class));
}
else
{
prefcBTransProxyAll.setEnabled(prefCBTransProxy.isChecked());
prefTransProxyApps.setEnabled(prefCBTransProxy.isChecked() && (!prefcBTransProxyAll.isChecked()));
}
return true;
}
}

View File

@ -24,7 +24,7 @@ public interface TorConstants {
public final static String NEWLINE = "\n";
public final static String TORRC_DEFAULT =
"SocksPort 9050\nSocksListenAddress 127.0.0.1\nSafeSocks 1\nDNSPort 5400\nLog debug syslog\nDataDirectory /data/data/org.torproject.android/data\n"
"SocksPort 9050\nSocksListenAddress 127.0.0.1\nSafeSocks 1\nDNSPort 5400\nLog debug syslog\nDataDirectory /data/data/org.torproject.android/cache\n"
+ "ControlPort 9051\nCookieAuthentication 1\nRelayBandwidthRate 20 KBytes\nRelayBandwidthBurst 20 KBytes\nAutomapHostsOnResolve 1\nTransPort 9040\n";
public final static String INTENT_TOR_SERVICE = "org.torproject.android.service.TOR_SERVICE";

View File

@ -1,5 +1,7 @@
package org.torproject.android;
import android.graphics.drawable.Drawable;
public class TorifiedApp {
private boolean enabled;
@ -7,6 +9,7 @@ public class TorifiedApp {
private String username;
private String procname;
private String name;
private Drawable icon;
private boolean torified = false;
@ -97,4 +100,12 @@ public class TorifiedApp {
this.name = name;
}
public Drawable getIcon() {
return icon;
}
public void setIcon(Drawable icon) {
this.icon = icon;
}
}

View File

@ -42,6 +42,8 @@ public class TorService extends Service implements TorServiceConstants, Runnable
private static final int NOTIFY_ID = 1;
private static final int MAX_START_TRIES = 3;
/** Called when the activity is first created. */
public void onCreate() {
@ -114,6 +116,7 @@ public class TorService extends Service implements TorServiceConstants, Runnable
Log.i(TAG, "onUnbind Called: " + intent.getAction());
return super.onUnbind(intent);
@ -169,20 +172,6 @@ public class TorService extends Service implements TorServiceConstants, Runnable
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
/*
if (currentStatus == STATUS_ON && conn != null && webProxy != null)
{
//we are good to go
Log.i(TAG,"onStart: Tor is running");
}
else
{
Log.i(TAG,"onStart: Starting up Tor");
new Thread(this).start();
}
*/
}
public void run ()
@ -324,6 +313,8 @@ public class TorService extends Service implements TorServiceConstants, Runnable
Log.i(TAG, msg);
sendCallbackMessage('>' + msg);
}
private boolean checkTorBinaries ()
@ -386,14 +377,20 @@ public class TorService extends Service implements TorServiceConstants, Runnable
checkTorBinaries ();
new Thread()
{
public void run ()
{
try {
runPrivoxyShellCmd();
} catch (Exception e) {
Log.w(TAG,"Error starting Privoxy",e);
currentStatus = STATUS_OFF;
Log.i(TAG,"Unable to start Privoxy: " + e.getMessage(),e);
sendCallbackMessage("Unable to start Privoxy: " + e.getMessage());
}
}
}.start();
@ -404,8 +401,11 @@ public class TorService extends Service implements TorServiceConstants, Runnable
{
try {
runTorShellCmd();
} catch (Exception e) {
Log.w(TAG,"Error starting Tor",e);
Log.i(TAG,"Unable to start Tor: " + e.getMessage(),e);
sendCallbackMessage("Unable to start Tor: " + e.getMessage());
stopTor();
}
}
}.start();
@ -425,54 +425,82 @@ public class TorService extends Service implements TorServiceConstants, Runnable
Thread.sleep(1000);
int procId = TorServiceUtils.findProcessId(TorServiceConstants.TOR_BINARY_INSTALL_PATH);
while (procId == -1)
int attempts = 0;
while (procId == -1 && attempts < MAX_START_TRIES)
{
log = new StringBuilder();
logNotice(torCmd[0]);
TorServiceUtils.doShellCommand(torCmd, log, false, false);
procId = TorServiceUtils.findProcessId(TorServiceConstants.TOR_BINARY_INSTALL_PATH);
if (procId == -1)
{
this.sendCallbackMessage("Couldn't start Tor process...\n" + log.toString());
Thread.sleep(5000);
}
sendCallbackMessage("Couldn't start Tor process...\n" + log.toString());
Thread.sleep(1000);
sendCallbackMessage("Trying to start Tor again...\n" + log.toString());
Thread.sleep(3000);
attempts++;
}
Log.i(TAG,"Tor process id=" + procId);
logNotice(log.toString());
}
showToolbarNotification("Orbot starting...", "Orbot is starting up", R.drawable.tornotification);
if (procId == -1)
{
throw new Exception ("Unable to start Tor");
}
else
{
logNotice("Tor process id=" + procId);
showToolbarNotification("Orbot starting...", "Tor is running", R.drawable.tornotification);
initControlConnection ();
}
}
private void runPrivoxyShellCmd () throws Exception
{
int privoxyProcId = TorServiceUtils.findProcessId(TorServiceConstants.PRIVOXY_INSTALL_PATH);
StringBuilder log = new StringBuilder();
StringBuilder log = null;
while (privoxyProcId == -1)
int attempts = 0;
while (privoxyProcId == -1 && attempts < MAX_START_TRIES)
{
log = new StringBuilder();
String[] cmds =
{ PRIVOXY_INSTALL_PATH + " " + PRIVOXY_COMMAND_LINE_ARGS };
logNotice (cmds[0]);
TorServiceUtils.doShellCommand(cmds, log, false, true);
//wait one second to make sure it has started up
Thread.sleep(1000);
privoxyProcId = TorServiceUtils.findProcessId(TorServiceConstants.PRIVOXY_INSTALL_PATH);
if (privoxyProcId == -1)
{
this.sendCallbackMessage("Couldn't start Privoxy process... retrying...\n" + log);
Thread.sleep(3000);
attempts++;
}
logNotice(log.toString());
}
sendCallbackMessage("Privoxy is running on port: " + PORT_HTTP);
Thread.sleep(100);
Log.i(TAG,"Privoxy process id=" + privoxyProcId);
logNotice("Privoxy process id=" + privoxyProcId);
@ -673,12 +701,7 @@ public class TorService extends Service implements TorServiceConstants, Runnable
if (msg.indexOf(TOR_CONTROL_PORT_MSG_BOOTSTRAP_DONE)!=-1)
{
currentStatus = STATUS_ON;
showToolbarNotification ("Orbot","Anonymous browsing is enabled",R.drawable.tornotification);
}
else
{
showToolbarNotification("Orbot", msg, R.drawable.tornotification);
showToolbarNotification ("Orbot","Tor is enabled",R.drawable.tornotification);
}
@ -694,29 +717,70 @@ public class TorService extends Service implements TorServiceConstants, Runnable
public void orConnStatus(String status, String orName) {
Log.i(TAG,"OrConnStatus=" + status + ": " + orName);
StringBuilder sb = new StringBuilder();
sb.append("orConnStatus (");
sb.append((orName) );
sb.append("): ");
sb.append(status);
logNotice(sb.toString());
}
public void streamStatus(String status, String streamID, String target) {
Log.i(TAG,"StreamStatus=" + status + ": " + streamID);
StringBuilder sb = new StringBuilder();
sb.append("StreamStatus (");
sb.append((streamID));
sb.append("): ");
sb.append(status);
logNotice(sb.toString());
}
public void unrecognized(String type, String msg) {
Log.i(TAG,"unrecognized log=" + type + ": " + msg);
StringBuilder sb = new StringBuilder();
sb.append("Message (");
sb.append(type);
sb.append("): ");
sb.append(msg);
logNotice(sb.toString());
}
public void bandwidthUsed(long read, long written) {
sendCallbackMessage ("bandwidth used: read=" + read + " written=" + 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());
}
public void circuitStatus(String status, String circID, String path) {
StringBuilder sb = new StringBuilder();
sb.append("Circuit (");
sb.append((circID));
sb.append("): ");
sb.append(status);
sb.append("; ");
sb.append(path);
logNotice(sb.toString());
}
public IBinder onBind(Intent intent) {
@ -786,6 +850,8 @@ public class TorService extends Service implements TorServiceConstants, Runnable
for (int i=0; i<N; i++) {
try {
mCallbacks.getBroadcastItem(i).statusChanged(status);
} catch (RemoteException e) {
// The RemoteCallbackList will take care of removing
// the dead object for us.

View File

@ -46,6 +46,8 @@ public interface TorServiceConstants {
public final static String SHELL_CMD_KILL = "kill";
public final static String SHELL_CMD_RM = "rm";
public final static String SHELL_CMD_PS = "ps";
public final static String SHELL_CMD_PIDOF = "pidof";
public final static String CHMOD_EXE_VALUE = "777";
//path of the installed APK file

View File

@ -112,7 +112,34 @@ public class TorServiceUtils implements TorServiceConstants {
public static int findProcessId(String command)
{
Log.i(TAG, "finding process id for: " + command);
int procId = -1;
try
{
procId = findProcessIdWithPidOf(command);
if (procId == -1)
procId = findProcessIdWithPS(command);
}
catch (Exception e)
{
try
{
procId = findProcessIdWithPS(command);
}
catch (Exception e2)
{
Log.w(TAG,"Unable to get proc id for: " + command,e2);
}
}
return procId;
}
//use 'pidof' command
public static int findProcessIdWithPidOf(String command) throws Exception
{
int procId = -1;
@ -120,7 +147,39 @@ public class TorServiceUtils implements TorServiceConstants {
Process procPs = null;
try {
procPs = r.exec(SHELL_CMD_PIDOF);
BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream()));
String line = null;
while ((line = reader.readLine())!=null)
{
if (line.indexOf(command)!=-1)
{
//this line should just be the process id
procId = Integer.parseInt(line.trim());
break;
}
}
return procId;
}
//use 'ps' command
public static int findProcessIdWithPS(String command) throws Exception
{
int procId = -1;
Runtime r = Runtime.getRuntime();
Process procPs = null;
procPs = r.exec(SHELL_CMD_PS);
@ -141,9 +200,7 @@ public class TorServiceUtils implements TorServiceConstants {
}
}
} catch (Exception e) {
Log.e(TAG, "error: " + e.getMessage(), e);
}
return procId;
@ -174,6 +231,7 @@ public class TorServiceUtils implements TorServiceConstants {
else
proc = Runtime.getRuntime().exec("sh");
OutputStreamWriter out = new OutputStreamWriter(proc.getOutputStream());
for (int i = 0; i < cmds.length; i++)
@ -190,15 +248,19 @@ public class TorServiceUtils implements TorServiceConstants {
{
exitCode = proc.waitFor();
log.append("process exit code: ");
log.append(exitCode);
log.append("\n");
final char buf[] = new char[10];
// Consume the "stdout"
InputStreamReader reader = new InputStreamReader(proc.getInputStream());
int read=0;
while ((read=reader.read(buf)) != -1) {
if (log != null) log.append(buf, 0, read);
}
// Consume the "stderr"
reader = new InputStreamReader(proc.getErrorStream());
read=0;