From a74cce3c5a31c39e785fea672b8369d8738a8357 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Thu, 1 Oct 2015 17:14:27 +0200 Subject: Implement connect-timeout logic in OpenVPN and in the UI. --- main/openvpn | 2 +- .../main/java/de/blinkt/openvpn/VpnProfile.java | 2 - .../java/de/blinkt/openvpn/core/ConfigParser.java | 11 +- .../java/de/blinkt/openvpn/core/Connection.java | 5 + .../openvpn/fragments/ConnectionsAdapter.java | 44 +++++ main/src/main/res/layout/server_card.xml | 197 ++++++++++++--------- main/src/main/res/layout/server_layout | 172 ------------------ main/src/main/res/values/strings.xml | 1 + 8 files changed, 173 insertions(+), 261 deletions(-) delete mode 100644 main/src/main/res/layout/server_layout (limited to 'main') diff --git a/main/openvpn b/main/openvpn index 701e103d..bdd72d23 160000 --- a/main/openvpn +++ b/main/openvpn @@ -1 +1 @@ -Subproject commit 701e103d16c09c73ed5ccc28687d9faf7212dafe +Subproject commit bdd72d23fc3bd1def7d58e79d79b7731ee205ad0 diff --git a/main/src/main/java/de/blinkt/openvpn/VpnProfile.java b/main/src/main/java/de/blinkt/openvpn/VpnProfile.java index 5afb1fe5..01ee3d82 100644 --- a/main/src/main/java/de/blinkt/openvpn/VpnProfile.java +++ b/main/src/main/java/de/blinkt/openvpn/VpnProfile.java @@ -159,8 +159,6 @@ public class VpnProfile implements Serializable, Cloneable { public String mServerPort = "1194"; public boolean mUseUdp = true; - - public VpnProfile(String name) { mUuid = UUID.randomUUID(); mName = name; diff --git a/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java b/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java index 028c8816..6ba80e66 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java +++ b/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java @@ -37,6 +37,8 @@ public class ConfigParser { public void parseConfig(Reader reader) throws IOException, ConfigParseError { + HashMap optionAliases = new HashMap<>(); + optionAliases.put("server-poll-timeout", "timeout-connect"); BufferedReader br = new BufferedReader(reader); @@ -76,6 +78,9 @@ public class ConfigParser { checkinlinefile(args, br); String optionname = args.get(0); + if (optionAliases.get(optionname)!=null) + optionname = optionAliases.get(optionname); + if (!options.containsKey(optionname)) { options.put(optionname, new Vector>()); } @@ -715,8 +720,12 @@ public class ConfigParser { conn.mUseUdp = isUdpProto(proto.get(1)); } + Vector connectTimeout = getOption("connect-timeout", 1, 1); + if (connectTimeout != null) + conn.mConnectTimeout = Integer.parseInt(connectTimeout.get(0)); + - // Parse remote config + // Parse remote config Vector> remotes = getAllOption("remote", 1, 3); 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 b10664ce..46ee4c36 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/Connection.java +++ b/main/src/main/java/de/blinkt/openvpn/core/Connection.java @@ -16,6 +16,7 @@ public class Connection implements Serializable, Cloneable { public String mCustomConfiguration=""; public boolean mUseCustomConfig=false; public boolean mEnabled=true; + public int mConnectTimeout = 0; private static final long serialVersionUID = 92031902903829089L; @@ -33,6 +34,10 @@ public class Connection implements Serializable, Cloneable { else cfg += " tcp-client\n"; + if (mConnectTimeout!=0) + cfg += String.format(" connect-timeout %d\n" , mConnectTimeout); + + if (!TextUtils.isEmpty(mCustomConfiguration) && mUseCustomConfig) { cfg += mCustomConfiguration; cfg += "\n"; diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/ConnectionsAdapter.java b/main/src/main/java/de/blinkt/openvpn/fragments/ConnectionsAdapter.java index 14c089f5..c0bda8d1 100644 --- a/main/src/main/java/de/blinkt/openvpn/fragments/ConnectionsAdapter.java +++ b/main/src/main/java/de/blinkt/openvpn/fragments/ConnectionsAdapter.java @@ -19,6 +19,7 @@ import android.widget.CompoundButton; import android.widget.EditText; import android.widget.ImageButton; import android.widget.RadioGroup; +import android.widget.SeekBar; import android.widget.Switch; import java.util.Arrays; @@ -55,6 +56,8 @@ public class ConnectionsAdapter extends RecyclerView.Adapter - - + android:layout_margin="@dimen/stdpadding"> + card_view:cardCornerRadius="10dp"> + android:animateLayoutChanges="true" + android:padding="5dp"> + android:text="1194" + android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium" /> + android:inputType="textUri" + android:singleLine="true" + android:text="openvpn.blinkt.de" + android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium" /> - - + - + - + - - --> + android:paddingLeft="10dp" + android:paddingStart="10dp"> + + android:layout_height="wrap_content" + android:text="@string/custom_connection_options_warng" /> + android:layout_height="wrap_content" + android:inputType="textMultiLine" + android:lines="5" /> + android:layout_below="@+id/portnumber" + android:layout_gravity="right|bottom" + android:text="Enable" /> + + android:contentDescription="@string/remove_connection_entry" + android:padding="12dp" /> - - - \ No newline at end of file diff --git a/main/src/main/res/layout/server_layout b/main/src/main/res/layout/server_layout deleted file mode 100644 index c6d11fe6..00000000 --- a/main/src/main/res/layout/server_layout +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/main/src/main/res/values/strings.xml b/main/src/main/res/values/strings.xml index ee4f76ef..a4424277 100755 --- a/main/src/main/res/values/strings.xml +++ b/main/src/main/res/values/strings.xml @@ -385,5 +385,6 @@ Search (Last dump is %1$d:%2$dh old (%3$s)) Clear log on new connection + Connect Timeout -- cgit v1.2.3