Skip to content

Commit

Permalink
2.0.6 correção de processamento DNSBL
Browse files Browse the repository at this point in the history
  • Loading branch information
leonamp committed Apr 5, 2016
1 parent 1ef5603 commit 9f53d19
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 deletions.
Binary file modified dist/SPFBL.jar
Binary file not shown.
8 changes: 4 additions & 4 deletions src/net/spfbl/core/Client.java
Expand Up @@ -476,13 +476,13 @@ public String getFrequencyLiteral() {
sinal = '>';
}
if (frequencyInt >= 3600000) {
return sinal + frequencyInt / 3600000 + "h";
return sinal + ((frequencyInt / 3600000) + "h");
} else if (frequencyInt >= 60000) {
return sinal + frequencyInt / 60000 + "min";
return sinal + ((frequencyInt / 60000) + "min");
} else if (frequencyInt >= 1000) {
return sinal + frequencyInt / 1000 + "s";
return sinal + ((frequencyInt / 1000) + "s");
} else {
return sinal + frequencyInt + "ms";
return sinal + (frequencyInt + "ms");
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/net/spfbl/core/Core.java
Expand Up @@ -67,7 +67,7 @@ public class Core {

private static final byte VERSION = 2;
private static final byte SUBVERSION = 0;
private static final byte RELEASE = 5;
private static final byte RELEASE = 6;

public static String getAplication() {
return "SPFBL-" + getVersion();
Expand Down
8 changes: 4 additions & 4 deletions src/net/spfbl/core/Peer.java
Expand Up @@ -957,13 +957,13 @@ public String getFrequencyLiteral() {
sinal = '>';
}
if (frequencyInt >= 3600000) {
return sinal + frequencyInt / 3600000 + "h";
return sinal + ((frequencyInt / 3600000) + "h");
} else if (frequencyInt >= 60000) {
return sinal + frequencyInt / 60000 + "min";
return sinal + ((frequencyInt / 60000) + "min");
} else if (frequencyInt >= 1000) {
return sinal + frequencyInt / 1000 + "s";
return sinal + ((frequencyInt / 1000) + "s");
} else {
return sinal + frequencyInt + "ms";
return sinal + (frequencyInt + "ms");
}
}
} else {
Expand Down
34 changes: 19 additions & 15 deletions src/net/spfbl/dnsbl/QueryDNSBL.java
Expand Up @@ -372,14 +372,14 @@ public void run() {
String permission = (domain == null || Block.containsHostIP(hostame, ip)) ? "NONE" : "DNSBL";
client = Client.create(cidr, domain, permission, null);
if (client != null) {
client.setLimit(10000);
client.setLimit(1000);
Server.logTrace("CLIENT ADDED " + client);
}
}
}
if (client == null) {
result = "IGNORED";
} else if (client.getPermission() != Permission.DNSBL) {
} else if (!client.hasPermission(Permission.DNSBL)) {
client.addQuery();
origin += ' ' + client.getDomain();
result = "IGNORED";
Expand Down Expand Up @@ -418,14 +418,6 @@ public void run() {
} else if (reverse.length() == 0) {
// O reverso é inválido.
result = "NXDOMAIN";
} else if (type.equals("TXT")) {
String information = server.getMessage();
if (information == null) {
result = "NXDOMAIN";
} else {
result = information;
ttl = 1814400; // Três semanas somente para TXT.
}
} else if (SubnetIPv4.isValidIPv4(reverse)) {
// A consulta é um IPv4.
String ip = SubnetIPv4.reverseToIPv4(reverse);
Expand Down Expand Up @@ -461,6 +453,18 @@ public void run() {
result = "NXDOMAIN";
}
}
if (type.equals("TXT") && result.equals("127.0.0.2")) {
if (server == null) {
result = "NXDOMAIN";
} else {
String information = server.getMessage();
if (information == null) {
result = "NXDOMAIN";
} else {
result = information;
}
}
}
// Alterando mensagem DNS para resposta.
header.setFlag(Flags.QR);
header.setFlag(Flags.AA);
Expand All @@ -476,13 +480,13 @@ public void run() {
name, SERIAL, refresh, retry, expire, minimum);
message.addRecord(soa, Section.AUTHORITY);
}
} else if (result.equals("127.0.0.2")) {
} else if (type.equals("TXT")) {
TXTRecord txt = new TXTRecord(name, DClass.IN, ttl, result);
message.addRecord(txt, Section.ANSWER);
} else {
InetAddress address = InetAddress.getByName(result);
ARecord a = new ARecord(name, DClass.IN, ttl, address);
message.addRecord(a, Section.ANSWER);
} else {
TXTRecord txt = new TXTRecord(name, DClass.IN, ttl, result);
message.addRecord(txt, Section.ANSWER);
}
result = ttl + " " + result;
// Enviando resposta.
Expand All @@ -494,7 +498,7 @@ public void run() {
);
SERVER_SOCKET.send(sendPacket);
}
query = type + ' ' + query;
query = type + " " + query;
} catch (SocketException ex) {
// Houve fechamento do socket.
result = "CLOSED";
Expand Down

0 comments on commit 9f53d19

Please sign in to comment.