Fixed cannot reload RuleResolver when no rule is activated
This commit is contained in:
parent
57191b8fd0
commit
ace52e19b4
@ -140,7 +140,7 @@ public class Daedalus extends Application {
|
||||
return gson.fromJson(reader, beanClass);
|
||||
}
|
||||
|
||||
public static void initHostsResolver() {
|
||||
public static void initRuleResolver() {
|
||||
if (Daedalus.getPrefs().getBoolean("settings_local_rules_resolution", false)) {
|
||||
ArrayList<String> pendingLoad = new ArrayList<>();
|
||||
ArrayList<Rule> usingRules = configurations.getUsingRules();
|
||||
@ -161,6 +161,8 @@ public class Daedalus extends Application {
|
||||
RuleResolver.startLoadDnsmasq(arr);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
RuleResolver.clear();
|
||||
}
|
||||
} else {
|
||||
RuleResolver.clear();
|
||||
@ -171,7 +173,7 @@ public class Daedalus extends Application {
|
||||
public static void setRulesChanged() {
|
||||
if (DaedalusVpnService.isActivated() &&
|
||||
getPrefs().getBoolean("settings_allow_dynamic_rule_reload", false)) {
|
||||
initHostsResolver();
|
||||
initRuleResolver();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class DaedalusVpnService extends VpnService implements Runnable {
|
||||
this.notification = builder;
|
||||
}
|
||||
|
||||
Daedalus.initHostsResolver();
|
||||
Daedalus.initRuleResolver();
|
||||
DNSServerHelper.buildPortCache();
|
||||
|
||||
if (this.mThread == null) {
|
||||
|
@ -33,8 +33,8 @@ public class RuleResolver implements Runnable {
|
||||
private static int mode = MODE_HOSTS;
|
||||
private static String[] hostsFiles;
|
||||
private static String[] dnsmasqFiles;
|
||||
private static HashMap<String, String> rulesA;
|
||||
private static HashMap<String, String> rulesAAAA;
|
||||
private static HashMap<String, String> rulesA = new HashMap<>();
|
||||
private static HashMap<String, String> rulesAAAA = new HashMap<>();
|
||||
private static boolean shutdown = false;
|
||||
|
||||
public RuleResolver() {
|
||||
@ -61,18 +61,20 @@ public class RuleResolver implements Runnable {
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
rulesA = null;
|
||||
rulesAAAA = null;
|
||||
rulesA = new HashMap<>();
|
||||
rulesAAAA = new HashMap<>();
|
||||
}
|
||||
|
||||
public static String resolve(String hostname, Record.TYPE type) {
|
||||
HashMap<String, String> rules = null;
|
||||
HashMap<String, String> rules;
|
||||
if (type == Record.TYPE.A) {
|
||||
rules = rulesA;
|
||||
} else if (type == Record.TYPE.AAAA) {
|
||||
rules = rulesAAAA;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
if (rules == null) {
|
||||
if (rules.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
if (rules.containsKey(hostname)) {
|
||||
|
Loading…
Reference in New Issue
Block a user