summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------main/openvpn0
-rw-r--r--main/src/main/java/de/blinkt/openvpn/VpnProfile.java2
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java11
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/Connection.java5
-rw-r--r--main/src/main/java/de/blinkt/openvpn/fragments/ConnectionsAdapter.java44
-rw-r--r--main/src/main/res/layout/server_card.xml197
-rw-r--r--main/src/main/res/layout/server_layout172
-rwxr-xr-xmain/src/main/res/values/strings.xml1
8 files changed, 172 insertions, 260 deletions
diff --git a/main/openvpn b/main/openvpn
-Subproject 701e103d16c09c73ed5ccc28687d9faf7212daf
+Subproject bdd72d23fc3bd1def7d58e79d79b7731ee205ad
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<String, String> 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<Vector<String>>());
}
@@ -715,8 +720,12 @@ public class ConfigParser {
conn.mUseUdp = isUdpProto(proto.get(1));
}
+ Vector<String> connectTimeout = getOption("connect-timeout", 1, 1);
+ if (connectTimeout != null)
+ conn.mConnectTimeout = Integer.parseInt(connectTimeout.get(0));
+
- // Parse remote config
+ // Parse remote config
Vector<Vector<String>> 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<ConnectionsAdapter.
private final CheckBox mCustomOptionCB;
private final View mCustomOptionsLayout;
private final ImageButton mDeleteButton;
+ private final EditText mConnectText;
+ private final SeekBar mConnectSlider;
public ConnectionsHolder(View card) {
super(card);
@@ -66,6 +69,8 @@ public class ConnectionsAdapter extends RecyclerView.Adapter<ConnectionsAdapter.
mProtoGroup = (RadioGroup) card.findViewById(R.id.udptcpradiogroup);
mCustomOptionsLayout = card.findViewById(R.id.custom_options_layout);
mDeleteButton = (ImageButton) card.findViewById(R.id.remove_connection);
+ mConnectSlider = (SeekBar) card.findViewById(R.id.connect_silder);
+ mConnectText = (EditText) card.findViewById(R.id.connect_timeout);
}
}
@@ -109,6 +114,13 @@ public class ConnectionsAdapter extends RecyclerView.Adapter<ConnectionsAdapter.
cH.mServerNameView.setText(connection.mServerName);
cH.mPortNumberView.setText(connection.mServerPort);
cH.mRemoteSwitch.setChecked(connection.mEnabled);
+ if (connection.mConnectTimeout==0) {
+ cH.mConnectText.setText("");
+ } else {
+ cH.mConnectText.setText(String.valueOf(connection.mConnectTimeout));
+ }
+ cH.mConnectSlider.setProgress(connection.mConnectTimeout);
+
cH.mRemoteSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@@ -182,6 +194,38 @@ public class ConnectionsAdapter extends RecyclerView.Adapter<ConnectionsAdapter.
}
});
+ cH.mConnectSlider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ if (fromUser) {
+ cH.mConnectText.setText(String.valueOf(progress));
+ connection.mConnectTimeout = progress;
+ }
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+
+ }
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+
+ }
+ });
+ cH.mConnectText.addTextChangedListener(new OnTextChangedWatcher() {
+ @Override
+ public void afterTextChanged(Editable s) {
+ try {
+ int t = Integer.valueOf(String.valueOf(s));
+ cH.mConnectSlider.setProgress(t);
+ connection.mConnectTimeout = t;
+ } catch (Exception ignored) {
+
+ }
+ }
+ });
+
}
private void removeRemote(int idx) {
diff --git a/main/src/main/res/layout/server_card.xml b/main/src/main/res/layout/server_card.xml
index 690a27bd..bad9a3c6 100644
--- a/main/src/main/res/layout/server_card.xml
+++ b/main/src/main/res/layout/server_card.xml
@@ -1,85 +1,82 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2012-2014 Arne Schwabe
~ Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt
-->
-<FrameLayout xmlns:tools="http://schemas.android.com/tools"
- xmlns:android="http://schemas.android.com/apk/res/android"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_margin="@dimen/stdpadding"
- >
+ android:layout_margin="@dimen/stdpadding">
<!-- A CardView that contains a TextView -->
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
- card_view:cardCornerRadius="10dp"
- >
+ card_view:cardCornerRadius="10dp">
<RelativeLayout
- android:animateLayoutChanges="true"
- android:padding="5dp"
+ xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- xmlns:android="http://schemas.android.com/apk/res/android">
+ android:animateLayoutChanges="true"
+ android:padding="5dp">
<TextView
- style="@style/item"
android:id="@+id/port_label"
- android:text="@string/port"
+ style="@style/item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
+ android:layout_alignParentRight="true"
+ android:text="@string/port"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
+ android:id="@+id/server_label"
style="@style/item"
android:text="@string/address"
- android:id="@+id/server_label"
android:textAppearance="?android:attr/textAppearanceSmall" />
<EditText
android:id="@+id/portnumber"
- android:layout_alignParentRight="true"
- android:layout_alignParentEnd="true"
- android:layout_below="@id/port_label"
android:layout_width="wrap_content"
-
android:layout_height="wrap_content"
+ android:layout_alignParentEnd="true"
+ android:layout_alignParentRight="true"
+
+ android:layout_below="@id/port_label"
android:inputType="numberDecimal"
- android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
- android:text="1194" />
+ android:text="1194"
+ android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium" />
<EditText
android:id="@+id/servername"
- android:singleLine="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
- android:inputType="textUri"
android:layout_below="@id/server_label"
android:layout_toLeftOf="@id/portnumber"
android:layout_toStartOf="@id/portnumber"
- android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
- android:text="openvpn.blinkt.de" />
+ android:inputType="textUri"
+ android:singleLine="true"
+ android:text="openvpn.blinkt.de"
+ android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium" />
<TextView
- android:paddingTop="10dp"
+ android:id="@+id/protocol"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/servername"
- android:id="@+id/protocol"
+ android:paddingTop="10dp"
android:text="Protocol" />
<RadioGroup
@@ -106,103 +103,133 @@
android:layout_height="wrap_content"
android:text="TCP" />
</RadioGroup>
- <!-- <TextView
- android:paddingTop="10dp"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@id/udptcpradiogroup"
- android:id="@+id/proxytext"
- android:text="Proxy" />
- <RadioGroup
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:id="@+id/proxygroup"
- android:paddingLeft="20dp"
- android:layout_below="@id/proxytext">
- <RadioButton
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="None" />
+ <!-- <TextView
+ android:paddingTop="10dp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/udptcpradiogroup"
+ android:id="@+id/proxytext"
+ android:text="Proxy" />
+
+ <RadioGroup
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:id="@+id/proxygroup"
+ android:paddingLeft="20dp"
+ android:layout_below="@id/proxytext">
+
+ <RadioButton
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="None" />
+
+ <Space
+ android:layout_width="10dp"
+ android:layout_height="wrap_content" />
+
+ <RadioButton
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="HTTP" />
+
+ <Space
+ android:layout_width="10dp"
+ android:layout_height="wrap_content" />
+
+ <RadioButton
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Socks" />
+ </RadioGroup> -->
- <Space
- android:layout_width="10dp"
- android:layout_height="wrap_content" />
+ <TextView
+ android:id="@+id/connect_timeout_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/udptcpradiogroup"
+ android:paddingTop="10dp"
+ android:text="@string/connect_timeout" />
- <RadioButton
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="HTTP" />
+ <EditText
+ android:id="@+id/connect_timeout"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_alignParentEnd="true"
+ android:layout_below="@+id/connect_timeout_label"
+ android:ems="3"
+ android:inputType="numberDecimal" />
- <Space
- android:layout_width="10dp"
- android:layout_height="wrap_content" />
+ <SeekBar
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:id="@+id/connect_silder"
+ android:max="300"
+ android:layout_alignBottom="@id/connect_timeout"
+ android:layout_toLeftOf="@id/connect_timeout"
+ android:layout_toStartOf="@id/connect_timeout"
+ android:layout_below="@id/connect_timeout_label" />
- <RadioButton
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Socks" />
- </RadioGroup> -->
<CheckBox
- android:paddingTop="10dp"
+ android:id="@+id/use_customoptions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_below="@id/udptcpradiogroup"
- android:id="@+id/use_customoptions"
+ android:layout_below="@id/connect_timeout"
+ android:paddingTop="10dp"
android:text="@string/custom_connection_options" />
<LinearLayout
- android:paddingLeft="10dp"
- android:paddingStart="10dp"
android:id="@+id/custom_options_layout"
- android:layout_below="@id/use_customoptions"
android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/use_customoptions"
android:orientation="vertical"
- android:layout_height="wrap_content">
+ android:paddingLeft="10dp"
+ android:paddingStart="10dp">
+
<TextView
android:id="@+id/warnung_custom"
- android:text="@string/custom_connection_options_warng"
android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
+ android:layout_height="wrap_content"
+ android:text="@string/custom_connection_options_warng" />
<EditText
- android:inputType="textMultiLine"
android:id="@+id/customoptions"
- android:lines="5"
android:layout_width="match_parent"
- android:layout_height="wrap_content" />
+ android:layout_height="wrap_content"
+ android:inputType="textMultiLine"
+ android:lines="5" />
</LinearLayout>
<Switch
+ android:id="@+id/remoteSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="Enable"
- android:id="@+id/remoteSwitch"
- android:layout_gravity="right|bottom"
- android:layout_below="@+id/portnumber"
+ android:layout_alignEnd="@+id/portnumber"
android:layout_alignRight="@+id/portnumber"
- android:layout_alignEnd="@+id/portnumber" />
+ android:layout_below="@+id/portnumber"
+ android:layout_gravity="right|bottom"
+ android:text="Enable" />
+
<ImageButton
- android:layout_margin="12dp"
+ android:id="@+id/remove_connection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:padding="12dp"
- android:layout_alignRight="@+id/portnumber"
android:layout_alignEnd="@+id/portnumber"
+ android:layout_alignRight="@+id/portnumber"
android:layout_below="@id/remoteSwitch"
+ android:layout_margin="12dp"
android:background="@drawable/ic_menu_delete_grey"
- android:id="@+id/remove_connection"
- android:contentDescription="@string/remove_connection_entry" />
+ android:contentDescription="@string/remove_connection_entry"
+ android:padding="12dp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
-
-
-
</FrameLayout> \ 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 @@
-<!--
- ~ Copyright (c) 2012-2014 Arne Schwabe
- ~ Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt
- -->
-
-<RelativeLayout
- android:padding="5dp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- xmlns:android="http://schemas.android.com/apk/res/android">
-
-
- <TextView
- style="@style/item"
- android:id="@+id/port_label"
- android:text="@string/port"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:layout_alignParentEnd="true"
- android:textAppearance="?android:attr/textAppearanceSmall" />
-
-
- <TextView
- style="@style/item"
- android:text="@string/address"
- android:id="@+id/server_label"
- android:textAppearance="?android:attr/textAppearanceSmall" />
-
-
- <EditText
- android:id="@+id/portnumber"
- android:layout_alignParentRight="true"
- android:layout_alignParentEnd="true"
- android:layout_below="@id/port_label"
- android:layout_width="wrap_content"
-
- android:layout_height="wrap_content"
- android:inputType="numberDecimal"
- android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
- android:text="1194" />
-
-
- <EditText
- android:id="@+id/servername"
- android:singleLine="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true"
- android:inputType="textUri"
- android:layout_below="@id/server_label"
- android:layout_toLeftOf="@id/portnumber"
- android:layout_toStartOf="@id/portnumber"
- android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
- android:text="openvpn.blinkt.de" />
-
- <TextView
- android:paddingTop="10dp"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@id/servername"
- android:id="@+id/protocol"
- android:text="Protocol" />
-
- <RadioGroup
- android:id="@+id/udptcpradiogroup"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@id/protocol"
- android:orientation="horizontal"
- android:paddingLeft="20dp">
-
- <RadioButton
- android:id="@+id/udp_proto"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="UDP" />
-
- <Space
- android:layout_width="20dp"
- android:layout_height="wrap_content" />
-
- <RadioButton
- android:id="@+id/tcp_proto"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="TCP" />
- </RadioGroup>
-
-<!-- <TextView
- android:paddingTop="10dp"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@id/udptcpradiogroup"
- android:id="@+id/proxytext"
- android:text="Proxy" />
-
- <RadioGroup
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:id="@+id/proxygroup"
- android:paddingLeft="20dp"
- android:layout_below="@id/proxytext">
-
- <RadioButton
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="None" />
-
- <Space
- android:layout_width="10dp"
- android:layout_height="wrap_content" />
-
- <RadioButton
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="HTTP" />
-
- <Space
- android:layout_width="10dp"
- android:layout_height="wrap_content" />
-
- <RadioButton
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Socks" />
- </RadioGroup> -->
-
-
- <CheckBox
- android:paddingTop="10dp"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@id/udptcpradiogroup"
- android:id="@+id/use_customoptions"
- android:text="Custom Options" />
-
- <LinearLayout
- android:paddingLeft="10dp"
- android:paddingStart="10dp"
- android:layout_below="@id/use_customoptions"
- android:layout_width="wrap_content"
- android:orientation="vertical"
- android:layout_height="wrap_content">
- <TextView
- android:id="@+id/warnung_custom"
- android:text="Specify custom connection specific options. Use with care"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <EditText
- android:inputType="textMultiLine"
- android:id="@+id/customoptions"
- android:lines="5"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
- </LinearLayout>
-
- <Switch
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Enable"
- android:id="@+id/remoteSwitch"
- android:layout_gravity="right|bottom"
- android:layout_below="@+id/portnumber"
- android:layout_alignRight="@+id/portnumber"
- android:layout_alignEnd="@+id/portnumber" />
-
-
-</RelativeLayout> \ 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 @@
<string name="Search">Search</string>
<string name="lastdumpdate">(Last dump is %1$d:%2$dh old (%3$s))</string>
<string name="clear_log_on_connect">Clear log on new connection</string>
+ <string name="connect_timeout">Connect Timeout</string>
</resources>