mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-16 00:00:37 -04:00
android: Import DNS servers
This commit is contained in:
parent
dd5de792cf
commit
1a39c3d98d
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2016-2018 Tobias Brunner
|
* Copyright (C) 2016-2019 Tobias Brunner
|
||||||
* HSR Hochschule fuer Technik Rapperswil
|
* HSR Hochschule fuer Technik Rapperswil
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
@ -65,6 +65,7 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.security.KeyStore;
|
import java.security.KeyStore;
|
||||||
@ -74,6 +75,7 @@ import java.security.cert.CertificateException;
|
|||||||
import java.security.cert.CertificateFactory;
|
import java.security.cert.CertificateFactory;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.net.ssl.SSLHandshakeException;
|
import javax.net.ssl.SSLHandshakeException;
|
||||||
@ -522,6 +524,7 @@ public class VpnProfileImportActivity extends AppCompatActivity
|
|||||||
|
|
||||||
profile.setIkeProposal(getProposal(obj, "ike-proposal", true));
|
profile.setIkeProposal(getProposal(obj, "ike-proposal", true));
|
||||||
profile.setEspProposal(getProposal(obj, "esp-proposal", false));
|
profile.setEspProposal(getProposal(obj, "esp-proposal", false));
|
||||||
|
profile.setDnsServers(getAddressList(obj, "dns-servers"));
|
||||||
profile.setMTU(getInteger(obj, "mtu", Constants.MTU_MIN, Constants.MTU_MAX));
|
profile.setMTU(getInteger(obj, "mtu", Constants.MTU_MIN, Constants.MTU_MAX));
|
||||||
profile.setNATKeepAlive(getInteger(obj, "nat-keepalive", Constants.NAT_KEEPALIVE_MIN, Constants.NAT_KEEPALIVE_MAX));
|
profile.setNATKeepAlive(getInteger(obj, "nat-keepalive", Constants.NAT_KEEPALIVE_MIN, Constants.NAT_KEEPALIVE_MAX));
|
||||||
JSONObject split = obj.optJSONObject("split-tunneling");
|
JSONObject split = obj.optJSONObject("split-tunneling");
|
||||||
@ -605,6 +608,44 @@ public class VpnProfileImportActivity extends AppCompatActivity
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getAddressList(JSONObject obj, String key) throws JSONException
|
||||||
|
{
|
||||||
|
ArrayList<String> addrs = new ArrayList<>();
|
||||||
|
JSONArray arr = obj.optJSONArray(key);
|
||||||
|
if (arr != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < arr.length(); i++)
|
||||||
|
{
|
||||||
|
String addr = arr.getString(i).replace(" ", "");
|
||||||
|
addrs.add(addr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
String value = obj.optString(key, null);
|
||||||
|
if (!TextUtils.isEmpty(value))
|
||||||
|
{
|
||||||
|
Collections.addAll(addrs, value.split("\\s+"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (addrs.size() > 0)
|
||||||
|
{
|
||||||
|
for (String addr : addrs)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
InetAddress.getByName(addr);
|
||||||
|
}
|
||||||
|
catch (UnknownHostException e)
|
||||||
|
{
|
||||||
|
throw new JSONException(getString(R.string.profile_import_failed_value, key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TextUtils.join(" ", addrs);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private String getApps(JSONArray arr) throws JSONException
|
private String getApps(JSONArray arr) throws JSONException
|
||||||
{
|
{
|
||||||
ArrayList<String> apps = new ArrayList<>();
|
ArrayList<String> apps = new ArrayList<>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user