summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2022-12-14 13:48:50 +0100
committerArne Schwabe <arne@rfc2549.org>2022-12-14 13:48:50 +0100
commit00097e479ba05462da3b0cc4794952ebfe1fea73 (patch)
tree7e693de9909ee937685baacad4e972de5df3814b /main
parentc2924c6da1bbac9a29d2d276165f28dd399971ba (diff)
Do not use IpPrefix constructor on older APIs
This method is not part of the official API but most devices still have it but some don't (closes #1558)
Diffstat (limited to 'main')
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java6
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/NetworkUtils.java6
2 files changed, 6 insertions, 6 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java b/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java
index 9c8cf363..da53831b 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java
+++ b/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java
@@ -5,11 +5,13 @@
package de.blinkt.openvpn.core;
+import android.annotation.TargetApi;
import android.net.IpPrefix;
+import android.os.Build;
import androidx.annotation.NonNull;
-import java.lang.reflect.Array;
+import java.lang.annotation.Target;
import java.math.BigInteger;
import java.net.Inet4Address;
import java.net.Inet6Address;
@@ -132,6 +134,7 @@ public class NetworkSpace {
}
+ @NonNull
@Override
public String toString() {
//String in = included ? "+" : "-";
@@ -210,6 +213,7 @@ public class NetworkSpace {
}
+ @TargetApi(Build.VERSION_CODES.TIRAMISU)
public IpPrefix getPrefix() throws UnknownHostException {
if (isV4){
/* add 0x01 00 00 00 00, so that all representations are 5 byte otherwise
diff --git a/main/src/main/java/de/blinkt/openvpn/core/NetworkUtils.java b/main/src/main/java/de/blinkt/openvpn/core/NetworkUtils.java
index 67cdb243..f104d3b0 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/NetworkUtils.java
+++ b/main/src/main/java/de/blinkt/openvpn/core/NetworkUtils.java
@@ -56,11 +56,7 @@ public class NetworkUtils {
else
ipaddress = new NetworkSpace.IpAddress(new CIDRIP(la.getAddress().getHostAddress(), la.getPrefixLength()), true);
- try {
- nets.add(ipaddress.getPrefix().toString());
- } catch (UnknownHostException ia) {
- VpnStatus.logError("getLocalNetworks error: " + ipaddress + " " + ia.getLocalizedMessage());
- }
+ nets.add(ipaddress.toString());
}
}
}