vpn changes

This commit is contained in:
SandroB 2015-01-20 15:47:24 +01:00
parent 09bdd8fd29
commit 21b75b4c56
23 changed files with 3716 additions and 3705 deletions

View File

@ -5,6 +5,12 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
@ -30,10 +36,20 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View File

@ -3,17 +3,17 @@
package="org.torproject.android"
android:versionName="14.1.4-noPIE"
android:versionCode="132"
android:installLocation="auto"
android:installLocation="auto"
>
<uses-sdk android:minSdkVersion="9" android:maxSdkVersion="20" android:targetSdkVersion="19"/>
<permission android:name="org.torproject.android.MANAGE_TOR" android:label="@string/permission_manage_tor_label" android:description="@string/permission_manage_tor_description" android:protectionLevel="signature"></permission>
<permission android:name="org.torproject.android.MANAGE_TOR" android:label="@string/permission_manage_tor_label" android:description="@string/permission_manage_tor_description" android:protectionLevel="signature"></permission>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
<uses-permission android:name="org.torproject.android.MANAGE_TOR"/>
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
<uses-permission android:name="org.torproject.android.MANAGE_TOR"/>
<application android:name=".OrbotApp" android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
@ -52,11 +52,11 @@
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="org.torproject.android.REQUEST_HS_PORT" />
<action android:name="org.torproject.android.REQUEST_HS_PORT" />
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="org.torproject.android.START_TOR" />
<action android:name="org.torproject.android.START_TOR" />
</intent-filter>
<!--
@ -76,56 +76,56 @@
<!--
<activity android:name=".OrbotDiagnosticsActivity" android:label="OrbotDiag"/>
-->
<activity
android:name=".service.DummyActivity"
android:theme="@android:style/Theme.NoDisplay"
android:enabled="true"
android:allowTaskReparenting="true"
android:noHistory="true"
android:excludeFromRecents="true"
android:alwaysRetainTaskState="false"
android:stateNotNeeded="true"
android:clearTaskOnLaunch="true"
android:finishOnTaskLaunch="true"
/>
<activity android:name=".wizard.LotsaText" android:exported="false"/>
<activity android:name=".wizard.Permissions" android:exported="false"/>
<activity android:name=".wizard.TipsAndTricks" android:exported="false"/>
<activity android:name=".wizard.ConfigureTransProxy" android:exported="false"/>
<activity android:name=".wizard.ChooseLocaleWizardActivity" android:exported="false"/>
<activity android:name=".settings.SettingsPreferences" android:label="@string/app_name"/>
<activity
android:name=".service.DummyActivity"
android:theme="@android:style/Theme.NoDisplay"
android:enabled="true"
android:allowTaskReparenting="true"
android:noHistory="true"
android:excludeFromRecents="true"
android:alwaysRetainTaskState="false"
android:stateNotNeeded="true"
android:clearTaskOnLaunch="true"
android:finishOnTaskLaunch="true"
/>
<activity android:name=".wizard.LotsaText" android:exported="false"/>
<activity android:name=".wizard.Permissions" android:exported="false"/>
<activity android:name=".wizard.TipsAndTricks" android:exported="false"/>
<activity android:name=".wizard.ConfigureTransProxy" android:exported="false"/>
<activity android:name=".wizard.ChooseLocaleWizardActivity" android:exported="false"/>
<activity android:name=".settings.SettingsPreferences" android:label="@string/app_name"/>
<activity android:name=".settings.AppManager" android:label="@string/app_name"/>
<service android:enabled="true"
android:name=".service.TorService"
android:permission="org.torproject.android.MANAGE_TOR"
android:stopWithTask="false"
>
<intent-filter>
<action android:name="org.torproject.android.service.ITorService" />
<action android:name="org.torproject.android.service.TOR_SERVICE" />
<service android:enabled="true"
android:name=".service.TorService"
android:permission="org.torproject.android.MANAGE_TOR"
android:stopWithTask="false"
>
<intent-filter>
<action android:name="org.torproject.android.service.ITorService" />
<action android:name="org.torproject.android.service.TOR_SERVICE" />
</intent-filter>
</service>
<receiver android:name=".OnBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.MEDIA_MOUNTED"/>
</intent-filter>
</receiver>
</service>
<receiver android:name=".OnBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.MEDIA_MOUNTED"/>
</intent-filter>
</receiver>
<service android:name="org.torproject.android.vpn.OrbotVpnService"
android:permission="android.permission.BIND_VPN_SERVICE">
<intent-filter>
<action android:name="android.net.VpnService"/>
</intent-filter>
</service>
</application>

View File

@ -3,17 +3,17 @@
package="org.torproject.android"
android:versionName="14.1.4-PIE"
android:versionCode="133"
android:installLocation="auto"
android:installLocation="auto"
>
<uses-sdk android:minSdkVersion="21" android:maxSdkVersion="21" android:targetSdkVersion="21"/>
<permission android:name="org.torproject.android.MANAGE_TOR" android:label="@string/permission_manage_tor_label" android:description="@string/permission_manage_tor_description" android:protectionLevel="signature"></permission>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
<uses-permission android:name="org.torproject.android.MANAGE_TOR"/>
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
<uses-permission android:name="org.torproject.android.MANAGE_TOR"/>
<application android:name=".OrbotApp" android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
@ -52,11 +52,11 @@
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="org.torproject.android.REQUEST_HS_PORT" />
<action android:name="org.torproject.android.REQUEST_HS_PORT" />
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="org.torproject.android.START_TOR" />
<action android:name="org.torproject.android.START_TOR" />
</intent-filter>
<!--
@ -76,56 +76,56 @@
<!--
<activity android:name=".OrbotDiagnosticsActivity" android:label="OrbotDiag"/>
-->
<activity
android:name=".service.DummyActivity"
android:theme="@android:style/Theme.NoDisplay"
android:enabled="true"
android:allowTaskReparenting="true"
android:noHistory="true"
android:excludeFromRecents="true"
android:alwaysRetainTaskState="false"
android:stateNotNeeded="true"
android:clearTaskOnLaunch="true"
android:finishOnTaskLaunch="true"
/>
<activity android:name=".wizard.LotsaText" android:exported="false"/>
<activity android:name=".wizard.Permissions" android:exported="false"/>
<activity android:name=".wizard.TipsAndTricks" android:exported="false"/>
<activity android:name=".wizard.ConfigureTransProxy" android:exported="false"/>
<activity android:name=".wizard.ChooseLocaleWizardActivity" android:exported="false"/>
<activity android:name=".settings.SettingsPreferences" android:label="@string/app_name"/>
<activity
android:name=".service.DummyActivity"
android:theme="@android:style/Theme.NoDisplay"
android:enabled="true"
android:allowTaskReparenting="true"
android:noHistory="true"
android:excludeFromRecents="true"
android:alwaysRetainTaskState="false"
android:stateNotNeeded="true"
android:clearTaskOnLaunch="true"
android:finishOnTaskLaunch="true"
/>
<activity android:name=".wizard.LotsaText" android:exported="false"/>
<activity android:name=".wizard.Permissions" android:exported="false"/>
<activity android:name=".wizard.TipsAndTricks" android:exported="false"/>
<activity android:name=".wizard.ConfigureTransProxy" android:exported="false"/>
<activity android:name=".wizard.ChooseLocaleWizardActivity" android:exported="false"/>
<activity android:name=".settings.SettingsPreferences" android:label="@string/app_name"/>
<activity android:name=".settings.AppManager" android:label="@string/app_name"/>
<service android:enabled="true"
android:name=".service.TorService"
android:permission="org.torproject.android.MANAGE_TOR"
android:stopWithTask="false"
>
<intent-filter>
<action android:name="org.torproject.android.service.ITorService" />
<action android:name="org.torproject.android.service.TOR_SERVICE" />
<service android:enabled="true"
android:name=".service.TorService"
android:permission="org.torproject.android.MANAGE_TOR"
android:stopWithTask="false"
>
<intent-filter>
<action android:name="org.torproject.android.service.ITorService" />
<action android:name="org.torproject.android.service.TOR_SERVICE" />
</intent-filter>
</service>
<receiver android:name=".OnBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.MEDIA_MOUNTED"/>
</intent-filter>
</receiver>
</service>
<receiver android:name=".OnBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.MEDIA_MOUNTED"/>
</intent-filter>
</receiver>
<service android:name="org.torproject.android.vpn.OrbotVpnService"
android:permission="android.permission.BIND_VPN_SERVICE">
<intent-filter>
<action android:name="android.net.VpnService"/>
</intent-filter>
</service>
</application>

