diff options
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/VpnProfile.java | 31 | ||||
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/core/Connection.java | 4 |
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; + } } |