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>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name> <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments> <arguments>
@ -30,10 +36,20 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature> <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</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> </natures>
</projectDescription> </projectDescription>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <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:versionName="14.1.4-noPIE"
android:versionCode="132" android:versionCode="132"
android:installLocation="auto" android:installLocation="auto"
@ -15,7 +15,7 @@
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/> <uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
<uses-permission android:name="org.torproject.android.MANAGE_TOR"/> <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:label="@string/app_name"
android:description="@string/app_description" android:description="@string/app_description"
android:configChanges="locale|orientation|screenSize" android:configChanges="locale|orientation|screenSize"
@ -27,7 +27,7 @@
android:largeHeap="false" android:largeHeap="false"
> >
<activity android:name=".Orbot" <activity android:name="org.torproject.android.Orbot"
android:configChanges="orientation|screenSize" android:configChanges="orientation|screenSize"
android:excludeFromRecents="true" android:excludeFromRecents="true"
android:launchMode="singleTop" android:launchMode="singleTop"
@ -77,7 +77,7 @@
<activity android:name=".OrbotDiagnosticsActivity" android:label="OrbotDiag"/> <activity android:name=".OrbotDiagnosticsActivity" android:label="OrbotDiag"/>
--> -->
<activity <activity
android:name=".service.DummyActivity" android:name="org.torproject.android.service.DummyActivity"
android:theme="@android:style/Theme.NoDisplay" android:theme="@android:style/Theme.NoDisplay"
android:enabled="true" android:enabled="true"
android:allowTaskReparenting="true" android:allowTaskReparenting="true"
@ -90,17 +90,17 @@
/> />
<activity android:name=".wizard.LotsaText" android:exported="false"/> <activity android:name="org.torproject.android.wizard.LotsaText" android:exported="false"/>
<activity android:name=".wizard.Permissions" android:exported="false"/> <activity android:name="org.torproject.android.wizard.Permissions" android:exported="false"/>
<activity android:name=".wizard.TipsAndTricks" android:exported="false"/> <activity android:name="org.torproject.android.wizard.TipsAndTricks" android:exported="false"/>
<activity android:name=".wizard.ConfigureTransProxy" android:exported="false"/> <activity android:name="org.torproject.android.wizard.ConfigureTransProxy" android:exported="false"/>
<activity android:name=".wizard.ChooseLocaleWizardActivity" android:exported="false"/> <activity android:name="org.torproject.android.wizard.ChooseLocaleWizardActivity" android:exported="false"/>
<activity android:name=".settings.SettingsPreferences" android:label="@string/app_name"/> <activity android:name="org.torproject.android.settings.SettingsPreferences" android:label="@string/app_name"/>
<activity android:name=".settings.AppManager" android:label="@string/app_name"/> <activity android:name="org.torproject.android.settings.AppManager" android:label="@string/app_name"/>
<service android:enabled="true" <service android:enabled="true"
android:name=".service.TorService" android:name="org.torproject.android.service.TorService"
android:permission="org.torproject.android.MANAGE_TOR" android:permission="org.torproject.android.MANAGE_TOR"
android:stopWithTask="false" android:stopWithTask="false"
> >
@ -110,7 +110,7 @@
</intent-filter> </intent-filter>
</service> </service>
<receiver android:name=".OnBootReceiver"> <receiver android:name="org.torproject.android.OnBootReceiver">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" /> <action android:name="android.intent.action.QUICKBOOT_POWERON" />

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. # user building this will have to manually set NDK_PROCESSOR or NDK_TOOLCHAIN.
CPU := $(shell uname -m) CPU := $(shell uname -m)
ifeq ($(CPU),x86_64) ifeq ($(CPU),x86_64)
NDK_PROCESSOR=x86_64 NDK_PROCESSOR=x86
else else
NDK_PROCESSOR=x86 NDK_PROCESSOR=x86
endif endif
# Android NDK setup # Android NDK setup
NDK_BASE ?= /opt/android-ndk NDK_BASE ?= /opt/android-ndk
NDK_PLATFORM_LEVEL ?= 9 NDK_PLATFORM_LEVEL ?= 19
NDK_ABI ?= arm NDK_ABI ?= arm
NDK_TOOLCHAIN_VERSION=4.8 NDK_TOOLCHAIN_VERSION=4.8
NDK_SYSROOT=$(NDK_BASE)/platforms/android-$(NDK_PLATFORM_LEVEL)/arch-$(NDK_ABI) NDK_SYSROOT=$(NDK_BASE)/platforms/android-$(NDK_PLATFORM_LEVEL)/arch-$(NDK_ABI)

