multiple fixes to re-enable VPN mode and pdnsd daemon

This commit is contained in:
Nathan Freitas 2016-10-12 16:01:09 -04:00
parent ca238c6521
commit da0fb101f3
10 changed files with 193 additions and 191 deletions

View File

@ -16,10 +16,9 @@ public class OnBootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Prefs.setContext(context);
if (Prefs.startOnBoot() && (!sReceivedBoot))
{
if (Prefs.useVpn())
startVpnService(context); //VPN will start Tor once it is done
else

View File

@ -52,6 +52,7 @@ import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SwitchCompat;
import android.support.v7.widget.Toolbar;
import android.util.AttributeSet;
import android.util.Log;
@ -70,10 +71,10 @@ import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
@ -89,9 +90,9 @@ public class OrbotMainActivity extends AppCompatActivity
private TextView uploadText = null;
private TextView mTxtOrbotLog = null;
private Button mBtnBrowser = null;
private ToggleButton mBtnVPN = null;
private ToggleButton mBtnBridges = null;
// private Button mBtnBrowser = null;
private SwitchCompat mBtnVPN = null;
private SwitchCompat mBtnBridges = null;
private Spinner spnCountries = null;
@ -257,7 +258,7 @@ public class OrbotMainActivity extends AppCompatActivity
// Gesture detection
mGestureDetector = new GestureDetector(this, new MyGestureDetector());
/**
mBtnBrowser = (Button)findViewById(R.id.btnBrowser);
mBtnBrowser.setOnClickListener(new View.OnClickListener ()
{
@ -271,8 +272,9 @@ public class OrbotMainActivity extends AppCompatActivity
});
mBtnBrowser.setEnabled(false);
*/
mBtnVPN = (ToggleButton)findViewById(R.id.btnVPN);
mBtnVPN = (SwitchCompat)findViewById(R.id.btnVPN);
boolean canDoVPN = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH;
@ -292,24 +294,23 @@ public class OrbotMainActivity extends AppCompatActivity
startActivity(new Intent(OrbotMainActivity.this,VPNEnableActivity.class));
}
mBtnVPN.setOnClickListener(new View.OnClickListener ()
{
mBtnVPN.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
if (isChecked)
startActivity(new Intent(OrbotMainActivity.this,VPNEnableActivity.class));
else
stopVpnService();
}
});
@Override
public void onClick(View v) {
if (mBtnVPN.isChecked())
startActivity(new Intent(OrbotMainActivity.this,VPNEnableActivity.class));
else
stopVpnService();
}
});
}
mBtnBridges = (ToggleButton)findViewById(R.id.btnBridges);
mBtnBridges = (SwitchCompat)findViewById(R.id.btnBridges);
mBtnBridges.setChecked(Prefs.bridgesEnabled());
mBtnBridges.setOnClickListener(new View.OnClickListener ()
{
@ -323,7 +324,6 @@ public class OrbotMainActivity extends AppCompatActivity
}
else
{
Toast.makeText(OrbotMainActivity.this, R.string.note_only_standard_tor_bridges_work_on_intel_x86_atom_devices, Toast.LENGTH_LONG).show();
showGetBridgePrompt(""); //if other chip ar, only stock bridges are supported
}
}
@ -1063,11 +1063,7 @@ public class OrbotMainActivity extends AppCompatActivity
protected void onResume() {
super.onResume();
if (mPrefs != null)
{
mBtnVPN.setChecked(Prefs.useVpn());
mBtnBridges.setChecked(Prefs.bridgesEnabled());
}
mBtnBridges.setChecked(Prefs.bridgesEnabled());
requestTorStatus();
@ -1124,7 +1120,7 @@ public class OrbotMainActivity extends AppCompatActivity
imgStatus.setImageResource(R.drawable.toron);
mBtnBrowser.setEnabled(true);
//mBtnBrowser.setEnabled(true);
if (torServiceMsg != null)
{
@ -1170,7 +1166,7 @@ public class OrbotMainActivity extends AppCompatActivity
else
lblStatus.setText(getString(R.string.status_starting_up));
mBtnBrowser.setEnabled(false);
// mBtnBrowser.setEnabled(false);
} else if (torStatus == TorServiceConstants.STATUS_STOPPING) {
@ -1179,13 +1175,13 @@ public class OrbotMainActivity extends AppCompatActivity
imgStatus.setImageResource(R.drawable.torstarting);
lblStatus.setText(torServiceMsg);
mBtnBrowser.setEnabled(false);
// mBtnBrowser.setEnabled(false);
} else if (torStatus == TorServiceConstants.STATUS_OFF) {
imgStatus.setImageResource(R.drawable.toroff);
lblStatus.setText(getString(R.string.press_to_start));
mBtnBrowser.setEnabled(false);
// mBtnBrowser.setEnabled(false);
}
if (torServiceMsg != null && torServiceMsg.length() > 0)

View File

@ -71,7 +71,6 @@ public class VPNEnableActivity extends Activity {
@Override
public void onClick(DialogInterface dialog, int which) {
Prefs.putUseVpn(true);
startVpnService();
}

View File

@ -31,91 +31,6 @@
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<!--
<TextView android:id="@+id/lblStatus"
android:text="status status status"
android:gravity="center_horizontal"
android:textSize="20sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:textColor="#ffffff"
android:maxLines="1"
android:fontFamily="sans-serif-light"
/>
-->
<RelativeLayout
android:id="@+id/rowTrafficDown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="3sp"
android:paddingRight="3sp"
>
<TextView
android:id="@+id/trafficLabelDown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textSize="15sp"
android:text="@string/main_layout_download"
android:gravity="center_vertical"
android:fontFamily="sans-serif-light" />
<TextView
android:id="@+id/trafficLabelUp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="@string/main_layout_upload"
android:textSize="15sp"
android:gravity="center_vertical"
android:fontFamily="sans-serif-light" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/rowTrafficUp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="3sp"
android:paddingRight="3sp"
android:paddingBottom="3sp"
>
<TextView
android:id="@+id/trafficDown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textSize="15sp"
android:gravity="center_vertical"
android:fontFamily="sans-serif-light"
/>
<TextView
android:id="@+id/trafficUp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textSize="15sp"
android:gravity="center_vertical"
android:fontFamily="sans-serif-light"
/>
</RelativeLayout>
</LinearLayout>
<ProgressBar
android:id="@+id/pbConnecting"
@ -138,10 +53,9 @@ android:layout_gravity="center_horizontal|center_vertical"/>
<org.torproject.android.ui.ImageProgressView
android:id="@+id/imgStatus"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".8"
android:layout_height="275dp"
android:padding="0dp"
android:padding="0dp"
android:layout_margin="0dp"
android:src="@drawable/toroff" />
@ -165,9 +79,9 @@ android:layout_gravity="center_horizontal|center_vertical"/>
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
>
<!--
<Button
android:id="@+id/btnBrowser"
android:layout_width="wrap_content"
@ -177,44 +91,129 @@ android:layout_gravity="center_horizontal|center_vertical"/>
android:layout_marginBottom="3dp"
android:ellipsize="end"
android:singleLine="true"
/>
/>-->
<ToggleButton
<android.support.v7.widget.SwitchCompat
android:id="@+id/btnVPN"
android:layout_width="wrap_content"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:textOff="@string/menu_vpn"
android:textOn="@string/menu_vpn"
android:text="@string/menu_vpn"
android:layout_margin="3dp"
android:ellipsize="end"
android:singleLine="true"
/>
<ToggleButton
<android.support.v7.widget.SwitchCompat
android:id="@+id/btnBridges"
android:layout_width="wrap_content"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:textOff="@string/bridges"
android:textOn="@string/bridges"
android:text="@string/bridges"
android:layout_marginTop="3dp"
android:layout_marginLeft="25dp"
android:layout_marginBottom="3dp"
android:ellipsize="end"
android:singleLine="true"
/>
<Spinner
android:id="@+id/spinnerCountry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>
</LinearLayout>
<Spinner
android:id="@+id/spinnerCountry"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom"
android:padding="6dp"
>
<!--
<TextView android:id="@+id/lblStatus"
android:text="status status status"
android:gravity="center_horizontal"
android:textSize="20sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:textColor="#ffffff"
android:maxLines="1"
android:fontFamily="sans-serif-light"
/>
-->
<RelativeLayout
android:id="@+id/rowTrafficDown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="3sp"
android:paddingRight="3sp"
>
<TextView
android:id="@+id/trafficLabelDown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textSize="15sp"
android:text="@string/main_layout_download"
android:gravity="center_vertical"
android:fontFamily="sans-serif-light" />
<TextView
android:id="@+id/trafficLabelUp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="@string/main_layout_upload"
android:textSize="15sp"
android:gravity="center_vertical"
android:fontFamily="sans-serif-light" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/rowTrafficUp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="3sp"
android:paddingRight="3sp"
android:paddingBottom="3sp"
>
<TextView
android:id="@+id/trafficDown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textSize="15sp"
android:gravity="center_vertical"
android:fontFamily="sans-serif-light"
/>
<TextView
android:id="@+id/trafficUp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textSize="15sp"
android:gravity="center_vertical"
android:fontFamily="sans-serif-light"
/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout

2
external/Makefile vendored
View File

@ -314,7 +314,7 @@ assets: tor polipo iptables pluto
-zip ../orbotservice/src/main/assets/$(APP_ABI)/xtables.mp3 bin/xtables
-$(STRIP) bin/obfs4proxy
-zip ../orbotservice/src/main/assets/$(APP_ABI)/obfs4proxy.mp3 bin/obfs4proxy
-$(STRIP) ../app/src/main/libs/$(APP_ABI)/pdnsd
-$(STRIP) ../orbotservice/src/main/libs/$(APP_ABI)/pdnsd
-zip ../orbotservice/src/main/assets/$(APP_ABI)/pdnsd.mp3 ../orbotservice/src/main/libs/$(APP_ABI)/pdnsd
-rm ../orbotservice/src/main/libs/$(APP_ABI)/pdnsd

View File

@ -121,7 +121,6 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
public static File fileObfsclient;
public static File fileXtables;
public static File fileTorRc;
public static File filePdnsd;
public void debug(String msg)
@ -227,8 +226,11 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
}
mNotifyBuilder.setOngoing(Prefs.persistNotifications());
mNotifyBuilder.setPriority(Notification.PRIORITY_LOW);
mNotifyBuilder.setCategory(Notification.CATEGORY_SERVICE);
mNotification = mNotifyBuilder.build();
mNotification = mNotifyBuilder.build();
if (Build.VERSION.SDK_INT >= 16 && Prefs.expandedNotifications()) {
// Create remote view that needs to be set as bigContentView for the notification.
@ -531,7 +533,6 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
fileObfsclient = new File(appBinHome, TorServiceConstants.OBFSCLIENT_ASSET_KEY);
fileXtables = new File(appBinHome, TorServiceConstants.IPTABLES_ASSET_KEY);
fileTorRc = new File(appBinHome, TorServiceConstants.TORRC_ASSET_KEY);
filePdnsd = new File(appBinHome, TorServiceConstants.PDNSD_ASSET_KEY);
mEventHandler = new TorEventHandler(this);
@ -726,7 +727,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
// these states should probably be handled better
sendCallbackLogMessage("Ignoring start request, currently " + mCurrentStatus);
return;
} else if (mCurrentStatus == STATUS_ON && findExistingTorDaemon()) {
} else if (mCurrentStatus == STATUS_ON) {
sendCallbackLogMessage("Ignoring start request, already started.");
@ -1444,7 +1445,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
@Override
public void onReceive(Context context, Intent intent) {
if (mCurrentStatus != STATUS_ON)
if (mCurrentStatus == STATUS_OFF)
return;
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
@ -1492,31 +1493,28 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
showToolbarNotification(getString(R.string.status_activated),NOTIFY_ID,R.drawable.ic_stat_tor);
}
//is this a change in state?
if (isChanged)
{
try {
try {
if (mCurrentStatus != STATUS_OFF)
{
if (mConnectivity)
{
if (Prefs.useRoot() && Prefs.useTransparentProxying() && Prefs.transProxyNetworkRefresh())
{
if (mCurrentStatus != STATUS_OFF)
{
if (mConnectivity)
{
if (Prefs.useRoot() && Prefs.useTransparentProxying() && Prefs.transProxyNetworkRefresh())
{
disableTransparentProxy();
enableTransparentProxy();
disableTransparentProxy();
enableTransparentProxy();
}
}
}
}
}
}
} catch (Exception e) {
logException ("error updating state after network restart",e);
}
} catch (Exception e) {
logException ("error updating state after network restart",e);
}
}
}

View File

@ -134,8 +134,7 @@ public interface TorServiceConstants {
public static final String CMD_SET_EXIT = "setexit";
public static final String BINARY_TOR_VERSION = "0.2.7.5-020120160125";
public static final String BINARY_TOR_VERSION = "0.2.8.1-1";
public static final String PREF_BINARY_TOR_VERSION_INSTALLED = "BINARY_TOR_VERSION_INSTALLED";
//obfsproxy

View File

@ -86,7 +86,9 @@ public class OrbotVpnManager implements Handler.Callback {
public OrbotVpnManager (VpnService service)
{
mService = service;
filePdnsd = mService.getDir(TorServiceConstants.DIRECTORY_TOR_BINARY, Application.MODE_PRIVATE);
File fileBinHome = mService.getDir(TorServiceConstants.DIRECTORY_TOR_BINARY, Application.MODE_PRIVATE);
filePdnsd = new File(fileBinHome,TorServiceConstants.PDNSD_ASSET_KEY);
}
@ -429,6 +431,17 @@ public class OrbotVpnManager implements Handler.Callback {
//f.withWriter { out -> out.print conf };
/**
*
server {
label= "upstream";
ip = %s;
port = %d;
uptest = none;
}
*/
File cache = new File(fileDir,"pdnsd.cache");

View File

@ -1,5 +1,4 @@
#APP_ABI := armeabi x86
APP_ABI := armeabi
APP_PLATFORM := android-14
APP_PLATFORM := android-16
APP_STL := stlport_static
NDK_TOOLCHAIN_VERSION := 4.8

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="pdnsd_conf" formatted="false">
<string name="pdnsd_conf" formatted="true">
global {
perm_cache=0;
cache_dir="/data/data/org.torproject.android/app_bin";
@ -17,8 +17,8 @@ global {
server {
label= "upstream";
ip = %s;
port = %d;
ip = %1$s;
port = %2$d;
uptest = none;
}