diff --git a/app/src/main/java/eu/faircode/netguard/SinkholeService.java b/app/src/main/java/eu/faircode/netguard/SinkholeService.java index eceb4695..a19f85ac 100644 --- a/app/src/main/java/eu/faircode/netguard/SinkholeService.java +++ b/app/src/main/java/eu/faircode/netguard/SinkholeService.java @@ -40,6 +40,7 @@ import android.graphics.Paint; import android.graphics.Path; import android.graphics.Typeface; import android.net.ConnectivityManager; +import android.net.NetworkInfo; import android.net.TrafficStats; import android.net.VpnService; import android.os.Build; @@ -2013,11 +2014,18 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS } private class Builder extends VpnService.Builder { + private NetworkInfo networkInfo; private List listAddress = new ArrayList<>(); private List listRoute = new ArrayList<>(); private List listDns = new ArrayList<>(); private List listDisallowed = new ArrayList<>(); + private Builder() { + super(); + ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); + networkInfo = cm.getActiveNetworkInfo(); + } + @Override public Builder addAddress(String address, int prefixLength) { listAddress.add(address + "/" + prefixLength); @@ -2053,6 +2061,10 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS if (other == null) return false; + if (this.networkInfo == null || other.networkInfo == null || + this.networkInfo.getType() != other.networkInfo.getType()) + return false; + if (this.listAddress.size() != other.listAddress.size()) return false;