summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/de/blinkt/openvpn/LogWindow.java25
-rw-r--r--src/de/blinkt/openvpn/OpenVpnManagementThread.java12
-rw-r--r--src/de/blinkt/openvpn/VpnProfile.java19
3 files changed, 40 insertions, 16 deletions
diff --git a/src/de/blinkt/openvpn/LogWindow.java b/src/de/blinkt/openvpn/LogWindow.java
index 65e8c66c..f3809e27 100644
--- a/src/de/blinkt/openvpn/LogWindow.java
+++ b/src/de/blinkt/openvpn/LogWindow.java
@@ -1,13 +1,19 @@
package de.blinkt.openvpn;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.charset.Charset;
import java.util.Vector;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.ListActivity;
import android.content.DialogInterface;
+import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.database.DataSetObserver;
+import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
@@ -20,6 +26,7 @@ import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
+import android.widget.Toast;
import de.blinkt.openvpn.OpenVPN.LogListener;
public class LogWindow extends ListActivity {
@@ -56,6 +63,22 @@ public class LogWindow extends ListActivity {
}
}
+ String getLogStr() {
+ String str = "";
+ for(String entry:myEntries) {
+ str+=entry + '\n';
+ }
+ return str;
+ }
+
+ private void shareLog() {
+ Intent shareIntent = new Intent(Intent.ACTION_SEND);
+ shareIntent.putExtra(Intent.EXTRA_TEXT, getLogStr());
+ shareIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.ics_openvpn_log_file));
+ shareIntent.setType("text/plain");
+ startActivity(Intent.createChooser(shareIntent, "Send Logfile"));
+ }
+
@Override
public void registerDataSetObserver(DataSetObserver observer) {
observers.add(observer);
@@ -190,6 +213,8 @@ public class LogWindow extends ListActivity {
} else if(item.getItemId()==R.id.info) {
if(mBconfig==null)
OpenVPN.triggerLogBuilderConfig();
+ } else if(item.getItemId()==R.id.send) {
+ ladapter.shareLog();
}
return super.onOptionsItemSelected(item);
diff --git a/src/de/blinkt/openvpn/OpenVpnManagementThread.java b/src/de/blinkt/openvpn/OpenVpnManagementThread.java
index 2bae9e5e..4162d315 100644
--- a/src/de/blinkt/openvpn/OpenVpnManagementThread.java
+++ b/src/de/blinkt/openvpn/OpenVpnManagementThread.java
@@ -31,14 +31,6 @@ public class OpenVpnManagementThread implements Runnable {
}
- private String managmentEscape(String unescape) {
- String escapedString = unescape.replace("\\", "\\\\");
- escapedString = escapedString.replace("\"","\\\"");
- escapedString = escapedString.replace("\n","\\n");
- return '"' + escapedString + '"';
- }
-
-
public void managmentCommand(String cmd) {
try {
mSocket.getOutputStream().write(cmd.getBytes());
@@ -177,7 +169,7 @@ public class OpenVpnManagementThread implements Runnable {
pw = mProfile.getPasswordPrivateKey();
} else if (needed.equals("Auth")) {
String usercmd = String.format("username '%s' %s\n",
- needed, managmentEscape(mProfile.mUsername));
+ needed, VpnProfile.openVpnEscape(mProfile.mUsername));
managmentCommand(usercmd);
pw = mProfile.getPasswordAuth();
} else if (needed.equals("PROTECTFD")) {
@@ -187,7 +179,7 @@ public class OpenVpnManagementThread implements Runnable {
response="needok";
}
if(pw!=null) {
- String cmd = String.format("%s '%s' %s\n",response, needed, managmentEscape(pw));
+ String cmd = String.format("%s '%s' %s\n",response, needed, VpnProfile.openVpnEscape(pw));
managmentCommand(cmd);
}
diff --git a/src/de/blinkt/openvpn/VpnProfile.java b/src/de/blinkt/openvpn/VpnProfile.java
index 572c0c2d..75f0235d 100644
--- a/src/de/blinkt/openvpn/VpnProfile.java
+++ b/src/de/blinkt/openvpn/VpnProfile.java
@@ -148,6 +148,13 @@ public class VpnProfile implements Serializable{
}
};
+ public static String openVpnEscape(String unescape) {
+ String escapedString = unescape.replace("\\", "\\\\");
+ escapedString = escapedString.replace("\"","\\\"");
+ escapedString = escapedString.replace("\n","\\n");
+ return '"' + escapedString + '"';
+ }
+
static final String OVPNCONFIGPKCS12 = "android.pkcs12";
@@ -231,22 +238,22 @@ public class VpnProfile implements Serializable{
case VpnProfile.TYPE_CERTIFICATES:
// Ca
cfg+="ca ";
- cfg+=mCaFilename;
+ cfg+=openVpnEscape(mCaFilename);
cfg+="\n";
// Client Cert + Key
cfg+="key ";
- cfg+=mClientKeyFilename;
+ cfg+=openVpnEscape(mClientKeyFilename);
cfg+="\n";
cfg+="cert ";
- cfg+=mClientCertFilename;
+ cfg+=openVpnEscape(mClientCertFilename);
cfg+="\n";
break;
case VpnProfile.TYPE_USERPASS_PKCS12:
cfg+="auth-user-pass\n";
case VpnProfile.TYPE_PKCS12:
cfg+="pkcs12 ";
- cfg+=mPKCS12Filename;
+ cfg+=openVpnEscape(mPKCS12Filename);
cfg+="\n";
cfg+="management-query-passwords\n";
break;
@@ -262,7 +269,7 @@ public class VpnProfile implements Serializable{
case VpnProfile.TYPE_USERPASS:
cfg+="auth-user-pass\n";
cfg+="management-query-passwords\n";
- cfg+="ca " + mCaFilename +"\n";
+ cfg+="ca " +openVpnEscape(mCaFilename) +"\n";
}
if(mUseLzo) {
@@ -274,7 +281,7 @@ public class VpnProfile implements Serializable{
cfg+="secret ";
else
cfg+="tls-auth ";
- cfg+=mTLSAuthFilename;
+ cfg+=openVpnEscape(mTLSAuthFilename);
cfg+=" ";
cfg+= mTLSAuthDirection;
cfg+="\n";