/*
- * Copyright (C) 2012-2017 Tobias Brunner
+ * Copyright (C) 2012-2019 Tobias Brunner
* Copyright (C) 2012 Giuliano Grassi
* Copyright (C) 2012 Ralf Sager
* HSR Hochschule fuer Technik Rapperswil
import org.strongswan.android.utils.IPRangeSet;
import org.strongswan.android.utils.Utils;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.SortedSet;
private EditText mEspProposal;
private TextView mProfileIdLabel;
private TextView mProfileId;
+ private MultiAutoCompleteTextView mDnsServers;
+ private TextInputLayoutHelper mDnsServersWrap;
@Override
public void onCreate(Bundle savedInstanceState)
mRemoteId = (MultiAutoCompleteTextView)findViewById(R.id.remote_id);
mRemoteIdWrap = (TextInputLayoutHelper) findViewById(R.id.remote_id_wrap);
+ mDnsServers = (MultiAutoCompleteTextView)findViewById(R.id.dns_servers);
+ mDnsServersWrap = (TextInputLayoutHelper) findViewById(R.id.dns_servers_wrap);
mMTU = (EditText)findViewById(R.id.mtu);
mMTUWrap = (TextInputLayoutHelper) findViewById(R.id.mtu_wrap);
mPort = (EditText)findViewById(R.id.port);
(flags != null && flags != 0) || (st != null && st != 0) ||
mProfile.getIncludedSubnets() != null || mProfile.getExcludedSubnets() != null ||
mProfile.getSelectedAppsHandling() != SelectedAppsHandling.SELECTED_APPS_DISABLE ||
- mProfile.getIkeProposal() != null || mProfile.getEspProposal() != null;
+ mProfile.getIkeProposal() != null || mProfile.getEspProposal() != null ||
+ mProfile.getDnsServers() != null;
}
mShowAdvanced.setVisibility(!show ? View.VISIBLE : View.GONE);
mAdvancedSettings.setVisibility(show ? View.VISIBLE : View.GONE);
mEspProposalWrap.setError(getString(R.string.alert_text_no_proposal));
valid = false;
}
+ if (!validateAddresses(mDnsServers))
+ {
+ mDnsServersWrap.setError(getString(R.string.alert_text_no_ips));
+ valid = false;
+ }
return valid;
}
mProfile.setIkeProposal(ike.isEmpty() ? null : ike);
String esp = mEspProposal.getText().toString().trim();
mProfile.setEspProposal(esp.isEmpty() ? null : esp);
+ String dns = mDnsServers.getText().toString().trim();
+ mProfile.setDnsServers(dns.isEmpty() ? null : dns);
}
/**
mSelectedApps = mProfile.getSelectedAppsSet();
mIkeProposal.setText(mProfile.getIkeProposal());
mEspProposal.setText(mProfile.getEspProposal());
+ mDnsServers.setText(mProfile.getDnsServers());
mProfileId.setText(mProfile.getUUID().toString());
flags = mProfile.getFlags();
useralias = mProfile.getUserCertificateAlias();
return value.isEmpty() || IPRangeSet.fromString(value) != null;
}
+ /**
+ * Check that the value in the given text box is a valid list of IP addresses
+ *
+ * @param view text box
+ */
+ private boolean validateAddresses(EditText view)
+ {
+ String value = view.getText().toString().trim();
+ if (value.isEmpty())
+ {
+ return true;
+ }
+ for (String addr : value.split("\\s+"))
+ {
+ try
+ {
+ InetAddress.getByName(addr);
+ }
+ catch (UnknownHostException e)
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
/**
* Check that the value in the given text box is a valid proposal
*
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2012-2018 Tobias Brunner
+ Copyright (C) 2012-2019 Tobias Brunner
Copyright (C) 2012 Giuliano Grassi
Copyright (C) 2012 Ralf Sager
HSR Hochschule fuer Technik Rapperswil
</org.strongswan.android.ui.widget.TextInputLayoutHelper>
+ <org.strongswan.android.ui.widget.TextInputLayoutHelper
+ android:id="@+id/dns_servers_wrap"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp"
+ android:hint="@string/profile_dns_servers_label"
+ app:helper_text="@string/profile_dns_servers_hint" >
+
+ <MultiAutoCompleteTextView
+ android:id="@+id/dns_servers"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:inputType="textNoSuggestions"
+ android:completionThreshold="1" />
+
+ </org.strongswan.android.ui.widget.TextInputLayoutHelper>
+
<org.strongswan.android.ui.widget.TextInputLayoutHelper
android:id="@+id/mtu_wrap"
android:layout_width="match_parent"
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2012-2018 Tobias Brunner
+ Copyright (C) 2012-2019 Tobias Brunner
Copyright (C) 2012 Giuliano Grassi
Copyright (C) 2012 Ralf Sager
HSR Hochschule fuer Technik Rapperswil
<string name="profile_remote_id_label">Server-Identität</string>
<string name="profile_remote_id_hint">Standardwert ist der konfigurierte Server. Eigene Werte werden explizit an den Server gesendet und während der Authentifizierung erzwungen</string>
<string name="profile_remote_id_hint_gateway">Standardwert ist \"%1$s\". Eigene Werte werden explizit an den Server gesendet und während der Authentifizierung erzwungen</string>
+ <string name="profile_dns_servers_label">DNS Server</string>
+ <string name="profile_dns_servers_hint">Benutzerdefinierte DNS Server bei Verbindung zum VPN (mit Leerzeichen getrennt, z.B.. \"8.8.8.8 2001:4860:4860::8888\", standardmässig werden die vom VPN Server erhaltenen Server verwendet)</string>
<string name="profile_mtu_label">MTU des VPN Tunnel-Device</string>
<string name="profile_mtu_hint">Falls der Standardwert in einem bestimmten Netzwerk nicht geeignet ist</string>
<string name="profile_port_label">Server Port</string>
<string name="alert_text_nocertfound">Bitte wählen Sie eines aus oder aktivieren Sie <i>Automatisch wählen</i></string>
<string name="alert_text_out_of_range">Bitte geben Sie eine Nummer von %1$d - %2$d ein</string>
<string name="alert_text_no_subnets">Bitte geben Sie mit Leerzeichen getrennte, gültige Subnetzte und/oder IP-Adressen ein</string>
+ <string name="alert_text_no_ips">Bitte geben Sie mit Leerzeichen getrennte, gültige IP-Adressen ein</string>
<string name="alert_text_no_proposal">Bitte geben Sie eine mit Bindestrichen getrennte, gültige Liste von Algorithmen ein</string>
<string name="tnc_notice_title">EAP-TNC kann Ihre Privatsphäre beeinträchtigen</string>
<string name="tnc_notice_subtitle">Gerätedaten werden an den Server-Betreiber gesendet</string>
<string name="profile_remote_id_label">Server identity</string>
<string name="profile_remote_id_hint">Defaults to the configured server. Custom values are explicitly sent to the server and enforced during authentication</string>
<string name="profile_remote_id_hint_gateway">Defaults to \"%1$s\". Custom values are explicitly sent to the server and enforced during authentication</string>
+ <string name="profile_dns_servers_label">DNS servers</string>
+ <string name="profile_dns_servers_hint">Custom DNS servers to use when connected to the VPN (separated by spaces, e.g. \"8.8.8.8 2001:4860:4860::8888\", defaults to those received from the VPN server)</string>
<string name="profile_mtu_label">MTU of the VPN tunnel device</string>
<string name="profile_mtu_hint">In case the default value is unsuitable for a particular network</string>
<string name="profile_port_label">Server port</string>
<string name="alert_text_nocertfound">Wybierz lub uaktywnij jeden <i>Wybierz automatycznie</i></string>
<string name="alert_text_out_of_range">Please enter a number in the range from %1$d - %2$d</string>
<string name="alert_text_no_subnets">Please enter valid subnets and/or IP addresses, separated by spaces</string>
+ <string name="alert_text_no_ips">Please enter valid IP addresses, separated by spaces</string>
<string name="alert_text_no_proposal">Please enter a valid list of algorithms, separated by hyphens</string>
<string name="tnc_notice_title">EAP-TNC may affect your privacy</string>
<string name="tnc_notice_subtitle">Device data is sent to the server operator</string>
<string name="profile_remote_id_label">Server identity</string>
<string name="profile_remote_id_hint">Defaults to the configured server. Custom values are explicitly sent to the server and enforced during authentication</string>
<string name="profile_remote_id_hint_gateway">Defaults to \"%1$s\". Custom values are explicitly sent to the server and enforced during authentication</string>
+ <string name="profile_dns_servers_label">DNS servers</string>
+ <string name="profile_dns_servers_hint">Custom DNS servers to use when connected to the VPN (separated by spaces, e.g. \"8.8.8.8 2001:4860:4860::8888\", defaults to those received from the VPN server)</string>
<string name="profile_mtu_label">MTU of the VPN tunnel device</string>
<string name="profile_mtu_hint">In case the default value is unsuitable for a particular network</string>
<string name="profile_port_label">Server port</string>
<string name="alert_text_nocertfound">Пожалуйста выберите один <i>Выбрать автоматически</i></string>
<string name="alert_text_out_of_range">Please enter a number in the range from %1$d - %2$d</string>
<string name="alert_text_no_subnets">Please enter valid subnets and/or IP addresses, separated by spaces</string>
+ <string name="alert_text_no_ips">Please enter valid IP addresses, separated by spaces</string>
<string name="alert_text_no_proposal">Please enter a valid list of algorithms, separated by hyphens</string>
<string name="tnc_notice_title">EAP-TNC may affect your privacy</string>
<string name="tnc_notice_subtitle">Device data is sent to the server operator</string>
<string name="profile_remote_id_label">Server identity</string>
<string name="profile_remote_id_hint">Defaults to the configured server. Custom values are explicitly sent to the server and enforced during authentication</string>
<string name="profile_remote_id_hint_gateway">Defaults to \"%1$s\". Custom values are explicitly sent to the server and enforced during authentication</string>
+ <string name="profile_dns_servers_label">DNS servers</string>
+ <string name="profile_dns_servers_hint">Custom DNS servers to use when connected to the VPN (separated by spaces, e.g. \"8.8.8.8 2001:4860:4860::8888\", defaults to those received from the VPN server)</string>
<string name="profile_mtu_label">MTU of the VPN tunnel device</string>
<string name="profile_mtu_hint">In case the default value is unsuitable for a particular network</string>
<string name="profile_port_label">Server port</string>
<string name="alert_text_nocertfound">Будь ласка виберіть один <i>Вибрати автоматично</i></string>
<string name="alert_text_out_of_range">Please enter a number in the range from %1$d - %2$d</string>
<string name="alert_text_no_subnets">Please enter valid subnets and/or IP addresses, separated by spaces</string>
+ <string name="alert_text_no_ips">Please enter valid IP addresses, separated by spaces</string>
<string name="alert_text_no_proposal">Please enter a valid list of algorithms, separated by hyphens</string>
<string name="tnc_notice_title">EAP-TNC may affect your privacy</string>
<string name="tnc_notice_subtitle">Device data is sent to the server operator</string>
<string name="alert_text_nocertfound">请选择一项或激活 <i>自动选择</i></string>
<string name="alert_text_out_of_range">请输入一个数字范围从%1$d到%2$d</string>
<string name="alert_text_no_subnets">Please enter valid subnets and/or IP addresses, separated by spaces</string>
+ <string name="alert_text_no_ips">Please enter valid IP addresses, separated by spaces</string>
<string name="alert_text_no_proposal">Please enter a valid list of algorithms, separated by hyphens</string>
<string name="tnc_notice_title">EAP-TNC可能会影响您的隐私</string>
<string name="tnc_notice_subtitle">设备数据已被发送至服务器管理员</string>
<string name="profile_remote_id_label">伺服器ID</string>
<string name="profile_remote_id_hint">預設為已設定的伺服器位置。自訂值會在授權期間送到伺服器</string>
<string name="profile_remote_id_hint_gateway">預設為 \"%1$s\"。自訂值會在授權期間送到伺服器</string>
+ <string name="profile_dns_servers_label">DNS servers</string>
+ <string name="profile_dns_servers_hint">Custom DNS servers to use when connected to the VPN (separated by spaces, e.g. \"8.8.8.8 2001:4860:4860::8888\", defaults to those received from the VPN server)</string>
<string name="profile_mtu_label">VPN通道裝置的MTU值</string>
<string name="profile_mtu_hint">如果在某個網路下預設值不適合</string>
<string name="profile_port_label">伺服器Port</string>
<string name="alert_text_nocertfound">請選擇一項或啟動 <i>自動選擇</i></string>
<string name="alert_text_out_of_range">請輸入一個數字範圍從%1$d到%2$d</string>
<string name="alert_text_no_subnets">Please enter valid subnets and/or IP addresses, separated by spaces</string>
+ <string name="alert_text_no_ips">Please enter valid IP addresses, separated by spaces</string>
<string name="alert_text_no_proposal">Please enter a valid list of algorithms, separated by hyphens</string>
<string name="tnc_notice_title">EAP-TNC可能會影響您的隱私安全</string>
<string name="tnc_notice_subtitle">裝置資料已經發送給伺服器管理者</string>
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2012-2018 Tobias Brunner
+ Copyright (C) 2012-2019 Tobias Brunner
Copyright (C) 2012 Giuliano Grassi
Copyright (C) 2012 Ralf Sager
HSR Hochschule fuer Technik Rapperswil
<string name="profile_remote_id_label">Server identity</string>
<string name="profile_remote_id_hint">Defaults to the configured server. Custom values are explicitly sent to the server and enforced during authentication</string>
<string name="profile_remote_id_hint_gateway">Defaults to \"%1$s\". Custom values are explicitly sent to the server and enforced during authentication</string>
+ <string name="profile_dns_servers_label">DNS servers</string>
+ <string name="profile_dns_servers_hint">Custom DNS servers to use when connected to the VPN (separated by spaces, e.g. \"8.8.8.8 2001:4860:4860::8888\", defaults to those received from the VPN server)</string>
<string name="profile_mtu_label">MTU of the VPN tunnel device</string>
<string name="profile_mtu_hint">In case the default value is unsuitable for a particular network</string>
<string name="profile_port_label">Server port</string>
<string name="alert_text_nocertfound">Please select one or activate <i>Select automatically</i></string>
<string name="alert_text_out_of_range">Please enter a number in the range from %1$d - %2$d</string>
<string name="alert_text_no_subnets">Please enter valid subnets and/or IP addresses, separated by spaces</string>
+ <string name="alert_text_no_ips">Please enter valid IP addresses, separated by spaces</string>
<string name="alert_text_no_proposal">Please enter a valid list of algorithms, separated by hyphens</string>
<string name="tnc_notice_title">EAP-TNC may affect your privacy</string>
<string name="tnc_notice_subtitle">Device data is sent to the server operator</string>