From 82940714ebe944e63ed70c745e1abe950673fe5b Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Fri, 11 May 2012 01:17:01 +0200 Subject: CLeanups Fix backtrace from market console, I suspect someone tried IPv6 and I failed him/her :( --- AndroidManifest.xml | 5 ++-- res/values/strings.xml | 3 +- src/de/blinkt/openvpn/MainActivity.java | 2 -- src/de/blinkt/openvpn/OpenVPN.java | 33 ++-------------------- src/de/blinkt/openvpn/OpenVPNThread.java | 6 +--- src/de/blinkt/openvpn/OpenVpnService.java | 18 ++++++++---- src/de/blinkt/openvpn/Settings_Authentication.java | 3 +- todo.txt | 8 ++---- 8 files changed, 24 insertions(+), 54 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 61c5f585..8943334a 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -17,8 +17,8 @@ + android:versionCode="24" + android:versionName="0.5.3" > @@ -29,7 +29,6 @@ - Import Error importing File Could not import File from Filesystem - [[Inline file data]] + [[Inline file data]] + Refusing to open tun device without IP information diff --git a/src/de/blinkt/openvpn/MainActivity.java b/src/de/blinkt/openvpn/MainActivity.java index 86c1d73f..d9169284 100644 --- a/src/de/blinkt/openvpn/MainActivity.java +++ b/src/de/blinkt/openvpn/MainActivity.java @@ -10,8 +10,6 @@ public class MainActivity extends PreferenceActivity { @Override public void onBuildHeaders(List
target) { loadHeadersFromResource(R.xml.main_headers, target); - //debug - OpenVPN.foo(); } @Override diff --git a/src/de/blinkt/openvpn/OpenVPN.java b/src/de/blinkt/openvpn/OpenVPN.java index 71df887f..24281d13 100644 --- a/src/de/blinkt/openvpn/OpenVPN.java +++ b/src/de/blinkt/openvpn/OpenVPN.java @@ -4,15 +4,11 @@ import java.util.LinkedList; import java.util.Vector; public class OpenVPN { - private static OpenVpnService mOpenVpnService; - private static final int MAXLOGENTRIES = 500; - //public static native int startOpenVPNThreadArgs(String argv[]); - private static final String TAG = "OpenVpn"; + private static final int MAXLOGENTRIES = 200; public static LinkedList logbuffer = new LinkedList(); - private static int counter=0; - + private static Vector logListener=new Vector(); private static String[] mBconfig; @@ -20,27 +16,13 @@ public class OpenVPN { void newLog(String logmessage); } - /* - static { - System.loadLibrary("crypto"); - System.loadLibrary("ssl"); - System.loadLibrary("lzo"); - System.loadLibrary("openvpn"); - }*/ synchronized static void logMessage(int level,String prefix, String message) { logbuffer.addLast(prefix + message); if(logbuffer.size()>MAXLOGENTRIES) logbuffer.removeFirst(); - - // The garbage collector does not collect the String from native - // but kills me for logging 100 messages with too many references :( - // Force GC how and then to kill loose ends - if(counter++ % 50==0) { - //System.gc(); - } - + for (LogListener ll : logListener) { ll.newLog(prefix + message); } @@ -60,15 +42,6 @@ public class OpenVPN { } - - - public static void setCallback(OpenVpnService openVpnService) { - mOpenVpnService = openVpnService; - } - - //! Dummy method being called to force loading of JNI Libraries - public static void foo() { } - synchronized public static String[] getlogbuffer() { // The stoned way of java to return an array from a vector diff --git a/src/de/blinkt/openvpn/OpenVPNThread.java b/src/de/blinkt/openvpn/OpenVPNThread.java index a24abb8b..ce332677 100644 --- a/src/de/blinkt/openvpn/OpenVPNThread.java +++ b/src/de/blinkt/openvpn/OpenVPNThread.java @@ -27,11 +27,7 @@ public class OpenVPNThread implements Runnable { @Override public void run() { try { - Log.i(TAG, "Starting o"); - - - OpenVPN.setCallback(mService); - + Log.i(TAG, "Starting openvpn"); // We try to create the tunnel for several times. The better way // is to work with ConnectivityManager, such as trying only when diff --git a/src/de/blinkt/openvpn/OpenVpnService.java b/src/de/blinkt/openvpn/OpenVpnService.java index 9030d29a..ad20737b 100644 --- a/src/de/blinkt/openvpn/OpenVpnService.java +++ b/src/de/blinkt/openvpn/OpenVpnService.java @@ -45,7 +45,7 @@ public class OpenVpnService extends VpnService implements Handler.Callback { private Vector mRoutes=new Vector(); - private CIDRIP mLocalIP; + private CIDRIP mLocalIP=null; private OpenVpnManagementThread mSocketManager; @@ -253,7 +253,12 @@ public class OpenVpnService extends VpnService implements Handler.Callback { public ParcelFileDescriptor openTun() { Builder builder = new Builder(); - + + if(mLocalIP==null) { + OpenVPN.logMessage(0, "", getString(R.string.opentun_no_ipaddr)); + return null; + } + builder.addAddress(mLocalIP.mIp, mLocalIP.len); for (String dns : mDnslist ) { @@ -282,15 +287,16 @@ public class OpenVpnService extends VpnService implements Handler.Callback { bconfig[3] = String.format(getString(R.string.dns_domain_info, mDomain)); bconfig[4] = String.format(getString(R.string.routes_info, joinString(mRoutes))); + builder.setSession(mProfile.mName + " - " + mLocalIP); + OpenVPN.logBuilderConfig(bconfig); + // Reset information mDnslist.clear(); mRoutes.clear(); - - - builder.setSession(mProfile.mName + " - " + mLocalIP); - + mLocalIP=null; + // Let the configure Button show the Log Intent intent = new Intent(getBaseContext(),LogWindow.class); PendingIntent startLW = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0); diff --git a/src/de/blinkt/openvpn/Settings_Authentication.java b/src/de/blinkt/openvpn/Settings_Authentication.java index 003a26dd..5849923d 100644 --- a/src/de/blinkt/openvpn/Settings_Authentication.java +++ b/src/de/blinkt/openvpn/Settings_Authentication.java @@ -106,7 +106,7 @@ public class Settings_Authentication extends PreferenceFragment implements OnPre return true; } void startFileDialog() { - Intent startFC = new Intent(getActivity(),FileSelectionFragment.class); + Intent startFC = new Intent(getActivity(),FileSelect.class); startFC.putExtra(FileSelect.START_DATA, "/sdcard"); startActivityForResult(startFC,SELECT_TLS_FILE); @@ -130,6 +130,7 @@ public class Settings_Authentication extends PreferenceFragment implements OnPre } private void setTlsAuthSummary(String result) { + if(result==null) result = getString(R.string.no_certificate); if(result.startsWith(FileSelect.INLINE_TAG)) mTLSAuthFile.setSummary(R.string.inline_file_data); else diff --git a/todo.txt b/todo.txt index 49fc9a8b..fc604ce2 100644 --- a/todo.txt +++ b/todo.txt @@ -1,9 +1,4 @@ Ideas: - -- Implement tabbed filebrowser with - 1. tab file selection - 2. tab inline file for safer storage - - implement security notice fragment - explain plain text storage of all data except for android keystore - explain even more insecure of storage on sd card @@ -38,8 +33,9 @@ Tap support: - need to chose right mac of receiver Requested by users: -cipher +keepalive 10 120 auth mtu-link nobind + -- cgit v1.2.3