View File

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

View File

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

View File

@ -65,11 +65,9 @@
yourapp:showAsAction="never" yourapp:showAsAction="never"
/> />
<!--
<item android:id="@+id/menu_vpn" <item android:id="@+id/menu_vpn"
android:title="@string/menu_vpn" android:title="@string/menu_vpn"
yourapp:showAsAction="never"/> yourapp:showAsAction="never"/>
-->
<item android:id="@+id/menu_exit" <item android:id="@+id/menu_exit"
android:title="@string/menu_exit" android:title="@string/menu_exit"

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<resources> <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="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="internal_web_url">http://orbot/</string>
<string name="default_web_url">http://check.torproject.org</string> <string name="default_web_url">http://check.torproject.org</string>

View File

@ -8,6 +8,7 @@ import static org.torproject.android.TorConstants.TAG;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.Locale; import java.util.Locale;
import org.sandroproxy.ony.R;
import org.torproject.android.service.TorService; import org.torproject.android.service.TorService;
import org.torproject.android.service.TorServiceConstants; import org.torproject.android.service.TorServiceConstants;
import org.torproject.android.service.TorServiceUtils; import org.torproject.android.service.TorServiceUtils;
@ -394,12 +395,10 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
} }
/**
* remove for now... VPN is not ready yet
else if (item.getItemId() == R.id.menu_vpn) else if (item.getItemId() == R.id.menu_vpn)
{ {
this.startVpnService(); this.startVpnService();
}*/ }
return true; return true;
} }
@ -1210,8 +1209,5 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
} }
return false; return false;
} }
} }
} }

View File

@ -7,6 +7,7 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.ArrayList;
import org.sandroproxy.ony.R;
import org.sufficientlysecure.rootcommands.Shell; import org.sufficientlysecure.rootcommands.Shell;
import org.sufficientlysecure.rootcommands.command.SimpleCommand; import org.sufficientlysecure.rootcommands.command.SimpleCommand;
import org.torproject.android.service.TorResourceInstaller; 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.ZipEntry;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
import org.sandroproxy.ony.R;
import org.sufficientlysecure.rootcommands.Shell; import org.sufficientlysecure.rootcommands.Shell;
import org.sufficientlysecure.rootcommands.command.SimpleCommand; import org.sufficientlysecure.rootcommands.command.SimpleCommand;
import org.torproject.android.R;
import org.torproject.android.TorConstants; import org.torproject.android.TorConstants;
import android.content.Context; import android.content.Context;

View File

