Local resolver Response flag fix

This commit is contained in:
PeratX 2017-09-06 19:55:23 +08:00
parent 2522125a55
commit 89b9c0ef95
2 changed files with 11 additions and 11 deletions

View File

@ -159,13 +159,13 @@ public class DNSTestFragment extends ToolbarFragment {
boolean succ = false;
try {
DNSMessage.Builder message = DNSMessage.builder();
message.addQuestion(new Question(domain, type));
message.setId((new Random()).nextInt());
message.setRecursionDesired(true);
message.setOpcode(DNSMessage.OPCODE.QUERY);
message.setResponseCode(DNSMessage.RESPONSE_CODE.NO_ERROR);
message.setQrFlag(false);
DNSMessage.Builder message = DNSMessage.builder()
.addQuestion(new Question(domain, type))
.setId((new Random()).nextInt())
.setRecursionDesired(true)
.setOpcode(DNSMessage.OPCODE.QUERY)
.setResponseCode(DNSMessage.RESPONSE_CODE.NO_ERROR)
.setQrFlag(false);
long startTime = System.currentTimeMillis();
DNSMessage response = dnsQuery.query(message.build(), InetAddress.getByName(server.getAddress()), server.getPort());

View File

@ -216,12 +216,12 @@ public class UdpProvider extends Provider {
* @param responsePayload The payload of the response
*/
void handleDnsResponse(IpPacket requestPacket, byte[] responsePayload) {
/*try {
try {
DNSMessage message = new DNSMessage(responsePayload);
Logger.info(message.toString());
} catch (IOException e) {
Logger.logException(e);
}*/
}
UdpPacket udpOutPacket = (UdpPacket) requestPacket.getPayload();
UdpPacket.Builder payLoadBuilder = new UdpPacket.Builder(udpOutPacket)
.srcPort(udpOutPacket.getHeader().getDstPort())
@ -322,7 +322,7 @@ public class UdpProvider extends Provider {
String response = RuleResolver.resolve(dnsQueryName, dnsMsg.getQuestion().type);
if (response != null && dnsMsg.getQuestion().type == Record.TYPE.A) {
Logger.info("Provider: Resolved " + dnsQueryName + " Local resolver response: " + response);
DNSMessage.Builder builder = dnsMsg.asBuilder();
DNSMessage.Builder builder = dnsMsg.asBuilder().setQrFlag(false);
int[] ip = new int[4];
byte i = 0;
for (String block : response.split("\\.")) {
@ -333,7 +333,7 @@ public class UdpProvider extends Provider {
handleDnsResponse(parsedPacket, builder.build().toArray());
} else if (response != null && dnsMsg.getQuestion().type == Record.TYPE.AAAA) {
Logger.info("Provider: Resolved " + dnsQueryName + " Local resolver response: " + response);
DNSMessage.Builder builder = dnsMsg.asBuilder();
DNSMessage.Builder builder = dnsMsg.asBuilder().setQrFlag(false);
builder.addAnswer(new Record<>(dnsQueryName, Record.TYPE.AAAA, 1, 64,
new AAAA(Inet6Address.getByName(response).getAddress())));
handleDnsResponse(parsedPacket, builder.build().toArray());