summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2014-12-08 13:07:28 +0100
committerArne Schwabe <arne@rfc2549.org>2014-12-08 13:07:28 +0100
commit451a47487185e1e17626386e38381e5e8dba9fb8 (patch)
tree1b9207bee82c12cc4912dd7d61809a4281748b7c
parentb0cd8e9c418ee029e67e2f5af609ef3ac3eacc0e (diff)
Always use --remote when possible, fix connection block not accepting global options
--HG-- extra : rebase_source : 725acc40a0c82171fab1536a14e22805b1322ed4
-rw-r--r--main/src/main/java/de/blinkt/openvpn/VpnProfile.java31
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/Connection.java4
2 files changed, 30 insertions, 5 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/VpnProfile.java b/main/src/main/java/de/blinkt/openvpn/VpnProfile.java
index 606c563c..ed235373 100644
--- a/main/src/main/java/de/blinkt/openvpn/VpnProfile.java
+++ b/main/src/main/java/de/blinkt/openvpn/VpnProfile.java
@@ -299,16 +299,24 @@ public class VpnProfile implements Serializable, Cloneable {
// We cannot use anything else than tun
cfg += "dev tun\n";
+
+ boolean canUsePlainRemotes = true;
+
if (mConnections.length==1) {
cfg += mConnections[0].getConnectionBlock();
} else {
+ for (Connection conn : mConnections) {
+ canUsePlainRemotes = canUsePlainRemotes && conn.isOnlyRemote();
+ }
+
if (mRemoteRandom)
cfg+="remote-random\n";
- for (Connection conn : mConnections) {
- if (conn.mEnabled) {
- cfg += "<connection>\n";
- cfg += conn.getConnectionBlock();
- cfg += "</connection>\n";
+
+ if (canUsePlainRemotes) {
+ for (Connection conn : mConnections) {
+ if (conn.mEnabled) {
+ cfg += conn.getConnectionBlock();
+ }
}
}
}
@@ -501,6 +509,19 @@ public class VpnProfile implements Serializable, Cloneable {
}
+ if (!canUsePlainRemotes) {
+ cfg += "# Connection Options are at the end to allow global options (and global custom options) to influence connection blocks\n"
+ for (Connection conn : mConnections) {
+ if (conn.mEnabled) {
+ cfg += "<connection>\n";
+ cfg += conn.getConnectionBlock();
+ cfg += "</connection>\n";
+ }
+ }
+ }
+
+
+
return cfg;
}
diff --git a/main/src/main/java/de/blinkt/openvpn/core/Connection.java b/main/src/main/java/de/blinkt/openvpn/core/Connection.java
index fd5c3761..a12dfcaf 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/Connection.java
+++ b/main/src/main/java/de/blinkt/openvpn/core/Connection.java
@@ -44,4 +44,8 @@ public class Connection implements Serializable, Cloneable {
public Connection clone() throws CloneNotSupportedException {
return (Connection) super.clone();
}
+
+ public boolean isOnlyRemote() {
+ return TextUtils.isEmpty(mCustomConfiguration) || !mUseCustomConfig;
+ }
}