View File

@ -1,21 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.torproject.android"
package="org.sandroproxy.ony"
android:versionName="14.1.4-noPIE"
android:versionCode="132"
android:installLocation="auto"
android:installLocation="auto"
>
<uses-sdk android:minSdkVersion="9" android:maxSdkVersion="20" android:targetSdkVersion="19"/>
<permission android:name="org.torproject.android.MANAGE_TOR" android:label="@string/permission_manage_tor_label" android:description="@string/permission_manage_tor_description" android:protectionLevel="signature"></permission>
<permission android:name="org.torproject.android.MANAGE_TOR" android:label="@string/permission_manage_tor_label" android:description="@string/permission_manage_tor_description" android:protectionLevel="signature"></permission>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
<uses-permission android:name="org.torproject.android.MANAGE_TOR"/>
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
<uses-permission android:name="org.torproject.android.MANAGE_TOR"/>
<application android:name=".OrbotApp" android:icon="@drawable/ic_launcher"
<application android:name="org.sandroproxy.ony.OrbotApp" android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:description="@string/app_description"
android:configChanges="locale|orientation|screenSize"
@ -27,7 +27,7 @@
android:largeHeap="false"
>
<activity android:name=".Orbot"
<activity android:name="org.torproject.android.Orbot"
android:configChanges="orientation|screenSize"
android:excludeFromRecents="true"
android:launchMode="singleTop"
@ -52,11 +52,11 @@
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="org.torproject.android.REQUEST_HS_PORT" />
<action android:name="org.torproject.android.REQUEST_HS_PORT" />
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="org.torproject.android.START_TOR" />
<action android:name="org.torproject.android.START_TOR" />
</intent-filter>
<!--
@ -76,56 +76,56 @@
<!--
<activity android:name=".OrbotDiagnosticsActivity" android:label="OrbotDiag"/>
-->
<activity
android:name=".service.DummyActivity"
android:theme="@android:style/Theme.NoDisplay"
android:enabled="true"
android:allowTaskReparenting="true"
android:noHistory="true"
android:excludeFromRecents="true"
android:alwaysRetainTaskState="false"
android:stateNotNeeded="true"
android:clearTaskOnLaunch="true"
android:finishOnTaskLaunch="true"
/>
<activity android:name=".wizard.LotsaText" android:exported="false"/>
<activity android:name=".wizard.Permissions" android:exported="false"/>
<activity android:name=".wizard.TipsAndTricks" android:exported="false"/>
<activity android:name=".wizard.ConfigureTransProxy" android:exported="false"/>
<activity android:name=".wizard.ChooseLocaleWizardActivity" android:exported="false"/>
<activity android:name=".settings.SettingsPreferences" android:label="@string/app_name"/>
<activity android:name=".settings.AppManager" android:label="@string/app_name"/>
<activity
android:name="org.torproject.android.service.DummyActivity"
android:theme="@android:style/Theme.NoDisplay"
android:enabled="true"
android:allowTaskReparenting="true"
android:noHistory="true"
android:excludeFromRecents="true"
android:alwaysRetainTaskState="false"
android:stateNotNeeded="true"
android:clearTaskOnLaunch="true"
android:finishOnTaskLaunch="true"
/>
<activity android:name="org.torproject.android.wizard.LotsaText" android:exported="false"/>
<activity android:name="org.torproject.android.wizard.Permissions" android:exported="false"/>
<activity android:name="org.torproject.android.wizard.TipsAndTricks" android:exported="false"/>
<activity android:name="org.torproject.android.wizard.ConfigureTransProxy" android:exported="false"/>
<activity android:name="org.torproject.android.wizard.ChooseLocaleWizardActivity" android:exported="false"/>
<activity android:name="org.torproject.android.settings.SettingsPreferences" android:label="@string/app_name"/>
<activity android:name="org.torproject.android.settings.AppManager" android:label="@string/app_name"/>
<service android:enabled="true"
android:name=".service.TorService"
android:permission="org.torproject.android.MANAGE_TOR"
android:stopWithTask="false"
>
<intent-filter>
<action android:name="org.torproject.android.service.ITorService" />
<action android:name="org.torproject.android.service.TOR_SERVICE" />
<service android:enabled="true"
android:name="org.torproject.android.service.TorService"
android:permission="org.torproject.android.MANAGE_TOR"
android:stopWithTask="false"
>
<intent-filter>
<action android:name="org.torproject.android.service.ITorService" />
<action android:name="org.torproject.android.service.TOR_SERVICE" />
</intent-filter>
</service>
<receiver android:name=".OnBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.MEDIA_MOUNTED"/>
</intent-filter>
</receiver>
</service>
<receiver android:name="org.torproject.android.OnBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.MEDIA_MOUNTED"/>
</intent-filter>
</receiver>
<service android:name="org.torproject.android.vpn.OrbotVpnService"
android:permission="android.permission.BIND_VPN_SERVICE">
<intent-filter>
<action android:name="android.net.VpnService"/>
</intent-filter>
</service>
</application>

View File

@ -1,3 +1,3 @@
Manifest-Version: 1.0
Sealed: true
Manifest-Version: 1.0
Sealed: true

4
external/Makefile vendored
View File

@ -16,14 +16,14 @@ EXTERNAL_ROOT := $(shell pwd)
# user building this will have to manually set NDK_PROCESSOR or NDK_TOOLCHAIN.
CPU := $(shell uname -m)
ifeq ($(CPU),x86_64)
NDK_PROCESSOR=x86_64
NDK_PROCESSOR=x86
else
NDK_PROCESSOR=x86
endif
# Android NDK setup
NDK_BASE ?= /opt/android-ndk
NDK_PLATFORM_LEVEL ?= 9
NDK_PLATFORM_LEVEL ?= 19
NDK_ABI ?= arm
NDK_TOOLCHAIN_VERSION=4.8
NDK_SYSROOT=$(NDK_BASE)/platforms/android-$(NDK_PLATFORM_LEVEL)/arch-$(NDK_ABI)

View File

@ -2,10 +2,10 @@
<classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry exported="true" kind="lib" path="libs/android-support-v4.jar"/>
<classpathentry exported="true" kind="lib" path="libs/android-support-v7-appcompat.jar"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View File

