android: Use helper to parse IP addresses where appropriate

This commit is contained in:
Tobias Brunner 2019-03-05 19:02:05 +01:00
parent 7028e9d31e
commit 2ef473be15
4 changed files with 8 additions and 9 deletions

View File

@ -58,6 +58,7 @@ import org.strongswan.android.utils.Constants;
import org.strongswan.android.utils.IPRange;
import org.strongswan.android.utils.IPRangeSet;
import org.strongswan.android.utils.SettingsWriter;
import org.strongswan.android.utils.Utils;
import java.io.File;
import java.io.FileInputStream;
@ -1117,7 +1118,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
{
try
{
mDnsServers.add(InetAddress.getByName(server));
mDnsServers.add(Utils.parseInetAddress(server));
recordAddressFamily(server);
mDnsServersConfigured = true;
}
@ -1156,7 +1157,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
try
{
mDnsServers.add(InetAddress.getByName(address));
mDnsServers.add(Utils.parseInetAddress(address));
recordAddressFamily(address);
}
catch (UnknownHostException e)
@ -1341,7 +1342,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
private boolean isIPv6(String address) throws UnknownHostException
{
InetAddress addr = InetAddress.getByName(address);
InetAddress addr = Utils.parseInetAddress(address);
if (addr instanceof Inet4Address)
{
return false;

View File

@ -72,7 +72,6 @@ import org.strongswan.android.utils.Constants;
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;
@ -915,7 +914,7 @@ public class VpnProfileDetailActivity extends AppCompatActivity
{
try
{
InetAddress.getByName(addr);
Utils.parseInetAddress(addr);
}
catch (UnknownHostException e)
{

View File

@ -65,7 +65,6 @@ import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.URL;
import java.net.UnknownHostException;
import java.security.KeyStore;
@ -634,7 +633,7 @@ public class VpnProfileImportActivity extends AppCompatActivity
{
try
{
InetAddress.getByName(addr);
Utils.parseInetAddress(addr);
}
catch (UnknownHostException e)
{

View File

@ -76,7 +76,7 @@ public class IPRange implements Comparable<IPRange>
public IPRange(String from, String to) throws UnknownHostException
{
this(InetAddress.getByName(from), InetAddress.getByName(to));
this(Utils.parseInetAddress(from), Utils.parseInetAddress(to));
}
public IPRange(InetAddress from, InetAddress to)
@ -106,7 +106,7 @@ public class IPRange implements Comparable<IPRange>
public IPRange(String base, int prefix) throws UnknownHostException
{
this(InetAddress.getByName(base), prefix);
this(Utils.parseInetAddress(base), prefix);
}
public IPRange(InetAddress base, int prefix)