@ -45,10 +45,10 @@ import net.freehaven.tor.control.TorControlConnection;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import org.sandroproxy.ony.R;
import org.sufficientlysecure.rootcommands.Shell; import org.sufficientlysecure.rootcommands.Shell;
import org.sufficientlysecure.rootcommands.command.SimpleCommand; import org.sufficientlysecure.rootcommands.command.SimpleCommand;
import org.torproject.android.Orbot; import org.torproject.android.Orbot;
import org.torproject.android.R;
import org.torproject.android.TorConstants; import org.torproject.android.TorConstants;
import org.torproject.android.Utils; import org.torproject.android.Utils;
import org.torproject.android.settings.AppManager; import org.torproject.android.settings.AppManager;
@ -362,66 +362,43 @@ public class TorService extends Service implements TorServiceConstants, TorConst
mIntent = intent; mIntent = intent;
} }
public void run () public void run (){
{ try{
try
{
//if this is a start on boot launch turn tor on //if this is a start on boot launch turn tor on
if (mIntent != null) if (mIntent != null){
{
String action = mIntent.getAction(); String action = mIntent.getAction();
if (action!=null) if (action!=null){
{ if(action.equals(Intent.ACTION_BOOT_COMPLETED)||action.equals(CMD_START)){
if(action.equals(Intent.ACTION_BOOT_COMPLETED)||action.equals(CMD_START))
{
setTorProfile(STATUS_ON); setTorProfile(STATUS_ON);
} }else if (action.equals(CMD_STOP)){
else if (action.equals(CMD_STOP))
{
setTorProfile(STATUS_OFF); setTorProfile(STATUS_OFF);
} }else if (action.equals(CMD_INIT)){
else if (action.equals(CMD_INIT))
{
initialize(); initialize();
sendCallbackStatus(mCurrentStatus); sendCallbackStatus(mCurrentStatus);
} }else if (action.equals(CMD_NEWNYM)){
else if (action.equals(CMD_NEWNYM))
{
newIdentity(); newIdentity();
} }else if (action.equals(CMD_FLUSH)){
else if (action.equals(CMD_FLUSH))
{
flushTransparentProxyRules(); flushTransparentProxyRules();
} }else if (action.equals(CMD_UPDATE)){
else if (action.equals(CMD_UPDATE))
{
processSettings(); processSettings();
} }else if (action.equals(CMD_VPN)){
else if (action.equals(CMD_VPN))
{
startVpnService(); startVpnService();
} }
} }
} }else{
else
{
Log.d(TAG, "Got null onStartCommand() intent"); Log.d(TAG, "Got null onStartCommand() intent");
} }
} }catch (Exception e){
catch (Exception e)
{
Log.e(TAG,"error onBind",e); Log.e(TAG,"error onBind",e);
} }
} }
} }
@Override @Override
public void onTaskRemoved(Intent rootIntent) { public void onTaskRemoved(Intent rootIntent){
Log.d(TAG,"task removed"); Log.d(TAG,"task removed");
Intent intent = new Intent( this, DummyActivity.class ); Intent intent = new Intent( this, DummyActivity.class );
intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK ); intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
startActivity( intent ); startActivity( intent );
@ -429,27 +406,19 @@ public class TorService extends Service implements TorServiceConstants, TorConst
@Override @Override
public boolean stopService(Intent name) { public boolean stopService(Intent name) {
logNotice("TorService is being stopped: " + name); logNotice("TorService is being stopped: " + name);
return super.stopService(name); return super.stopService(name);
} }
@Override @Override
public void onDestroy () public void onDestroy ()
{ {
String msg = ("TorService is being DESTROYED... shutting down!"); String msg = ("TorService is being DESTROYED... shutting down!");
Log.d(TAG, msg); Log.d(TAG, msg);
sendCallbackLogMessage(msg); sendCallbackLogMessage(msg);
unregisterReceiver(mNetworkStateReceiver); unregisterReceiver(mNetworkStateReceiver);
clearNotifications (); clearNotifications ();
super.onDestroy(); super.onDestroy();
} }
private void stopTor () private void stopTor ()
@ -1783,69 +1752,46 @@ public class TorService extends Service implements TorServiceConstants, TorConst
public void processSettings () public void processSettings (){
{ try{
try {
boolean hadEnableTransparentProxy = mEnableTransparentProxy; boolean hadEnableTransparentProxy = mEnableTransparentProxy;
updateSettings (); updateSettings ();
if (mHasRoot) if (mHasRoot)
{ {
Shell shell = Shell.startRootShell(); Shell shell = Shell.startRootShell();
if (hadEnableTransparentProxy){
if (hadEnableTransparentProxy)
disableTransparentProxy(shell); disableTransparentProxy(shell);
}
if (mEnableTransparentProxy) if (mEnableTransparentProxy){
enableTransparentProxy(shell); enableTransparentProxy(shell);
}
shell.close(); shell.close();
} }
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
Thread thread = new Thread() Thread thread = new Thread(){
{ public void run (){
public void run ()
{
try { try {
processSettingsImpl();
processSettingsImpl ();
} catch (Exception e) { } catch (Exception e) {
logException ("error applying mPrefs",e); logException ("error applying mPrefs",e);
} }
} }
}; };
thread.start(); thread.start();
} }
public String getInfo (String key) { public String getInfo (String key) {
try try {
{ if(conn !=null){
if(conn !=null)
{
String m = conn.getInfo(key); String m = conn.getInfo(key);
return m; return m;
} }
} }
catch(Exception ioe) catch(Exception ioe){
{
// Log.e(TAG,"Unable to get Tor information",ioe); // Log.e(TAG,"Unable to get Tor information",ioe);
logNotice("Unable to get Tor information"+ioe.getMessage()); logNotice("Unable to get Tor information"+ioe.getMessage());
} }
@ -2398,7 +2344,6 @@ public class TorService extends Service implements TorServiceConstants, TorConst
private void blockPlaintextPorts (String portList) throws RemoteException private void blockPlaintextPorts (String portList) throws RemoteException
{ {
updateConfiguration("RejectPlaintextPorts",portList,false); updateConfiguration("RejectPlaintextPorts",portList,false);
} }

View File

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

View File

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

View File

@ -20,23 +20,36 @@ import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.Locale; 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 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.annotation.TargetApi;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.VpnService; import android.net.VpnService;
import android.os.Build; import android.os.Build;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor;
import android.support.v4.app.NotificationCompat;
import android.util.Log; import android.util.Log;
import android.widget.RemoteViews;
import android.widget.Toast; import android.widget.Toast;
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public class OrbotVpnService extends VpnService implements Handler.Callback { public class OrbotVpnService extends VpnService implements Handler.Callback {
private static final String TAG = "OrbotVpnService"; private static final String TAG = "DrobotVpnService";
private PendingIntent mConfigureIntent; private PendingIntent mConfigureIntent;
@ -48,10 +61,24 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
private ParcelFileDescriptor mInterface; private ParcelFileDescriptor mInterface;
private int mSocksProxyPort = 9999; private int mSocksProxyPort = 9999;
// private ProxyServer mProxyServer; private ProxyServer mProxyServer;
private final static int VPN_MTU = 1500; 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 @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
@ -71,16 +98,31 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
return START_STICKY; 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 @Override
public void onDestroy() { public void onDestroy() {
if (mProxyServer != null){
mProxyServer.stop();
}
if (mInterface != null) if (mInterface != null){
try { try {
mInterface.close(); mInterface.close();
} catch (IOException e) { } catch (IOException e) {
@ -88,6 +130,7 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
e.printStackTrace(); e.printStackTrace();
} }
} }
}
@Override @Override
public boolean handleMessage(Message message) { public boolean handleMessage(Message message) {
@ -117,13 +160,11 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
Builder builder = new Builder(); Builder builder = new Builder();
builder.setMtu(VPN_MTU); builder.setMtu(VPN_MTU);
builder.addAddress("10.0.0.1",8); builder.addAddress("10.0.0.1",28);
builder.setSession("OrbotVPN"); builder.setSession("DrobotVPN");
builder.addRoute("0.0.0.0",0); builder.addRoute("0.0.0.0",0);
builder.addRoute("10.0.0.0",8);
//builder.addRoute("192.0.0.0",8); //builder.addRoute("192.0.0.0",8);
//builder.addRoute("192.168.43.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. // Create a new interface using the builder and save the parameters.
mInterface = builder.setSession(mSessionName) mInterface = builder.setSession(mSessionName)
@ -132,7 +173,14 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
try 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); 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) catch (Exception e)
{ {
@ -141,8 +189,8 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
} }
} }
}; };
mThreadVPN.start(); mThreadVPN.start();
showToolbarNotification(getString(R.string.status_activated), NOTIFY_ID, R.drawable.ic_stat_tor);
} }
@Override @Override
@ -163,89 +211,90 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
} }
} }
}.start(); }.start();
clearNotifications();
super.onRevoke(); super.onRevoke();
}
private void clearNotifications()
{
if (mNotificationManager != null)
mNotificationManager.cancelAll();
mNotificationShowing = false;
} }
/*
private void debugPacket(ByteBuffer packet) @SuppressLint("NewApi")
private void showToolbarNotification (String notifyMsg, int notifyType, int icon)
{ {
int buffer = packet.get(); //Reusable code.
int version; Intent intent = new Intent(OrbotVpnService.this, Orbot.class);
int headerlength; PendingIntent pendIntent = PendingIntent.getActivity(OrbotVpnService.this, 0, intent, 0);
version = buffer >> 4;
headerlength = buffer & 0x0F;
headerlength *= 4;
Log.d(TAG, "IP Version:"+version);
Log.d(TAG, "Header Length:"+headerlength);
String status = ""; if (mNotifyBuilder == null)
status += "Header Length:"+headerlength; {
buffer = packet.get(); //DSCP + EN mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
buffer = packet.getChar(); //Total Length
Log.d(TAG, "Total Length:"+buffer); if (mNotifyBuilder == null)
{
mNotifyBuilder = new NotificationCompat.Builder(this)
.setContentTitle(getString(R.string.app_name))
.setSmallIcon(R.drawable.ic_stat_tor);
mNotifyBuilder.setContentIntent(pendIntent);
}
}
buffer = packet.getChar(); //Identification mNotifyBuilder.setContentText(notifyMsg);
Log.d(TAG, "Identification:"+buffer); mNotifyBuilder.setSmallIcon(icon);
buffer = packet.getChar(); //Flags + Fragment Offset if (notifyType != NOTIFY_ID)
buffer = packet.get(); //Time to Live {
buffer = packet.get(); //Protocol mNotifyBuilder.setTicker(notifyMsg);
// mNotifyBuilder.setLights(Color.GREEN, 1000, 1000);
}
else
{
mNotifyBuilder.setTicker(null);
}
Log.d(TAG, "Protocol:"+buffer); mNotifyBuilder.setOngoing(prefPersistNotifications);
status += " Protocol:"+buffer; mNotification = mNotifyBuilder.build();
buffer = packet.getChar(); //Header checksum if (Build.VERSION.SDK_INT >= 16 && mShowExpandedNotifications) {
String sourceIP = "";
buffer = packet.get(); //Source IP 1st Octet
sourceIP += buffer;
sourceIP += ".";
buffer = packet.get(); //Source IP 2nd Octet // Create remote view that needs to be set as bigContentView for the notification.
sourceIP += buffer; RemoteViews expandedView = new RemoteViews(this.getPackageName(),
sourceIP += "."; R.layout.layout_notification_expanded);
buffer = packet.get(); //Source IP 3rd Octet StringBuffer sbInfo = new StringBuffer();
sourceIP += buffer;
sourceIP += ".";
buffer = packet.get(); //Source IP 4th Octet
sourceIP += buffer;
Log.d(TAG, "Source IP:"+sourceIP); if (notifyType == NOTIFY_ID)
expandedView.setTextViewText(R.id.text, notifyMsg);
else
{
expandedView.setTextViewText(R.id.info, notifyMsg);
status += " Source IP:"+sourceIP; }
expandedView.setTextViewText(R.id.title, getString(R.string.app_name));
String destIP = ""; expandedView.setImageViewResource(R.id.icon, icon);
buffer = packet.get(); //Destination IP 1st Octet mNotification.bigContentView = expandedView;
destIP += buffer; }
destIP += ".";
buffer = packet.get(); //Destination IP 2nd Octet if (prefPersistNotifications && (!mNotificationShowing))
destIP += buffer; {
destIP += "."; startForeground(NOTIFY_ID, mNotification);
}
buffer = packet.get(); //Destination IP 3rd Octet else
destIP += buffer; {
destIP += "."; mNotificationManager.notify(NOTIFY_ID, mNotification);
}
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());
}*/
mNotificationShowing = true;
}
} }

