summaryrefslogtreecommitdiff
path: root/src/de/blinkt
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/blinkt')
-rw-r--r--src/de/blinkt/openvpn/LaunchVPN.java13
-rw-r--r--src/de/blinkt/openvpn/OpenVPNThread.java14
-rw-r--r--src/de/blinkt/openvpn/OpenVpnManagementThread.java19
-rw-r--r--src/de/blinkt/openvpn/VpnProfile.java8
4 files changed, 37 insertions, 17 deletions
diff --git a/src/de/blinkt/openvpn/LaunchVPN.java b/src/de/blinkt/openvpn/LaunchVPN.java
index 17313cd5..858c8d38 100644
--- a/src/de/blinkt/openvpn/LaunchVPN.java
+++ b/src/de/blinkt/openvpn/LaunchVPN.java
@@ -78,6 +78,8 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
private ProfileManager mPM;
private VpnProfile mSelectedProfile;
+ static boolean minivpnwritten=false;
+
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
@@ -210,6 +212,8 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
}
private boolean writeMiniVPN() {
+ if(minivpnwritten)
+ return true;
try {
InputStream mvpn = getAssets().open("minivpn");
File mvpnout = new File(getCacheDir(),"minivpn");
@@ -227,7 +231,7 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
if(!mvpnout.setExecutable(true))
return false;
-
+ minivpnwritten=true;
return true;
} catch (IOException e) {
e.printStackTrace();
@@ -321,8 +325,10 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
// Start the query
try {
startActivityForResult(intent, START_VPN_PROFILE);
- } catch (ActivityNotFoundException ane){
- Toast.makeText(this, "Your image does not support the VPNService API,sorry :(", Toast.LENGTH_LONG).show();
+ } catch (ActivityNotFoundException ane) {
+ // Shame on you Sony! At least one user reported that
+ // an official Sony Xperia Arc S image triggers this exception
+ Toast.makeText(this, R.string.no_vpn_support_image, Toast.LENGTH_LONG).show();
}
} else {
onActivityResult(START_VPN_PROFILE, Activity.RESULT_OK, null);
@@ -341,7 +347,6 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
Intent startLW = new Intent(getBaseContext(),LogWindow.class);
startActivity(startLW);
- OpenVPN.logMessage(0, "", "Writing minivpn binary");
if(!writeMiniVPN()) {
OpenVPN.logMessage(0, "", "Error writing minivpn binary");
return;
diff --git a/src/de/blinkt/openvpn/OpenVPNThread.java b/src/de/blinkt/openvpn/OpenVPNThread.java
index d4d4cd64..008598e4 100644
--- a/src/de/blinkt/openvpn/OpenVPNThread.java
+++ b/src/de/blinkt/openvpn/OpenVPNThread.java
@@ -44,7 +44,7 @@ public class OpenVPNThread implements Runnable {
// Log argv
- OpenVPN.logMessage(0, "argv:" , Arrays.toString(mArgv));
+ //OpenVPN.logMessage(0, "argv:" , Arrays.toString(mArgv));
startOpenVPNThreadArgs(mArgv);
@@ -77,7 +77,17 @@ public class OpenVPNThread implements Runnable {
ProcessBuilder pb = new ProcessBuilder(argvlist);
// Hack O rama
- pb.environment().put("LD_LIBRARY_PATH", "/data/data/de.blinkt.openvpn/lib");
+
+ // Hack until I find a good way to get the real library path
+ String applibpath = argv[0].replace("/cache/minivpn", "/lib");
+
+ String lbpath = pb.environment().get("LD_LIBRARY_PATH");
+ if(lbpath==null)
+ lbpath = applibpath;
+ else
+ lbpath = lbpath + ":" + applibpath;
+
+ pb.environment().put("LD_LIBRARY_PATH", lbpath);
pb.redirectErrorStream(true);
try {
mProcess = pb.start();
diff --git a/src/de/blinkt/openvpn/OpenVpnManagementThread.java b/src/de/blinkt/openvpn/OpenVpnManagementThread.java
index 18d543f1..bc2b0e13 100644
--- a/src/de/blinkt/openvpn/OpenVpnManagementThread.java
+++ b/src/de/blinkt/openvpn/OpenVpnManagementThread.java
@@ -33,7 +33,7 @@ public class OpenVpnManagementThread implements Runnable {
}
public void managmentCommand(String cmd) {
- Log.d("openvpn", "mgmt cmd" + mSocket + " " +cmd + " " );
+ //Log.d("openvpn", "mgmt cmd" + mSocket + " " +cmd + " " );
try {
mSocket.getOutputStream().write(cmd.getBytes());
mSocket.getOutputStream().flush();
@@ -144,21 +144,24 @@ public class OpenVpnManagementThread implements Runnable {
String argument = parts[1];
- if(cmd.equals("INFO"))
- logStatusMessage(command);
- else if (cmd.equals("PASSWORD")) {
+ if(cmd.equals("INFO")) {
+ // Ignore greeting from mgmt
+ //logStatusMessage(command);
+ }else if (cmd.equals("PASSWORD")) {
processPWCommand(argument);
} else if (cmd.equals("HOLD")) {
managmentCommand("hold release\n");
- managmentCommand("log on\n");
- managmentCommand("bytecount 13\n");
+ //managmentCommand("log on\n");
} else if (cmd.equals("NEED-OK")) {
processNeedCommand(argument);
} else if (cmd.equals("LOG")) {
- OpenVPN.logMessage(0, "", command);
+ String[] args = argument.split(",",3);
+ // 0 unix time stamp
+ // 1 log level N,I,E etc.
+ // 2 log message
+ OpenVPN.logMessage(0, "", args[2]);
} else {
OpenVPN.logMessage(0, "MGMT:", "Got unrecognized command" + command);
- managmentCommand("log 1\n");
Log.i(TAG, "Got unrecognized command" + command);
}
} else if (command.startsWith("SUCCESS:")) {
diff --git a/src/de/blinkt/openvpn/VpnProfile.java b/src/de/blinkt/openvpn/VpnProfile.java
index 227df5ba..26cf50bd 100644
--- a/src/de/blinkt/openvpn/VpnProfile.java
+++ b/src/de/blinkt/openvpn/VpnProfile.java
@@ -137,8 +137,6 @@ public class VpnProfile implements Serializable{
cfg+=cacheDir.getAbsolutePath();
cfg+="\n\n";
- cfg+="# Silences script security warning\n";
- cfg+="script-security 0\n\n";
boolean useTLSClient = (mAuthenticationType != TYPE_STATICKEYS);
@@ -350,7 +348,11 @@ public class VpnProfile implements Serializable{
args.add("--config");
args.add(cacheDir.getAbsolutePath() + "/" + OVPNCONFIGFILE);
-
+ // Silences script security warning
+
+ args.add("script-security");
+ args.add("0");
+
return (String[]) args.toArray(new String[args.size()]);
}