summaryrefslogtreecommitdiff
path: root/src/de
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2012-05-09 13:35:58 +0200
committerArne Schwabe <arne@rfc2549.org>2012-05-09 13:35:58 +0200
commit5f8dcd814c5cb6588220678a2b5dbe61644e151b (patch)
tree04974bc92c7256cd1a0cbc6fa8d02089e36415aa /src/de
parent632ea7eb1cd7e4c9fa330d4e80acaa6940a4e1a8 (diff)
Writing the Minivpn binary on start.
It is small enough to not care about writing it over and over again.
Diffstat (limited to 'src/de')
-rw-r--r--src/de/blinkt/openvpn/LaunchVPN.java39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/de/blinkt/openvpn/LaunchVPN.java b/src/de/blinkt/openvpn/LaunchVPN.java
index 88c14da..17313cd 100644
--- a/src/de/blinkt/openvpn/LaunchVPN.java
+++ b/src/de/blinkt/openvpn/LaunchVPN.java
@@ -16,6 +16,11 @@
package de.blinkt.openvpn;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.util.Collection;
import java.util.Vector;
@@ -203,6 +208,32 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
// }
}
+
+ private boolean writeMiniVPN() {
+ try {
+ InputStream mvpn = getAssets().open("minivpn");
+ File mvpnout = new File(getCacheDir(),"minivpn");
+ FileOutputStream fout = new FileOutputStream(mvpnout);
+
+ byte buf[]= new byte[4096];
+
+ int lenread = mvpn.read(buf);
+ while(lenread> 0) {
+ fout.write(buf, 0, lenread);
+ lenread = mvpn.read(buf);
+ }
+ fout.close();
+
+ if(!mvpnout.setExecutable(true))
+ return false;
+
+
+ return true;
+ } catch (IOException e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
private void askForPW(final String type) {
@@ -309,8 +340,12 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
void startOpenVpn() {
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;
+ }
OpenVPN.logMessage(0, "", "Building configration...");
Intent startVPN = mSelectedProfile.prepareIntent(getBaseContext());