rules: support more dnsmasq rules. close #122
This commit is contained in:
parent
e559925805
commit
29b60b3ba7
@ -57,11 +57,13 @@ public class Daedalus extends Application {
|
||||
public static final ArrayList<Rule> RULES = new ArrayList<Rule>() {{
|
||||
add(new Rule("googlehosts/hosts", "googlehosts.hosts", Rule.TYPE_HOSTS,
|
||||
"https://raw.githubusercontent.com/googlehosts/hosts/master/hosts-files/hosts", false));
|
||||
add(new Rule("vokins/yhosts", "vokins.hosts", Rule.TYPE_HOSTS,
|
||||
"https://raw.githubusercontent.com/vokins/yhosts/master/hosts", false));
|
||||
add(new Rule("VeleSila/yhosts", "vokins.hosts", Rule.TYPE_HOSTS,
|
||||
"https://raw.githubusercontent.com/VeleSila/yhosts/master/hosts.txt", false));
|
||||
add(new Rule("adaway", "adaway.hosts", Rule.TYPE_HOSTS,
|
||||
"https://adaway.org/hosts.txt", false));
|
||||
//Build-in DNSMasq rule providers
|
||||
add(new Rule("anti-AD", "antiad.dnsmasq", Rule.TYPE_DNAMASQ,
|
||||
"https://anti-ad.net/anti-ad-for-dnsmasq.conf", false));
|
||||
add(new Rule("vokins/yhosts/union", "union.dnsmasq", Rule.TYPE_DNAMASQ,
|
||||
"https://raw.githubusercontent.com/vokins/yhosts/master/dnsmasq/union.conf", false));
|
||||
}};
|
||||
|
@ -108,7 +108,7 @@ public class RuleResolver implements Runnable {
|
||||
for (String hostsFile : hostsFiles) {
|
||||
File file = new File(hostsFile);
|
||||
if (file.canRead()) {
|
||||
Logger.info("Loading hosts from " + file.toString());
|
||||
Logger.info("Loading hosts from " + file);
|
||||
FileInputStream stream = new FileInputStream(file);
|
||||
BufferedReader dataIO = new BufferedReader(new InputStreamReader(stream));
|
||||
String strLine;
|
||||
@ -136,7 +136,7 @@ public class RuleResolver implements Runnable {
|
||||
for (String dnsmasqFile : dnsmasqFiles) {
|
||||
File file = new File(dnsmasqFile);
|
||||
if (file.canRead()) {
|
||||
Logger.info("Loading DNSMasq configuration from " + file.toString());
|
||||
Logger.info("Loading DNSMasq configuration from " + file);
|
||||
FileInputStream stream = new FileInputStream(file);
|
||||
BufferedReader dataIO = new BufferedReader(new InputStreamReader(stream));
|
||||
String strLine;
|
||||
@ -145,7 +145,12 @@ public class RuleResolver implements Runnable {
|
||||
while ((strLine = dataIO.readLine()) != null) {
|
||||
if (!strLine.equals("") && !strLine.startsWith("#")) {
|
||||
data = strLine.split("/");
|
||||
if (data.length == 3 && data[0].equals("address=")) {
|
||||
if (data.length >= 2 && data[0].equals("address=")) {
|
||||
if (data.length == 2) {
|
||||
rulesA.put(data[1], "0.0.0.0");
|
||||
count++;
|
||||
continue;
|
||||
}
|
||||
if (data[1].startsWith(".")) {
|
||||
data[1] = data[1].substring(1);
|
||||
}
|
||||
@ -153,6 +158,8 @@ public class RuleResolver implements Runnable {
|
||||
rulesAAAA.put(data[1], data[2]);
|
||||
} else if (strLine.contains(".")) {//IPv4
|
||||
rulesA.put(data[1], data[2]);
|
||||
} else {
|
||||
rulesA.put(data[1], "0.0.0.0");
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user