mirror of
https://github.com/M66B/NetGuard.git
synced 2025-01-03 05:44:14 +00:00
Revert "Selectively sinkhole in non filtering mode"
This reverts commit 57d40a479f
.
This commit is contained in:
parent
98129bdecb
commit
dd7b99807d
2 changed files with 13 additions and 48 deletions
|
@ -43,7 +43,6 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class Rule {
|
public class Rule {
|
||||||
private static final String TAG = "NetGuard.Rule";
|
private static final String TAG = "NetGuard.Rule";
|
||||||
|
@ -446,21 +445,6 @@ public class Rule {
|
||||||
updateChanged(default_wifi, default_other, default_roaming);
|
updateChanged(default_wifi, default_other, default_roaming);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (obj instanceof Rule) {
|
|
||||||
Rule other = (Rule) obj;
|
|
||||||
return (this.uid == other.uid &&
|
|
||||||
Objects.equals(this.packageName, other.packageName));
|
|
||||||
} else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return (this.packageName == null ? this.uid : this.packageName.hashCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
// This is used in the port forwarding dialog application selector
|
// This is used in the port forwarding dialog application selector
|
||||||
|
|
|
@ -1409,22 +1409,19 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
|
|
||||||
// Add list of allowed applications
|
// Add list of allowed applications
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
if (last_connected && !filter) {
|
|
||||||
for (Rule rule : listRule)
|
|
||||||
if (!listAllowed.contains(rule))
|
|
||||||
try {
|
|
||||||
Log.i(TAG, "Sink=" + rule.packageName);
|
|
||||||
builder.addAllowedApplication(rule.packageName);
|
|
||||||
} catch (PackageManager.NameNotFoundException ex) {
|
|
||||||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
|
||||||
}
|
|
||||||
} else if (filter) {
|
|
||||||
try {
|
try {
|
||||||
builder.addDisallowedApplication(getPackageName());
|
builder.addDisallowedApplication(getPackageName());
|
||||||
} catch (PackageManager.NameNotFoundException ex) {
|
} catch (PackageManager.NameNotFoundException ex) {
|
||||||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||||
}
|
}
|
||||||
|
if (last_connected && !filter)
|
||||||
|
for (Rule rule : listAllowed)
|
||||||
|
try {
|
||||||
|
builder.addDisallowedApplication(rule.packageName);
|
||||||
|
} catch (PackageManager.NameNotFoundException ex) {
|
||||||
|
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||||
|
}
|
||||||
|
else if (filter)
|
||||||
for (Rule rule : listRule)
|
for (Rule rule : listRule)
|
||||||
if (!rule.apply || (!system && rule.system))
|
if (!rule.apply || (!system && rule.system))
|
||||||
try {
|
try {
|
||||||
|
@ -1434,7 +1431,6 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Build configure intent
|
// Build configure intent
|
||||||
Intent configure = new Intent(this, ActivityMain.class);
|
Intent configure = new Intent(this, ActivityMain.class);
|
||||||
|
@ -3073,7 +3069,6 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
private List<String> listAddress = new ArrayList<>();
|
private List<String> listAddress = new ArrayList<>();
|
||||||
private List<String> listRoute = new ArrayList<>();
|
private List<String> listRoute = new ArrayList<>();
|
||||||
private List<InetAddress> listDns = new ArrayList<>();
|
private List<InetAddress> listDns = new ArrayList<>();
|
||||||
private List<String> listAllowed = new ArrayList<>();
|
|
||||||
private List<String> listDisallowed = new ArrayList<>();
|
private List<String> listDisallowed = new ArrayList<>();
|
||||||
|
|
||||||
private Builder() {
|
private Builder() {
|
||||||
|
@ -3117,13 +3112,6 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Builder addAllowedApplication(String packageName) throws PackageManager.NameNotFoundException {
|
|
||||||
listAllowed.add(packageName);
|
|
||||||
super.addAllowedApplication(packageName);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Builder addDisallowedApplication(String packageName) throws PackageManager.NameNotFoundException {
|
public Builder addDisallowedApplication(String packageName) throws PackageManager.NameNotFoundException {
|
||||||
listDisallowed.add(packageName);
|
listDisallowed.add(packageName);
|
||||||
|
@ -3154,9 +3142,6 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
if (this.listDns.size() != other.listDns.size())
|
if (this.listDns.size() != other.listDns.size())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (this.listAllowed.size() != other.listAllowed.size())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (this.listDisallowed.size() != other.listDisallowed.size())
|
if (this.listDisallowed.size() != other.listDisallowed.size())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -3172,10 +3157,6 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
if (!other.listDns.contains(dns))
|
if (!other.listDns.contains(dns))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (String pkg : this.listAllowed)
|
|
||||||
if (!other.listAllowed.contains(pkg))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for (String pkg : this.listDisallowed)
|
for (String pkg : this.listDisallowed)
|
||||||
if (!other.listDisallowed.contains(pkg))
|
if (!other.listDisallowed.contains(pkg))
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue