1
0
Fork 0
mirror of https://github.com/M66B/NetGuard.git synced 2025-02-25 07:32:46 +00:00

Check if VPN IP/DNS address is numeric

This commit is contained in:
M66B 2016-02-27 09:17:44 +01:00
parent 4c8058b240
commit e4c63e0355

View file

@ -650,6 +650,8 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
private void checkAddress(String address) throws IllegalArgumentException, UnknownHostException { private void checkAddress(String address) throws IllegalArgumentException, UnknownHostException {
if (address == null || TextUtils.isEmpty(address.trim())) if (address == null || TextUtils.isEmpty(address.trim()))
throw new IllegalArgumentException("Bad address"); throw new IllegalArgumentException("Bad address");
if (!Util.isNumericAddress(address))
throw new IllegalArgumentException("Bad address");
InetAddress idns = InetAddress.getByName(address); InetAddress idns = InetAddress.getByName(address);
if (idns.isLoopbackAddress() || idns.isAnyLocalAddress()) if (idns.isLoopbackAddress() || idns.isAnyLocalAddress())
throw new IllegalArgumentException("Bad address"); throw new IllegalArgumentException("Bad address");