@ -1,3 +1,3 @@
##include ../OriginalDest/Android.mk
##include ../external/badvpn/Android.mk
include ./external/badvpn/Android.mk
##include ../kalium-jni/jni/Android.mk

View File

@ -36,7 +36,7 @@
android:id="@+id/menu_verify_list"
android:title="@string/menu_verify"
android:icon="@drawable/ic_action_browse"
yourapp:showAsAction="always"
yourapp:showAsAction="always"
>
<menu>
<item android:id="@+id/menu_verify"
@ -65,11 +65,9 @@
yourapp:showAsAction="never"
/>
<!--
<item android:id="@+id/menu_vpn"
android:title="@string/menu_vpn"
yourapp:showAsAction="never"/>
-->
<item android:id="@+id/menu_exit"
android:title="@string/menu_exit"

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<resources>
<string name="app_name">Orbot</string>
<string name="app_name">Ony</string>
<string name="app_description">Orbot is a free proxy app that empowers other apps to use the internet more securely. Orbot uses Tor to encrypt your Internet traffic and then hides it by bouncing through a series of computers around the world. Tor is free software and an open network that helps you defend against a form of network surveillance that threatens personal freedom and privacy, confidential business activities and relationships, and state security known as traffic analysis.</string>
<string name="internal_web_url">http://orbot/</string>
<string name="default_web_url">http://check.torproject.org</string>

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import org.sandroproxy.ony.R;
import org.sufficientlysecure.rootcommands.Shell;
import org.sufficientlysecure.rootcommands.command.SimpleCommand;
import org.torproject.android.service.TorResourceInstaller;

View File

