1
0
Fork 0
mirror of https://github.com/M66B/NetGuard.git synced 2024-12-22 07:43:15 +00:00

COpy search domain from active network

This commit is contained in:
M66B 2024-02-17 16:03:24 +01:00
parent a3375e11c8
commit 37ff174b1f

View file

@ -1291,6 +1291,20 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
try {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
Network active = (cm == null ? null : cm.getActiveNetwork());
LinkProperties props = (active == null ? null : cm.getLinkProperties(active));
String domain = (props == null ? null : props.getDomains());
if (domain != null) {
Log.i(TAG, "Using search domain=" + domain);
builder.addSearchDomain(domain);
}
} catch (Throwable ex) {
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
}
// Subnet routing
if (subnet) {
// Exclude IP ranges