Skip to content

Commit 29b60b3

Browse files
committed
rules: support more dnsmasq rules. close #122
1 parent e559925 commit 29b60b3

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

app/src/main/java/org/itxtech/daedalus/Daedalus.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ public class Daedalus extends Application {
5757
public static final ArrayList<Rule> RULES = new ArrayList<Rule>() {{
5858
add(new Rule("googlehosts/hosts", "googlehosts.hosts", Rule.TYPE_HOSTS,
5959
"https://raw.githubusercontent.com/googlehosts/hosts/master/hosts-files/hosts", false));
60-
add(new Rule("vokins/yhosts", "vokins.hosts", Rule.TYPE_HOSTS,
61-
"https://raw.githubusercontent.com/vokins/yhosts/master/hosts", false));
60+
add(new Rule("VeleSila/yhosts", "vokins.hosts", Rule.TYPE_HOSTS,
61+
"https://raw.githubusercontent.com/VeleSila/yhosts/master/hosts.txt", false));
6262
add(new Rule("adaway", "adaway.hosts", Rule.TYPE_HOSTS,
6363
"https://adaway.org/hosts.txt", false));
6464
//Build-in DNSMasq rule providers
65+
add(new Rule("anti-AD", "antiad.dnsmasq", Rule.TYPE_DNAMASQ,
66+
"https://anti-ad.net/anti-ad-for-dnsmasq.conf", false));
6567
add(new Rule("vokins/yhosts/union", "union.dnsmasq", Rule.TYPE_DNAMASQ,
6668
"https://raw.githubusercontent.com/vokins/yhosts/master/dnsmasq/union.conf", false));
6769
}};

app/src/main/java/org/itxtech/daedalus/util/RuleResolver.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private void load() {
108108
for (String hostsFile : hostsFiles) {
109109
File file = new File(hostsFile);
110110
if (file.canRead()) {
111-
Logger.info("Loading hosts from " + file.toString());
111+
Logger.info("Loading hosts from " + file);
112112
FileInputStream stream = new FileInputStream(file);
113113
BufferedReader dataIO = new BufferedReader(new InputStreamReader(stream));
114114
String strLine;
@@ -136,7 +136,7 @@ private void load() {
136136
for (String dnsmasqFile : dnsmasqFiles) {
137137
File file = new File(dnsmasqFile);
138138
if (file.canRead()) {
139-
Logger.info("Loading DNSMasq configuration from " + file.toString());
139+
Logger.info("Loading DNSMasq configuration from " + file);
140140
FileInputStream stream = new FileInputStream(file);
141141
BufferedReader dataIO = new BufferedReader(new InputStreamReader(stream));
142142
String strLine;
@@ -145,14 +145,21 @@ private void load() {
145145
while ((strLine = dataIO.readLine()) != null) {
146146
if (!strLine.equals("") && !strLine.startsWith("#")) {
147147
data = strLine.split("/");
148-
if (data.length == 3 && data[0].equals("address=")) {
148+
if (data.length >= 2 && data[0].equals("address=")) {
149+
if (data.length == 2) {
150+
rulesA.put(data[1], "0.0.0.0");
151+
count++;
152+
continue;
153+
}
149154
if (data[1].startsWith(".")) {
150155
data[1] = data[1].substring(1);
151156
}
152157
if (strLine.contains(":")) {//IPv6
153158
rulesAAAA.put(data[1], data[2]);
154159
} else if (strLine.contains(".")) {//IPv4
155160
rulesA.put(data[1], data[2]);
161+
} else {
162+
rulesA.put(data[1], "0.0.0.0");
156163
}
157164
count++;
158165
}

0 commit comments

Comments
 (0)