View File

@ -25,6 +25,7 @@ import java.net.Socket;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.os.Build; import android.os.Build;
import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor;
import android.util.Log;
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
public class Tun2Socks public class Tun2Socks
@ -35,6 +36,8 @@ public class Tun2Socks
boolean doVpnProtect(DatagramSocket socket); boolean doVpnProtect(DatagramSocket socket);
}; };
private static final String TAG = Tun2Socks.class.getSimpleName();
private static final boolean LOGD = true;
private static Thread mThread; private static Thread mThread;
private static ParcelFileDescriptor mVpnInterfaceFileDescriptor; private static ParcelFileDescriptor mVpnInterfaceFileDescriptor;
@ -84,8 +87,6 @@ public class Tun2Socks
mSocksServerAddress, mSocksServerAddress,
mUdpgwServerAddress, mUdpgwServerAddress,
mUdpgwTransparentDNS ? 1 : 0); mUdpgwTransparentDNS ? 1 : 0);
} }
public static void Stop() public static void Stop()
@ -95,6 +96,22 @@ public class Tun2Socks
} }
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( private native static int runTun2Socks(
int vpnInterfaceFileDescriptor, int vpnInterfaceFileDescriptor,
int vpnInterfaceMTU, int vpnInterfaceMTU,

View File

@ -2,7 +2,7 @@ package org.torproject.android.wizard;
import java.util.Locale; import java.util.Locale;
import org.torproject.android.R; import org.sandroproxy.ony.R;
import org.torproject.android.TorConstants; import org.torproject.android.TorConstants;
import org.torproject.android.service.TorServiceUtils; import org.torproject.android.service.TorServiceUtils;

View File

@ -1,12 +1,8 @@
package org.torproject.android.wizard; package org.torproject.android.wizard;
import org.sandroproxy.ony.R;
import org.torproject.android.Orbot; import org.torproject.android.Orbot;
import org.torproject.android.R;
import org.torproject.android.TorConstants; 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.service.TorServiceUtils;
import org.torproject.android.settings.AppManager; import org.torproject.android.settings.AppManager;

View File

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

View File

@ -1,7 +1,7 @@
package org.torproject.android.wizard; package org.torproject.android.wizard;
import org.sandroproxy.ony.R;
import org.sufficientlysecure.rootcommands.RootCommands; import org.sufficientlysecure.rootcommands.RootCommands;
import org.torproject.android.R;
import org.torproject.android.TorConstants; import org.torproject.android.TorConstants;
import org.torproject.android.service.TorServiceUtils; import org.torproject.android.service.TorServiceUtils;

View File

@ -1,7 +1,7 @@
package org.torproject.android.wizard; package org.torproject.android.wizard;
import org.sandroproxy.ony.R;
import org.torproject.android.Orbot; import org.torproject.android.Orbot;
import org.torproject.android.R;
import org.torproject.android.TorConstants; import org.torproject.android.TorConstants;
import android.app.Activity; import android.app.Activity;
@ -241,9 +241,5 @@ public class TipsAndTricks extends Activity implements TorConstants {
.setPositiveButton(R.string.button_close, ocListener) .setPositiveButton(R.string.button_close, ocListener)
.setMessage(msg) .setMessage(msg)
.show(); .show();
}*/ }*/
} }