@ -17,9 +17,9 @@ import java.util.concurrent.TimeoutException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.sandroproxy.ony.R;
import org.sufficientlysecure.rootcommands.Shell;
import org.sufficientlysecure.rootcommands.command.SimpleCommand;
import org.torproject.android.R;
import org.torproject.android.TorConstants;
import android.content.Context;
@ -28,44 +28,44 @@ import android.util.Log;
public class TorResourceInstaller implements TorServiceConstants {
File installFolder;
Context context;
public TorResourceInstaller (Context context, File installFolder)
{
this.installFolder = installFolder;
this.context = context;
}
public void deleteDirectory(File file) {
if( file.exists() ) {
if (file.isDirectory()) {
File[] files = file.listFiles();
for(int i=0; i<files.length; i++) {
if(files[i].isDirectory()) {
deleteDirectory(files[i]);
}
else {
files[i].delete();
}
}
}
file.delete();
}
}
private final static String COMMAND_RM_FORCE = "rm -f ";
//
/*
* Extract the Tor resources from the APK file using ZIP
*/
public boolean installResources () throws IOException, FileNotFoundException, TimeoutException
{
InputStream is;
File installFolder;
Context context;
public TorResourceInstaller (Context context, File installFolder)
{
this.installFolder = installFolder;
this.context = context;
}
public void deleteDirectory(File file) {
if( file.exists() ) {
if (file.isDirectory()) {
File[] files = file.listFiles();
for(int i=0; i<files.length; i++) {
if(files[i].isDirectory()) {
deleteDirectory(files[i]);
}
else {
files[i].delete();
}
}
}
file.delete();
}
}
private final static String COMMAND_RM_FORCE = "rm -f ";
//
/*
* Extract the Tor resources from the APK file using ZIP
*/
public boolean installResources () throws IOException, FileNotFoundException, TimeoutException
{
InputStream is;
File outFile;
deleteDirectory(installFolder);
@ -74,129 +74,129 @@ public class TorResourceInstaller implements TorServiceConstants {
Shell shell = Shell.startShell(new ArrayList<String>(),installFolder.getAbsolutePath());
is = context.getResources().openRawResource(R.raw.torrc);
outFile = new File(installFolder, TORRC_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, false);
is = context.getResources().openRawResource(R.raw.torpolipo);
outFile = new File(installFolder, POLIPOCONFIG_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, false);
is = context.getResources().openRawResource(R.raw.tor);
outFile = new File(installFolder, TOR_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, true);
is = context.getResources().openRawResource(R.raw.polipo);
outFile = new File(installFolder, POLIPO_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, true);
is = context.getResources().openRawResource(R.raw.obfsclient);
outFile = new File(installFolder, OBFSCLIENT_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, true);
is = context.getResources().openRawResource(R.raw.xtables);
outFile = new File(installFolder, IPTABLES_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, true);
is = context.getResources().openRawResource(R.raw.torrc);
outFile = new File(installFolder, TORRC_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, false);
is = context.getResources().openRawResource(R.raw.torpolipo);
outFile = new File(installFolder, POLIPOCONFIG_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, false);
return true;
}
public boolean updateTorConfigCustom (File fileTorRcCustom, String extraLines) throws IOException, FileNotFoundException, TimeoutException
{
is = context.getResources().openRawResource(R.raw.tor);
outFile = new File(installFolder, TOR_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, true);
is = context.getResources().openRawResource(R.raw.polipo);
outFile = new File(installFolder, POLIPO_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, true);
is = context.getResources().openRawResource(R.raw.obfsclient);
outFile = new File(installFolder, OBFSCLIENT_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, true);
is = context.getResources().openRawResource(R.raw.xtables);
outFile = new File(installFolder, IPTABLES_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, true);
return true;
}
public boolean updateTorConfigCustom (File fileTorRcCustom, String extraLines) throws IOException, FileNotFoundException, TimeoutException
{
StringBufferInputStream sbis = new StringBufferInputStream(extraLines + '\n');
streamToFile(sbis,fileTorRcCustom,false,false);
return true;
}
public boolean updatePolipoConfig (File filePolipo, String extraLines) throws IOException, FileNotFoundException, TimeoutException
{
InputStream is;
StringBufferInputStream sbis = new StringBufferInputStream(extraLines + '\n');
streamToFile(sbis,fileTorRcCustom,false,false);
return true;
}
public boolean updatePolipoConfig (File filePolipo, String extraLines) throws IOException, FileNotFoundException, TimeoutException
{
InputStream is;
Shell shell = Shell.startShell(new ArrayList<String>(),installFolder.getAbsolutePath());
is = context.getResources().openRawResource(R.raw.torpolipo);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + filePolipo.getAbsolutePath())).waitForFinish();
streamToFile(is,filePolipo, false, false);
is = context.getResources().openRawResource(R.raw.torpolipo);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + filePolipo.getAbsolutePath())).waitForFinish();
streamToFile(is,filePolipo, false, false);
if (extraLines != null && extraLines.length() > 0)
{
StringBufferInputStream sbis = new StringBufferInputStream('\n' + extraLines + '\n');
streamToFile(sbis,filePolipo,true,false);
}
shell.close();
return true;
}
public boolean installPolipoConf () throws IOException, FileNotFoundException, TimeoutException
{
InputStream is;
if (extraLines != null && extraLines.length() > 0)
{
StringBufferInputStream sbis = new StringBufferInputStream('\n' + extraLines + '\n');
streamToFile(sbis,filePolipo,true,false);
}
shell.close();
return true;
}
public boolean installPolipoConf () throws IOException, FileNotFoundException, TimeoutException
{
InputStream is;
File outFile;
Shell shell = Shell.startShell(new ArrayList<String>(),installFolder.getAbsolutePath());
is = context.getResources().openRawResource(R.raw.torpolipo);
outFile = new File(installFolder, POLIPOCONFIG_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, false);
return true;
}
/*
* Extract the Tor binary from the APK file using ZIP
*/
public boolean installGeoIP () throws IOException, FileNotFoundException
{
InputStream is;
outFile = new File(installFolder, POLIPOCONFIG_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, false);
return true;
}
/*
* Extract the Tor binary from the APK file using ZIP
*/
public boolean installGeoIP () throws IOException, FileNotFoundException
{
InputStream is;
File outFile;
is = context.getResources().openRawResource(R.raw.geoip);
outFile = new File(installFolder, GEOIP_ASSET_KEY);
streamToFile(is, outFile, false, true);
is = context.getResources().openRawResource(R.raw.geoip6);
outFile = new File(installFolder, GEOIP6_ASSET_KEY);
streamToFile(is, outFile, false, true);
return true;
}
/*
private static void copyAssetFile(Context ctx, String asset, File file) throws IOException, InterruptedException
{
DataOutputStream out = new DataOutputStream(new FileOutputStream(file));
InputStream is = new GZIPInputStream(ctx.getAssets().open(asset));
byte buf[] = new byte[8172];
int len;
while ((len = is.read(buf)) > 0) {
out.write(buf, 0, len);
}
out.close();
is.close();
}*/
/*
* Write the inputstream contents to the file
*/
is = context.getResources().openRawResource(R.raw.geoip);
outFile = new File(installFolder, GEOIP_ASSET_KEY);
streamToFile(is, outFile, false, true);
is = context.getResources().openRawResource(R.raw.geoip6);
outFile = new File(installFolder, GEOIP6_ASSET_KEY);
streamToFile(is, outFile, false, true);
return true;
}
/*
private static void copyAssetFile(Context ctx, String asset, File file) throws IOException, InterruptedException
{
DataOutputStream out = new DataOutputStream(new FileOutputStream(file));
InputStream is = new GZIPInputStream(ctx.getAssets().open(asset));
byte buf[] = new byte[8172];
int len;
while ((len = is.read(buf)) > 0) {
out.write(buf, 0, len);
}
out.close();
is.close();
}*/
/*
* Write the inputstream contents to the file
*/
public static boolean streamToFile(InputStream stm, File outFile, boolean append, boolean zip) throws IOException
{
@ -204,17 +204,17 @@ public class TorResourceInstaller implements TorServiceConstants {
int bytecount;
OutputStream stmOut = new FileOutputStream(outFile.getAbsolutePath(), append);
ZipInputStream zis = null;
if (zip)
{
zis = new ZipInputStream(stm);
ZipEntry ze = zis.getNextEntry();
stm = zis;
}
OutputStream stmOut = new FileOutputStream(outFile.getAbsolutePath(), append);
ZipInputStream zis = null;
if (zip)
{
zis = new ZipInputStream(stm);
ZipEntry ze = zis.getNextEntry();
stm = zis;
}
while ((bytecount = stm.read(buffer)) > 0)
{
@ -226,97 +226,97 @@ public class TorResourceInstaller implements TorServiceConstants {
stm.close();
if (zis != null)
zis.close();
zis.close();
return true;
}
//copy the file from inputstream to File output - alternative impl
public static void copyFile (InputStream is, File outputFile)
{
try {
outputFile.createNewFile();
DataOutputStream out = new DataOutputStream(new FileOutputStream(outputFile));
DataInputStream in = new DataInputStream(is);
int b = -1;
byte[] data = new byte[1024];
while ((b = in.read(data)) != -1) {
out.write(data);
}
if (b == -1); //rejoice
//
out.flush();
out.close();
in.close();
// chmod?
} catch (IOException ex) {
Log.e(TorConstants.TAG, "error copying binary", ex);
}
public static void copyFile (InputStream is, File outputFile)
{
try {
outputFile.createNewFile();
DataOutputStream out = new DataOutputStream(new FileOutputStream(outputFile));
DataInputStream in = new DataInputStream(is);
int b = -1;
byte[] data = new byte[1024];
while ((b = in.read(data)) != -1) {
out.write(data);
}
if (b == -1); //rejoice
//
out.flush();
out.close();
in.close();
// chmod?
} catch (IOException ex) {
Log.e(TorConstants.TAG, "error copying binary", ex);
}
}
}
/**
* Copies a raw resource file, given its ID to the given location
* @param ctx context
* @param resid resource id
* @param file destination file
* @param mode file permissions (E.g.: "755")
* @throws IOException on error
* @throws InterruptedException when interrupted
*/
public static void copyRawFile(Context ctx, int resid, File file, String mode, boolean isZipd) throws IOException, InterruptedException
{
final String abspath = file.getAbsolutePath();
// Write the iptables binary
final FileOutputStream out = new FileOutputStream(file);
InputStream is = ctx.getResources().openRawResource(resid);
if (isZipd)
{
ZipInputStream zis = new ZipInputStream(is);
ZipEntry ze = zis.getNextEntry();
is = zis;
}
byte buf[] = new byte[1024];
int len;
while ((len = is.read(buf)) > 0) {
out.write(buf, 0, len);
}
out.close();
is.close();
// Change the permissions
Runtime.getRuntime().exec("chmod "+mode+" "+abspath).waitFor();
}
/**
* Asserts that the binary files are installed in the bin directory.
* @param ctx context
* Copies a raw resource file, given its ID to the given location
* @param ctx context
* @param resid resource id
* @param file destination file
* @param mode file permissions (E.g.: "755")
* @throws IOException on error
* @throws InterruptedException when interrupted
*/
public static void copyRawFile(Context ctx, int resid, File file, String mode, boolean isZipd) throws IOException, InterruptedException
{
final String abspath = file.getAbsolutePath();
// Write the iptables binary
final FileOutputStream out = new FileOutputStream(file);
InputStream is = ctx.getResources().openRawResource(resid);
if (isZipd)
{
ZipInputStream zis = new ZipInputStream(is);
ZipEntry ze = zis.getNextEntry();
is = zis;
}
byte buf[] = new byte[1024];
int len;
while ((len = is.read(buf)) > 0) {
out.write(buf, 0, len);
}
out.close();
is.close();
// Change the permissions
Runtime.getRuntime().exec("chmod "+mode+" "+abspath).waitFor();
}
/**
* Asserts that the binary files are installed in the bin directory.
* @param ctx context
* @param showErrors indicates if errors should be alerted
* @return false if the binary files could not be installed
*/
/*
public static boolean assertIpTablesBinaries(Context ctx, boolean showErrors) throws Exception {
boolean changed = false;
// Check iptables_g1
File file = new File(ctx.getDir("bin",0), "iptables");
copyRawFile(ctx, R.raw.iptables, file, CHMOD_EXEC, false);
return true;
}*/
* @return false if the binary files could not be installed
*/
/*
public static boolean assertIpTablesBinaries(Context ctx, boolean showErrors) throws Exception {
boolean changed = false;
// Check iptables_g1
File file = new File(ctx.getDir("bin",0), "iptables");
copyRawFile(ctx, R.raw.iptables, file, CHMOD_EXEC, false);
return true;
}*/
}

File diff suppressed because it is too large Load Diff

View File

@ -11,10 +11,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
import org.torproject.android.R;
import org.sandroproxy.ony.R;
import org.torproject.android.TorConstants;
import org.torproject.android.service.TorService;
import org.torproject.android.service.TorServiceUtils;

View File

@ -5,8 +5,8 @@ package org.torproject.android.settings;
import java.util.Locale;
import org.sandroproxy.ony.R;
import org.sufficientlysecure.rootcommands.RootCommands;
import org.torproject.android.R;
import org.torproject.android.service.TorServiceUtils;
import android.content.Context;

View File

@ -20,23 +20,36 @@ import java.io.IOException;
import java.net.InetAddress;
import java.nio.ByteBuffer;
import java.util.Locale;
import java.util.Set;
import org.sandroproxy.ony.R;
import org.torproject.android.Orbot;
import org.torproject.android.service.TorService;
import org.torproject.android.service.TorServiceConstants;
import com.runjva.sourceforge.jsocks.protocol.ProxyServer;
import com.runjva.sourceforge.jsocks.server.ServerAuthenticatorNone;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.VpnService;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import android.widget.RemoteViews;
import android.widget.Toast;
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public class OrbotVpnService extends VpnService implements Handler.Callback {
private static final String TAG = "OrbotVpnService";
private static final String TAG = "DrobotVpnService";
private PendingIntent mConfigureIntent;
@ -48,14 +61,28 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
private ParcelFileDescriptor mInterface;
private int mSocksProxyPort = 9999;
// private ProxyServer mProxyServer;
private ProxyServer mProxyServer;
private final static int VPN_MTU = 1500;
private static final int NOTIFY_ID = 10;
private static final int TRANSPROXY_NOTIFY_ID = 20;
private static final int ERROR_NOTIFY_ID = 30;
private static final int HS_NOTIFY_ID = 40;
private boolean prefPersistNotifications = true;
private NotificationManager mNotificationManager = null;
private android.support.v4.app.NotificationCompat.Builder mNotifyBuilder;
private Notification mNotification;
private boolean mShowExpandedNotifications = false;
private boolean mNotificationShowing = false;
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// The handler is only used to show messages.
// The handler is only used to show messages.
if (mHandler == null) {
mHandler = new Handler(this);
}
@ -63,30 +90,46 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
// Stop the previous session by interrupting the thread.
if (mThreadVPN == null || (!mThreadVPN.isAlive()))
{
startSocksBypass ();
setupTun2Socks();
startSocksBypass ();
setupTun2Socks();
}
return START_STICKY;
}
private void startSocksBypass ()
{
private void startSocksBypass(){
mThreadProxy = new Thread ()
{
public void run ()
{
try {
mProxyServer = new ProxyServer(new ServerAuthenticatorNone(null, null));
ProxyServer.setVpnService(OrbotVpnService.this);
mProxyServer.start(mSocksProxyPort, 5, InetAddress.getLocalHost());
} catch (Exception e) {
Log.d(TAG,"proxy server error: " + e.getLocalizedMessage(),e);
}
}
};
mThreadProxy.start();
}
@Override
public void onDestroy() {
if (mInterface != null)
try {
mInterface.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (mProxyServer != null){
mProxyServer.stop();
}
if (mInterface != null){
try {
mInterface.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
@Override
@ -100,152 +143,158 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
private void setupTun2Socks() {
mThreadVPN = new Thread ()
{
public void run ()
{
if (mInterface == null)
{
// Set the locale to English (or probably any other language that^M
// uses Hindu-Arabic (aka Latin) numerals).^M
// We have found that VpnService.Builder does something locale-dependent^M
// internally that causes errors when the locale uses its own numerals^M
// (i.e., Farsi and Arabic).^M
Locale.setDefault(new Locale("en"));
Builder builder = new Builder();
builder.setMtu(VPN_MTU);
builder.addAddress("10.0.0.1",8);
builder.setSession("OrbotVPN");
builder.addRoute("0.0.0.0",0);
builder.addRoute("10.0.0.0",8);
//builder.addRoute("192.0.0.0",8);
//builder.addRoute("192.168.43.0",8);
builder.addDnsServer("8.8.8.8");
// Create a new interface using the builder and save the parameters.
mInterface = builder.setSession(mSessionName)
.setConfigureIntent(mConfigureIntent)
.establish();
try
{
Tun2Socks.Start(mInterface, VPN_MTU, "10.0.0.2", "255.255.255.0", "localhost:" + TorServiceConstants.PORT_SOCKS_DEFAULT, "50.116.51.157:7300", true);
}
catch (Exception e)
{
Log.d(TAG,"tun2Socks has stopped",e);
}
}
}
};
mThreadVPN.start();
mThreadVPN = new Thread ()
{
public void run ()
{
if (mInterface == null)
{
// Set the locale to English (or probably any other language that^M
// uses Hindu-Arabic (aka Latin) numerals).^M
// We have found that VpnService.Builder does something locale-dependent^M
// internally that causes errors when the locale uses its own numerals^M
// (i.e., Farsi and Arabic).^M
Locale.setDefault(new Locale("en"));
Builder builder = new Builder();
builder.setMtu(VPN_MTU);
builder.addAddress("10.0.0.1",28);
builder.setSession("DrobotVPN");
builder.addRoute("0.0.0.0",0);
//builder.addRoute("192.0.0.0",8);
//builder.addRoute("192.168.43.0",8);
// Create a new interface using the builder and save the parameters.
mInterface = builder.setSession(mSessionName)
.setConfigureIntent(mConfigureIntent)
.establish();
try
{
Tun2Socks.Start(mInterface,
VPN_MTU,
"10.0.0.2",
"255.255.255.0",
"127.0.0.1:" + TorServiceConstants.PORT_SOCKS_DEFAULT,
"10.0.0.1:" + String.valueOf(TorServiceConstants.TOR_DNS_PORT_DEFAULT),
true);
}
catch (Exception e)
{
Log.d(TAG,"tun2Socks has stopped",e);
}
}
}
};
mThreadVPN.start();
showToolbarNotification(getString(R.string.status_activated), NOTIFY_ID, R.drawable.ic_stat_tor);
}
@Override
public void onRevoke() {
new Thread ()
{
public void run()
{
try
{
mInterface.close();
Tun2Socks.Stop();
}
catch (Exception e)
{
Log.d(TAG,"error stopping tun2socks",e);
}
}
}.start();
super.onRevoke();
}
@Override
public void onRevoke() {
new Thread ()
{
public void run()
{
try
{
mInterface.close();
Tun2Socks.Stop();
}
catch (Exception e)
{
Log.d(TAG,"error stopping tun2socks",e);
}
}
}.start();
clearNotifications();
super.onRevoke();
}
/*
private void debugPacket(ByteBuffer packet)
private void clearNotifications()
{
if (mNotificationManager != null)
mNotificationManager.cancelAll();
mNotificationShowing = false;
}
@SuppressLint("NewApi")
private void showToolbarNotification (String notifyMsg, int notifyType, int icon)
{
//Reusable code.
Intent intent = new Intent(OrbotVpnService.this, Orbot.class);
PendingIntent pendIntent = PendingIntent.getActivity(OrbotVpnService.this, 0, intent, 0);
if (mNotifyBuilder == null)
{
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (mNotifyBuilder == null)
{
mNotifyBuilder = new NotificationCompat.Builder(this)
.setContentTitle(getString(R.string.app_name))
.setSmallIcon(R.drawable.ic_stat_tor);
mNotifyBuilder.setContentIntent(pendIntent);
}
}
int buffer = packet.get();
int version;
int headerlength;
version = buffer >> 4;
headerlength = buffer & 0x0F;
headerlength *= 4;
Log.d(TAG, "IP Version:"+version);
Log.d(TAG, "Header Length:"+headerlength);
String status = "";
status += "Header Length:"+headerlength;
buffer = packet.get(); //DSCP + EN
buffer = packet.getChar(); //Total Length
Log.d(TAG, "Total Length:"+buffer);
buffer = packet.getChar(); //Identification
Log.d(TAG, "Identification:"+buffer);
buffer = packet.getChar(); //Flags + Fragment Offset
buffer = packet.get(); //Time to Live
buffer = packet.get(); //Protocol
Log.d(TAG, "Protocol:"+buffer);
status += " Protocol:"+buffer;
buffer = packet.getChar(); //Header checksum
String sourceIP = "";
buffer = packet.get(); //Source IP 1st Octet
sourceIP += buffer;
sourceIP += ".";
buffer = packet.get(); //Source IP 2nd Octet
sourceIP += buffer;
sourceIP += ".";
buffer = packet.get(); //Source IP 3rd Octet
sourceIP += buffer;
sourceIP += ".";
buffer = packet.get(); //Source IP 4th Octet
sourceIP += buffer;
Log.d(TAG, "Source IP:"+sourceIP);
status += " Source IP:"+sourceIP;
String destIP = "";
buffer = packet.get(); //Destination IP 1st Octet
destIP += buffer;
destIP += ".";
buffer = packet.get(); //Destination IP 2nd Octet
destIP += buffer;
destIP += ".";
buffer = packet.get(); //Destination IP 3rd Octet
destIP += buffer;
destIP += ".";
buffer = packet.get(); //Destination IP 4th Octet
destIP += buffer;
Log.d(TAG, "Destination IP:"+destIP);
status += " Destination IP:"+destIP;
//Log.d(TAG, "version:"+packet.getInt());
//Log.d(TAG, "version:"+packet.getInt());
//Log.d(TAG, "version:"+packet.getInt());
}*/
mNotifyBuilder.setContentText(notifyMsg);
mNotifyBuilder.setSmallIcon(icon);
if (notifyType != NOTIFY_ID)
{
mNotifyBuilder.setTicker(notifyMsg);
// mNotifyBuilder.setLights(Color.GREEN, 1000, 1000);
}
else
{
mNotifyBuilder.setTicker(null);
}
mNotifyBuilder.setOngoing(prefPersistNotifications);
mNotification = mNotifyBuilder.build();
if (Build.VERSION.SDK_INT >= 16 && mShowExpandedNotifications) {
// Create remote view that needs to be set as bigContentView for the notification.
RemoteViews expandedView = new RemoteViews(this.getPackageName(),
R.layout.layout_notification_expanded);
StringBuffer sbInfo = new StringBuffer();
if (notifyType == NOTIFY_ID)
expandedView.setTextViewText(R.id.text, notifyMsg);
else
{
expandedView.setTextViewText(R.id.info, notifyMsg);
}
expandedView.setTextViewText(R.id.title, getString(R.string.app_name));
expandedView.setImageViewResource(R.id.icon, icon);
mNotification.bigContentView = expandedView;
}
if (prefPersistNotifications && (!mNotificationShowing))
{
startForeground(NOTIFY_ID, mNotification);
}
else
{
mNotificationManager.notify(NOTIFY_ID, mNotification);
}
mNotificationShowing = true;
}
}

View File

@ -25,6 +25,7 @@ import java.net.Socket;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.ParcelFileDescriptor;
import android.util.Log;
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
public class Tun2Socks
@ -35,6 +36,8 @@ public class Tun2Socks
boolean doVpnProtect(DatagramSocket socket);
};
private static final String TAG = Tun2Socks.class.getSimpleName();
private static final boolean LOGD = true;
private static Thread mThread;
private static ParcelFileDescriptor mVpnInterfaceFileDescriptor;
@ -61,11 +64,11 @@ public class Tun2Socks
boolean udpgwTransparentDNS)
{
if (!mLibLoaded)
{
System.loadLibrary("tun2socks");
mLibLoaded = true;
}
if (!mLibLoaded)
{
System.loadLibrary("tun2socks");
mLibLoaded = true;
}
mVpnInterfaceFileDescriptor = vpnInterfaceFileDescriptor;
mVpnInterfaceMTU = vpnInterfaceMTU;
@ -76,16 +79,14 @@ public class Tun2Socks
mUdpgwTransparentDNS = udpgwTransparentDNS;
if (mVpnInterfaceFileDescriptor != null)
runTun2Socks(
mVpnInterfaceFileDescriptor.detachFd(),
mVpnInterfaceMTU,
mVpnIpAddress,
mVpnNetMask,
mSocksServerAddress,
mUdpgwServerAddress,
mUdpgwTransparentDNS ? 1 : 0);
runTun2Socks(
mVpnInterfaceFileDescriptor.detachFd(),
mVpnInterfaceMTU,
mVpnIpAddress,
mVpnNetMask,
mSocksServerAddress,
mUdpgwServerAddress,
mUdpgwTransparentDNS ? 1 : 0);
}
public static void Stop()
@ -94,7 +95,23 @@ public class Tun2Socks
terminateTun2Socks();
}
public static void logTun2Socks(
String level,
String channel,
String msg)
{
String logMsg = level + "(" + channel + "): " + msg;
if (0 == level.compareTo("ERROR"))
{
Log.e(TAG, logMsg);
}
else
{
if (LOGD) Log.d(TAG, logMsg);
}
}
private native static int runTun2Socks(
int vpnInterfaceFileDescriptor,
int vpnInterfaceMTU,

View File

@ -2,7 +2,7 @@ package org.torproject.android.wizard;
import java.util.Locale;
import org.torproject.android.R;
import org.sandroproxy.ony.R;
import org.torproject.android.TorConstants;
import org.torproject.android.service.TorServiceUtils;
@ -24,66 +24,66 @@ import android.widget.Toast;
public class ChooseLocaleWizardActivity extends Activity implements TorConstants {
private int flag = 0;
private ListView listLocales;
protected void onCreate(Bundle savedInstanceState)
{
private int flag = 0;
private ListView listLocales;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
}
@Override
protected void onStart() {
super.onStart();
setContentView(R.layout.layout_wizard_locale);
listLocales = (ListView)findViewById(R.id.wizard_locale_list);
Button next = ((Button)findViewById(R.id.btnWizard2));
// next.setEnabled(false);
String[] strLangs = getResources().getStringArray(R.array.languages);
strLangs[0] = Locale.getDefault().getDisplayName();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, strLangs);
}
@Override
protected void onStart() {
super.onStart();
setContentView(R.layout.layout_wizard_locale);
listLocales = (ListView)findViewById(R.id.wizard_locale_list);
Button next = ((Button)findViewById(R.id.btnWizard2));
// next.setEnabled(false);
String[] strLangs = getResources().getStringArray(R.array.languages);
strLangs[0] = Locale.getDefault().getDisplayName();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, strLangs);
listLocales.setAdapter(adapter);
listLocales.setSelection(0);
listLocales.setOnItemClickListener(new OnItemClickListener() {
listLocales.setSelection(0);
listLocales.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
setLocalePref(arg2);
finish();
startActivity(new Intent(ChooseLocaleWizardActivity.this, LotsaText.class));
}
});
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setLocalePref(0);
finish();
startActivity(new Intent(ChooseLocaleWizardActivity.this, LotsaText.class));
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
setLocalePref(arg2);
finish();
startActivity(new Intent(ChooseLocaleWizardActivity.this, LotsaText.class));
}
});
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setLocalePref(0);
finish();
startActivity(new Intent(ChooseLocaleWizardActivity.this, LotsaText.class));
}
});
}
});
}
private void setLocalePref(int selId)
{
}
private void setLocalePref(int selId)
{
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
Configuration config = getResources().getConfiguration();
@ -91,18 +91,18 @@ public class ChooseLocaleWizardActivity extends Activity implements TorConstants
String lang = localeVals[selId];
Editor pEdit = prefs.edit();
pEdit.putString(PREF_DEFAULT_LOCALE, lang);
pEdit.commit();
Locale locale = null;
Editor pEdit = prefs.edit();
pEdit.putString(PREF_DEFAULT_LOCALE, lang);
pEdit.commit();
Locale locale = null;
if (lang.equals("xx"))
{
locale = Locale.getDefault();
locale = Locale.getDefault();
}
else
locale = new Locale(lang);
locale = new Locale(lang);
Locale.setDefault(locale);
config.locale = locale;
@ -110,27 +110,27 @@ public class ChooseLocaleWizardActivity extends Activity implements TorConstants
}
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}
//Code to override the back button!
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK){
Toast.makeText(getApplicationContext(), R.string.wizard_exit_at_first_screen_toast, Toast.LENGTH_SHORT).show();
return true;
}
return false;
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}
//Code to override the back button!
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK){
Toast.makeText(getApplicationContext(), R.string.wizard_exit_at_first_screen_toast, Toast.LENGTH_SHORT).show();
return true;
}
return false;
}
}

