summaryrefslogtreecommitdiff
path: root/src/se/leap/openvpn
diff options
context:
space:
mode:
Diffstat (limited to 'src/se/leap/openvpn')
-rw-r--r--src/se/leap/openvpn/ConfigParser.java6
-rw-r--r--src/se/leap/openvpn/OpenVPN.java5
-rw-r--r--src/se/leap/openvpn/OpenVPNThread.java2
-rw-r--r--src/se/leap/openvpn/OpenVpnManagementThread.java28
-rw-r--r--src/se/leap/openvpn/OpenVpnService.java13
-rw-r--r--src/se/leap/openvpn/VpnProfile.java1
6 files changed, 39 insertions, 16 deletions
diff --git a/src/se/leap/openvpn/ConfigParser.java b/src/se/leap/openvpn/ConfigParser.java
index 3d369fa6..36585d29 100644
--- a/src/se/leap/openvpn/ConfigParser.java
+++ b/src/se/leap/openvpn/ConfigParser.java
@@ -355,6 +355,12 @@ public class ConfigParser {
np.mServerName = remote.get(1);
}
}
+
+ // Parse remote config
+ Vector<String> location = getOption("location",1,2);
+ if(location != null && location.size() == 2){
+ np.mLocation = location.get(1).replace("__", ", ");
+ }
Vector<Vector<String>> dhcpoptions = getAllOption("dhcp-option", 2, 2);
if(dhcpoptions!=null) {
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/OpenVPNThread.java b/src/se/leap/openvpn/OpenVPNThread.java
index 0c383ab0..ffd21732 100644
--- a/src/se/leap/openvpn/OpenVPNThread.java
+++ b/src/se/leap/openvpn/OpenVPNThread.java
@@ -56,7 +56,7 @@ public class OpenVPNThread implements Runnable {
if( exitvalue != 0)
OpenVPN.logError("Process exited with exit value " + exitvalue);
- OpenVPN.updateStateString("NOPROCESS","No process running.", R.string.state_noprocess);
+// OpenVPN.updateStateString("NOPROCESS","No process running.", R.string.state_noprocess); fixes bug #4565
if(mDumpPath!=null) {
try {
BufferedWriter logout = new BufferedWriter(new FileWriter(mDumpPath + ".log"));
diff --git a/src/se/leap/openvpn/OpenVpnManagementThread.java b/src/se/leap/openvpn/OpenVpnManagementThread.java
index 78ce5a2b..27a3db65 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")) {
@@ -209,8 +211,11 @@ public class OpenVpnManagementThread implements Runnable {
OpenVPN.logMessage(0, "MGMT:", "Got unrecognized command" + command);
Log.i(TAG, "Got unrecognized command" + command);
}
- } else if (command.startsWith("SUCCESS:")) {
- // ignore
+ } else if (command.startsWith("SUCCESS:")) { //Fixes bug LEAP #4565
+ if (command.equals("SUCCESS: signal SIGINT thrown")){
+ Log.d(TAG, "SUCCESS: signal SIGINT thrown");
+ processState(",EXITING,SIGINT,,");
+ }
} else {
Log.i(TAG, "Got unrecognized line from managment" + command);
OpenVPN.logMessage(0, "MGMT:", "Got unrecognized line from management:" + command);
@@ -272,11 +277,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;
@@ -333,8 +344,7 @@ public class OpenVpnManagementThread implements Runnable {
mOpenVPNService.setDomain(extra);
} else if (needed.equals("ROUTE")) {
String[] routeparts = extra.split(" ");
- if(!mOpenVPNService.isRunning()) // We cannot add routes to an existing openvpn session
- mOpenVPNService.addRoute(routeparts[0], routeparts[1]);
+ mOpenVPNService.addRoute(routeparts[0], routeparts[1]);
} else if (needed.equals("ROUTE6")) {
mOpenVPNService.addRoutev6(extra);
} else if (needed.equals("IFCONFIG")) {
diff --git a/src/se/leap/openvpn/OpenVpnService.java b/src/se/leap/openvpn/OpenVpnService.java
index 620de204..b5c9c798 100644
--- a/src/se/leap/openvpn/OpenVpnService.java
+++ b/src/se/leap/openvpn/OpenVpnService.java
@@ -106,7 +106,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
String ns = Context.NOTIFICATION_SERVICE;
mNotificationManager = (NotificationManager) getSystemService(ns);
int icon;
- if (state.equals("NOPROCESS") || state.equals("AUTH_FAILED") || state.equals("NONETWORK")){
+ if (state.equals("NOPROCESS") || state.equals("AUTH_FAILED") || state.equals("NONETWORK") || state.equals("EXITING")){
icon = R.drawable.ic_vpn_disconnected;
}else{
icon = R.drawable.ic_stat_vpn;
@@ -114,7 +114,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
android.app.Notification.Builder nbuilder = new Notification.Builder(this);
- nbuilder.setContentTitle(getString(R.string.notifcation_title,mProfile.mName));
+ nbuilder.setContentTitle(getString(R.string.notifcation_title,mProfile.mLocation));
nbuilder.setContentText(msg);
nbuilder.setOnlyAlertOnce(true);
nbuilder.setOngoing(persistant);
@@ -350,12 +350,13 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
bconfig[4] = getString(R.string.routes_info, joinString(mRoutes));
bconfig[5] = getString(R.string.routes_info6, joinString(mRoutesv6));
- String session = mProfile.mName;
+ String session = mProfile.mLocation;
+ /* we don't want the IP address in the notification bar
if(mLocalIP!=null && mLocalIPv6!=null)
session = getString(R.string.session_ipv6string,session, mLocalIP, mLocalIPv6);
else if (mLocalIP !=null)
session= getString(R.string.session_ipv4string, session, mLocalIP);
-
+ */
builder.setSession(session);
@@ -478,9 +479,11 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
// CONNECTED
String ticker = getString(resid);
boolean persist = false;
- if (("NOPROCESS".equals(state) ) || ("EXIT").equals(state)){
+ if (("NOPROCESS".equals(state) ) || ("EXITING").equals(state)){
showNotification(state, getString(R.string.eip_state_not_connected), ticker, false, 0, persist);
}
+ else if (state.equals("GET_CONFIG") || state.equals("ASSIGN_IP")){ //don't show them in the notification message
+ }
else{
persist = true;
showNotification(state, getString(resid) +" " + logmessage,ticker,false,0,persist);
diff --git a/src/se/leap/openvpn/VpnProfile.java b/src/se/leap/openvpn/VpnProfile.java
index 41cf574b..99e1c676 100644
--- a/src/se/leap/openvpn/VpnProfile.java
+++ b/src/se/leap/openvpn/VpnProfile.java
@@ -68,6 +68,7 @@ public class VpnProfile implements Serializable{
private UUID mUuid;
public int mAuthenticationType = TYPE_CERTIFICATES ;
public String mName;
+ public String mLocation;
public String mAlias;
public String mClientCertFilename;
public String mTLSAuthDirection="";