Local resolver Response flag fix
This commit is contained in:
parent
2522125a55
commit
89b9c0ef95
@ -159,13 +159,13 @@ public class DNSTestFragment extends ToolbarFragment {
|
|||||||
|
|
||||||
boolean succ = false;
|
boolean succ = false;
|
||||||
try {
|
try {
|
||||||
DNSMessage.Builder message = DNSMessage.builder();
|
DNSMessage.Builder message = DNSMessage.builder()
|
||||||
message.addQuestion(new Question(domain, type));
|
.addQuestion(new Question(domain, type))
|
||||||
message.setId((new Random()).nextInt());
|
.setId((new Random()).nextInt())
|
||||||
message.setRecursionDesired(true);
|
.setRecursionDesired(true)
|
||||||
message.setOpcode(DNSMessage.OPCODE.QUERY);
|
.setOpcode(DNSMessage.OPCODE.QUERY)
|
||||||
message.setResponseCode(DNSMessage.RESPONSE_CODE.NO_ERROR);
|
.setResponseCode(DNSMessage.RESPONSE_CODE.NO_ERROR)
|
||||||
message.setQrFlag(false);
|
.setQrFlag(false);
|
||||||
|
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
DNSMessage response = dnsQuery.query(message.build(), InetAddress.getByName(server.getAddress()), server.getPort());
|
DNSMessage response = dnsQuery.query(message.build(), InetAddress.getByName(server.getAddress()), server.getPort());
|
||||||
|
@ -216,12 +216,12 @@ public class UdpProvider extends Provider {
|
|||||||
* @param responsePayload The payload of the response
|
* @param responsePayload The payload of the response
|
||||||
*/
|
*/
|
||||||
void handleDnsResponse(IpPacket requestPacket, byte[] responsePayload) {
|
void handleDnsResponse(IpPacket requestPacket, byte[] responsePayload) {
|
||||||
/*try {
|
try {
|
||||||
DNSMessage message = new DNSMessage(responsePayload);
|
DNSMessage message = new DNSMessage(responsePayload);
|
||||||
Logger.info(message.toString());
|
Logger.info(message.toString());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logger.logException(e);
|
Logger.logException(e);
|
||||||
}*/
|
}
|
||||||
UdpPacket udpOutPacket = (UdpPacket) requestPacket.getPayload();
|
UdpPacket udpOutPacket = (UdpPacket) requestPacket.getPayload();
|
||||||
UdpPacket.Builder payLoadBuilder = new UdpPacket.Builder(udpOutPacket)
|
UdpPacket.Builder payLoadBuilder = new UdpPacket.Builder(udpOutPacket)
|
||||||
.srcPort(udpOutPacket.getHeader().getDstPort())
|
.srcPort(udpOutPacket.getHeader().getDstPort())
|
||||||
@ -322,7 +322,7 @@ public class UdpProvider extends Provider {
|
|||||||
String response = RuleResolver.resolve(dnsQueryName, dnsMsg.getQuestion().type);
|
String response = RuleResolver.resolve(dnsQueryName, dnsMsg.getQuestion().type);
|
||||||
if (response != null && dnsMsg.getQuestion().type == Record.TYPE.A) {
|
if (response != null && dnsMsg.getQuestion().type == Record.TYPE.A) {
|
||||||
Logger.info("Provider: Resolved " + dnsQueryName + " Local resolver response: " + response);
|
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];
|
int[] ip = new int[4];
|
||||||
byte i = 0;
|
byte i = 0;
|
||||||
for (String block : response.split("\\.")) {
|
for (String block : response.split("\\.")) {
|
||||||
@ -333,7 +333,7 @@ public class UdpProvider extends Provider {
|
|||||||
handleDnsResponse(parsedPacket, builder.build().toArray());
|
handleDnsResponse(parsedPacket, builder.build().toArray());
|
||||||
} else if (response != null && dnsMsg.getQuestion().type == Record.TYPE.AAAA) {
|
} else if (response != null && dnsMsg.getQuestion().type == Record.TYPE.AAAA) {
|
||||||
Logger.info("Provider: Resolved " + dnsQueryName + " Local resolver response: " + response);
|
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,
|
builder.addAnswer(new Record<>(dnsQueryName, Record.TYPE.AAAA, 1, 64,
|
||||||
new AAAA(Inet6Address.getByName(response).getAddress())));
|
new AAAA(Inet6Address.getByName(response).getAddress())));
|
||||||
handleDnsResponse(parsedPacket, builder.build().toArray());
|
handleDnsResponse(parsedPacket, builder.build().toArray());
|
||||||
|
Loading…
Reference in New Issue
Block a user