summaryrefslogtreecommitdiff
path: root/src/de/blinkt
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/blinkt')
-rw-r--r--src/de/blinkt/openvpn/MainActivity.java2
-rw-r--r--src/de/blinkt/openvpn/OpenVPN.java33
-rw-r--r--src/de/blinkt/openvpn/OpenVPNThread.java6
-rw-r--r--src/de/blinkt/openvpn/OpenVpnService.java18
-rw-r--r--src/de/blinkt/openvpn/Settings_Authentication.java3
5 files changed, 18 insertions, 44 deletions
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<Header> 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<String> logbuffer = new LinkedList<String>();
- private static int counter=0;
-
+
private static Vector<LogListener> logListener=new Vector<OpenVPN.LogListener>();
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<CIDRIP> mRoutes=new Vector<CIDRIP>();
- 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