View File

@ -1,12 +1,8 @@
package org.torproject.android.wizard;
import org.sandroproxy.ony.R;
import org.torproject.android.Orbot;
import org.torproject.android.R;
import org.torproject.android.TorConstants;
import org.torproject.android.R.drawable;
import org.torproject.android.R.id;
import org.torproject.android.R.layout;
import org.torproject.android.R.string;
import org.torproject.android.service.TorServiceUtils;
import org.torproject.android.settings.AppManager;

View File

@ -1,6 +1,6 @@
package org.torproject.android.wizard;
import org.torproject.android.R;
import org.sandroproxy.ony.R;
import org.torproject.android.TorConstants;
import org.torproject.android.service.TorServiceUtils;

View File

@ -1,7 +1,7 @@
package org.torproject.android.wizard;
import org.sandroproxy.ony.R;
import org.sufficientlysecure.rootcommands.RootCommands;
import org.torproject.android.R;
import org.torproject.android.TorConstants;
import org.torproject.android.service.TorServiceUtils;
@ -22,49 +22,49 @@ import android.widget.TextView;
public class Permissions extends Activity implements TorConstants {
private Context context;
protected void onCreate(Bundle savedInstanceState)
{
private Context context;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
context = this;
}
@Override
protected void onStart() {
super.onStart();
setContentView(R.layout.layout_wizard_permissions);
stepFourRoot();
}
@Override
protected void onResume() {
super.onResume();
}
private void stepFourRoot(){
String msg1 = context.getString(R.string.wizard_permissions_root_msg1);
String msg2 = context.getString(R.string.wizard_permissions_root_msg2);
}
@Override
protected void onStart() {
super.onStart();
setContentView(R.layout.layout_wizard_permissions);
stepFourRoot();
}
@Override
protected void onResume() {
super.onResume();
}
private void stepFourRoot(){
String msg1 = context.getString(R.string.wizard_permissions_root_msg1);
String msg2 = context.getString(R.string.wizard_permissions_root_msg2);
TextView txtBody1 = ((TextView)findViewById(R.id.WizardTextBody1));
txtBody1.setText(msg1);
txtBody1.setText(msg1);
TextView txtBody2 = ((TextView)findViewById(R.id.WizardTextBody2));
txtBody2.setText(msg2);
txtBody2.setVisibility(TextView.VISIBLE);
Button grantPermissions = ((Button)findViewById(R.id.grantPermissions));
grantPermissions.setVisibility(Button.VISIBLE);
txtBody2.setText(msg2);
txtBody2.setVisibility(TextView.VISIBLE);
Button grantPermissions = ((Button)findViewById(R.id.grantPermissions));
grantPermissions.setVisibility(Button.VISIBLE);
Button back = ((Button)findViewById(R.id.btnWizard1));
Button next = ((Button)findViewById(R.id.btnWizard2));
next.setEnabled(false);
@ -74,133 +74,133 @@ public class Permissions extends Activity implements TorConstants {
consent.setOnCheckedChangeListener(new OnCheckedChangeListener (){
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
//this is saying do not use root
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
//this is saying do not use root
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
Editor pEdit = prefs.edit();
pEdit.putBoolean(PREF_TRANSPARENT, false);
pEdit.putBoolean(PREF_TRANSPARENT_ALL, false);
pEdit.putBoolean(PREF_HAS_ROOT, false);
pEdit.commit();
/*
Button next = ((Button)findViewById(R.id.btnWizard2));
if(isChecked)
next.setEnabled(true);
else
next.setEnabled(false);
*/
stepFour();
}
Editor pEdit = prefs.edit();
pEdit.putBoolean(PREF_TRANSPARENT, false);
pEdit.putBoolean(PREF_TRANSPARENT_ALL, false);
pEdit.putBoolean(PREF_HAS_ROOT, false);
pEdit.commit();
/*
Button next = ((Button)findViewById(R.id.btnWizard2));
if(isChecked)
next.setEnabled(true);
else
next.setEnabled(false);
*/
stepFour();
}
});
grantPermissions.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//Check and Install iptables - TorTransProxy.testOwnerModule(this)
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
boolean hasRoot = RootCommands.rootAccessGiven();
Editor pEdit = prefs.edit();
pEdit.putBoolean(PREF_HAS_ROOT,hasRoot);
pEdit.commit();
if (!hasRoot)
{
public void onClick(View v) {
//Check and Install iptables - TorTransProxy.testOwnerModule(this)
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
boolean hasRoot = RootCommands.rootAccessGiven();
Editor pEdit = prefs.edit();
pEdit.putBoolean(PREF_HAS_ROOT,hasRoot);
pEdit.commit();
if (!hasRoot)
{
stepFour();
}
else
{
finish();
startActivity(new Intent(Permissions.this, ConfigureTransProxy.class));
}
stepFour();
}
else
{
finish();
startActivity(new Intent(Permissions.this, ConfigureTransProxy.class));
}
}
});
}
});
back.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
startActivity(new Intent(Permissions.this, LotsaText.class));
}
});
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
startActivity(new Intent(Permissions.this, TipsAndTricks.class));
}
});
}
private void stepFour(){
String title = context.getString(R.string.wizard_permissions_title);
String msg = context.getString(R.string.wizard_permissions_no_root_msg);
setTitle(title);
back.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
startActivity(new Intent(Permissions.this, LotsaText.class));
}
});
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
startActivity(new Intent(Permissions.this, TipsAndTricks.class));
}
});
}
private void stepFour(){
String title = context.getString(R.string.wizard_permissions_title);
String msg = context.getString(R.string.wizard_permissions_no_root_msg);
setTitle(title);
TextView txtBody = ((TextView)findViewById(R.id.WizardTextBody1));
txtBody.setText(msg);
txtBody.setText(msg);
Button btn1 = ((Button)findViewById(R.id.btnWizard1));
Button btn2 = ((Button)findViewById(R.id.btnWizard2));
btn2.setEnabled(true);
TextView txtBody2 = ((TextView)findViewById(R.id.WizardTextBody2));
txtBody2.setVisibility(TextView.GONE);
Button grantPermissions = ((Button)findViewById(R.id.grantPermissions));
grantPermissions.setVisibility(Button.GONE);
txtBody2.setVisibility(TextView.GONE);
Button grantPermissions = ((Button)findViewById(R.id.grantPermissions));
grantPermissions.setVisibility(Button.GONE);
CheckBox consent = (CheckBox)findViewById(R.id.checkBox);
consent.setVisibility(CheckBox.GONE);
btn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
startActivity(new Intent(Permissions.this, LotsaText.class));
}
});
btn2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
startActivity(new Intent(Permissions.this, TipsAndTricks.class));
}
});
}
//Code to override the back button!
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK){
finish();
startActivity(new Intent(getBaseContext(), LotsaText.class));
return true;
}
return false;
}
btn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
startActivity(new Intent(Permissions.this, LotsaText.class));
}
});
btn2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
startActivity(new Intent(Permissions.this, TipsAndTricks.class));
}
});
}
//Code to override the back button!
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK){
finish();
startActivity(new Intent(getBaseContext(), LotsaText.class));
return true;
}
return false;
}
}

