summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcyBerta <richy@cyborgsociety.org>2013-11-26 04:46:42 +0100
committerParménides GV <parmegv@sdf.org>2013-12-04 16:00:48 +0100
commit1df0766479f0235bd7e2afcaecce1eaebacb9ffc (patch)
treef12756e2af7ad181c3f9c8704c5e1fdb14cb7052
parente60be47e5a46b794846b166993260f17a54a19ad (diff)
added FATAL as status for reconnection timout
-rw-r--r--src/se/leap/bitmaskclient/EipServiceFragment.java10
-rw-r--r--src/se/leap/openvpn/OpenVPN.java5
-rw-r--r--src/se/leap/openvpn/OpenVpnManagementThread.java18
3 files changed, 24 insertions, 9 deletions
diff --git a/src/se/leap/bitmaskclient/EipServiceFragment.java b/src/se/leap/bitmaskclient/EipServiceFragment.java
index ba6bf561..e182b3fd 100644
--- a/src/se/leap/bitmaskclient/EipServiceFragment.java
+++ b/src/se/leap/bitmaskclient/EipServiceFragment.java
@@ -12,6 +12,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.ResultReceiver;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@@ -38,6 +39,9 @@ public class EipServiceFragment extends Fragment implements StateListener, OnCli
private EIPReceiver mEIPReceiver;
+
+ public static String TAG = "se.leap.bitmask.EipServiceFragment";
+
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
@@ -191,15 +195,14 @@ public class EipServiceFragment extends Fragment implements StateListener, OnCli
statusMessage = getString(R.string.eip_state_connected); getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE);
mEipStartPending = false;
- } else if ( (state.equals("NOPROCESS") && !mEipStartPending ) || state.equals("EXITING")) {
+ } else if ( (state.equals("NOPROCESS") && !mEipStartPending ) || state.equals("EXITING") || state.equals("FATAL")) {
statusMessage = getString(R.string.eip_state_not_connected);
getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE);
mEipStartPending = false;
switchState = false;
} else if (state.equals("NOPROCESS")){
statusMessage = logmessage;
- }
- else {
+ } else {
statusMessage = prefix + " " + logmessage;
}
@@ -212,6 +215,7 @@ public class EipServiceFragment extends Fragment implements StateListener, OnCli
});
}
+
/**
* Inner class for handling messages related to EIP status and control requests
*
diff --git a/src/se/leap/openvpn/OpenVPN.java b/src/se/leap/openvpn/OpenVPN.java
index d7d17b4f..8acdc423 100644
--- a/src/se/leap/openvpn/OpenVPN.java
+++ b/src/se/leap/openvpn/OpenVPN.java
@@ -25,6 +25,7 @@ public class OpenVPN {
private static String mLaststate;
private static int mLastStateresid=R.string.state_noprocess;
+ public static String TAG="se.leap.openvpn.OpenVPN";
static {
logbuffer = new LinkedList<LogItem>();
@@ -166,6 +167,8 @@ public class OpenVPN {
return R.string.state_resolve;
else if (state.equals("TCP_CONNECT"))
return R.string.state_tcp_connect;
+ else if (state.equals("FATAL"))
+ return R.string.eip_state_not_connected;
else
return R.string.unknown_state;
@@ -197,7 +200,7 @@ public class OpenVPN {
}
- public static void updateStateString (String state, String msg) {
+ public static void updateStateString (String state, String msg) {
int rid = getLocalizedState(state);
updateStateString(state, msg,rid);
}
diff --git a/src/se/leap/openvpn/OpenVpnManagementThread.java b/src/se/leap/openvpn/OpenVpnManagementThread.java
index 78ce5a2b..b4da1e30 100644
--- a/src/se/leap/openvpn/OpenVpnManagementThread.java
+++ b/src/se/leap/openvpn/OpenVpnManagementThread.java
@@ -19,7 +19,6 @@ import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import se.leap.bitmaskclient.R;
-
import android.content.SharedPreferences;
import android.net.LocalServerSocket;
import android.net.LocalSocket;
@@ -177,11 +176,12 @@ public class OpenVpnManagementThread implements Runnable {
private void processCommand(String command) {
+ Log.d(TAG, "processCommand: " + command);
+
if (command.startsWith(">") && command.contains(":")) {
String[] parts = command.split(":",2);
String cmd = parts[0].substring(1);
String argument = parts[1];
-
if(cmd.equals("INFO")) {
// Ignore greeting from mgmt
//logStatusMessage(command);
@@ -195,6 +195,8 @@ public class OpenVpnManagementThread implements Runnable {
processByteCount(argument);
} else if (cmd.equals("STATE")) {
processState(argument);
+ } else if (cmd.equals("FATAL")){
+ processState(","+cmd+","); //handles FATAL as state
} else if (cmd.equals("PROXY")) {
processProxyCMD(argument);
} else if (cmd.equals("LOG")) {
@@ -272,11 +274,17 @@ public class OpenVpnManagementThread implements Runnable {
private void processState(String argument) {
String[] args = argument.split(",",3);
String currentstate = args[1];
- Log.d("OpenVPN log", argument);
- if(args[2].equals(",,"))
+ if(args[2].equals(",,")){
OpenVPN.updateStateString(currentstate,"");
- else
+ }
+ else if (args[2].endsWith(",,")){ //fixes LEAP Bug #4546
+ args[2] = (String) args[2].subSequence(0, args[2].length()-2);
+ Log.d(TAG, "processState() STATE: "+ currentstate + " msg: " + args[2]);
OpenVPN.updateStateString(currentstate,args[2]);
+ }
+ else{
+ OpenVPN.updateStateString(currentstate,args[2]);
+ }
}
private static int repeated_byte_counts = 0;