View File

@ -1,7 +1,7 @@
package org.torproject.android.wizard;
import org.sandroproxy.ony.R;
import org.torproject.android.Orbot;
import org.torproject.android.R;
import org.torproject.android.TorConstants;
import android.app.Activity;
@ -17,233 +17,229 @@ import android.widget.TextView;
public class TipsAndTricks extends Activity implements TorConstants {
protected void onCreate(Bundle savedInstanceState)
{
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
}
@Override
protected void onStart() {
super.onStart();
setContentView(R.layout.layout_wizard_tips);
stepFive();
}
@Override
protected void onStart() {
}
@Override
protected void onResume() {
super.onResume();
}
super.onStart();
setContentView(R.layout.layout_wizard_tips);
stepFive();
}
@Override
protected void onResume() {
super.onResume();
}
void stepFive(){
String title = getString(R.string.wizard_tips_title);
setTitle(title);
void stepFive(){
String title = getString(R.string.wizard_tips_title);
setTitle(title);
Button btnLink = (Button)findViewById(R.id.WizardRootButtonInstallGibberbot);
btnLink.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
public void onClick(View view) {
String url = getString(R.string.gibberbot_apk_url);
finish();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
String url = getString(R.string.gibberbot_apk_url);
finish();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}
});
}
});
btnLink = (Button)findViewById(R.id.WizardRootButtonInstallOrweb);
btnLink.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
String url = getString(R.string.orweb_apk_url);
finish();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
public void onClick(View view) {
String url = getString(R.string.orweb_apk_url);
finish();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}
});
}
});
btnLink = (Button)findViewById(R.id.WizardRootButtonInstallDuckgo);
btnLink.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
String url = getString(R.string.duckgo_apk_url);
finish();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
public void onClick(View view) {
String url = getString(R.string.duckgo_apk_url);
finish();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}
});
}
});
btnLink = (Button)findViewById(R.id.WizardRootButtonInstallFirefox);
btnLink.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
String url = getString(R.string.proxymob_setup_url);
finish();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
public void onClick(View view) {
String url = getString(R.string.proxymob_setup_url);
finish();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}
});
}
});
btnLink = (Button)findViewById(R.id.WizardRootButtonInstallTwitter);
btnLink.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
String url = getString(R.string.twitter_setup_url);
finish();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
public void onClick(View view) {
String url = getString(R.string.twitter_setup_url);
finish();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}
});
}
});
btnLink = (Button)findViewById(R.id.WizardRootButtonInstallStoryMaker);
btnLink.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
String url = getString(R.string.story_maker_url);
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
public void onClick(View view) {
String url = getString(R.string.story_maker_url);
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}
});
}
});
btnLink = (Button)findViewById(R.id.WizardRootButtonInstallMartus);
btnLink.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
String url = getString(R.string.martus_url);
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
public void onClick(View view) {
String url = getString(R.string.martus_url);
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}
});
}
});
btnLink = (Button)findViewById(R.id.WizardRootButtonGooglePlay);
btnLink.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
String url = getString(R.string.wizard_tips_play_url);
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
public void onClick(View view) {
String url = getString(R.string.wizard_tips_play_url);
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}
});
}
});
Button back = ((Button)findViewById(R.id.btnWizard1));
Button next = ((Button)findViewById(R.id.btnWizard2));
back.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
startActivityForResult(new Intent(TipsAndTricks.this, Permissions.class), 1);
}
});
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
showWizardFinal();
}
});
public void onClick(View v) {
finish();
startActivityForResult(new Intent(TipsAndTricks.this, Permissions.class), 1);
}
});
}
private void showWizardFinal ()
{
setContentView(R.layout.scrollingtext_buttons_view);
String title = getString(R.string.wizard_final);
String msg = getString(R.string.wizard_final_msg);
setTitle(title);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
showWizardFinal();
}
});
}
private void showWizardFinal ()
{
setContentView(R.layout.scrollingtext_buttons_view);
String title = getString(R.string.wizard_final);
String msg = getString(R.string.wizard_final_msg);
setTitle(title);
TextView txtBody = ((TextView)findViewById(R.id.WizardTextBody));
txtBody.setText(msg);
txtBody.setText(msg);
Button btn1 = ((Button)findViewById(R.id.btnWizard1));
Button btn2 = ((Button)findViewById(R.id.btnWizard2));
btn2.setText(getString(R.string.btn_finish));
btn1.setVisibility(Button.VISIBLE);
btn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
startActivity(new Intent(TipsAndTricks.this, Permissions.class));
}
});
btn2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
}
});
}
//Code to override the back button!
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK){
finish();
startActivity(new Intent(getBaseContext(), Permissions.class));
return true;
}
return false;
}
/*
private void showWizardFinal ()
{
String title = null;
String msg = null;
title = context.getString(R.string.wizard_final);
msg = context.getString(R.string.wizard_final_msg);
DialogInterface.OnClickListener ocListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
context.startActivity(new Intent(context, Orbot.class));
btn1.setVisibility(Button.VISIBLE);
btn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
startActivity(new Intent(TipsAndTricks.this, Permissions.class));
}
});
btn2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
}
});
}
//Code to override the back button!
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK){
finish();
startActivity(new Intent(getBaseContext(), Permissions.class));
return true;
}
return false;
}
/*
private void showWizardFinal ()
{
String title = null;
String msg = null;
title = context.getString(R.string.wizard_final);
msg = context.getString(R.string.wizard_final_msg);
DialogInterface.OnClickListener ocListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
context.startActivity(new Intent(context, Orbot.class));
}
};
new AlertDialog.Builder(context)
.setIcon(R.drawable.icon)
}
};
new AlertDialog.Builder(context)
.setIcon(R.drawable.icon)
.setTitle(title)
.setPositiveButton(R.string.button_close, ocListener)
.setMessage(msg)
.show();
}*/
}*/
}