use of org.minidns.dnsmessage.Question in project minidns by MiniDNS.
the class DnssecResolverApi method resolveDnssecReliable.
/**
* Resolve the given name and type which is expected to yield DNSSEC authenticated results.
*
* @param name the DNS name to resolve.
* @param type the class of the RR type to resolve.
* @param <D> the RR type to resolve.
* @return the resolver result.
* @throws IOException in case an exception happens while resolving.
* @see #resolveDnssecReliable(Question)
*/
public <D extends Data> ResolverResult<D> resolveDnssecReliable(DNSName name, Class<D> type) throws IOException {
TYPE t = TYPE.getType(type);
Question q = new Question(name, t);
return resolveDnssecReliable(q);
}
use of org.minidns.dnsmessage.Question in project Smack by igniterealtime.
the class DoX method main.
public static void main(String[] args) throws XMPPException, SmackException, IOException, InterruptedException {
SmackConfiguration.DEBUG = true;
XMPPTCPConnection connection = new XMPPTCPConnection(args[0], args[1]);
connection.setReplyTimeout(60000);
connection.connect().login();
DnsOverXmppManager dox = DnsOverXmppManager.getInstanceFor(connection);
Jid target = JidCreate.from("dns@moparisthebest.com/listener");
Question question = new Question("geekplace.eu", Record.TYPE.A);
DnsMessage response = dox.query(target, question);
// CHECKSTYLE:OFF
System.out.println(response);
// CHECKSTYLE:ON
connection.disconnect();
}
use of org.minidns.dnsmessage.Question in project minidns by MiniDNS.
the class DNSMessageTest method testMessageSelfComplexReconstruction.
@Test
public void testMessageSelfComplexReconstruction() throws Exception {
DNSMessage.Builder dmb = DNSMessage.builder();
dmb.addQuestion(new Question("www.example.com", TYPE.NS));
dmb.addAnswer(record("www.example.com", ns("ns.example.com")));
dmb.addAdditionalResourceRecord(record("ns.example.com", a("127.0.0.1")));
dmb.addNameserverRecords(record("ns.example.com", aaaa("2001::1")));
dmb.setOpcode(DNSMessage.OPCODE.QUERY);
dmb.setResponseCode(DNSMessage.RESPONSE_CODE.NO_ERROR);
dmb.setRecursionAvailable(false);
dmb.setAuthoritativeAnswer(true);
dmb.setAuthenticData(true);
dmb.setQrFlag(false);
dmb.setId(43);
DNSMessage message = new DNSMessage(dmb.build().toArray());
assertEquals(1, message.questions.size());
assertEquals(1, message.answerSection.size());
assertEquals(1, message.additionalSection.size());
assertEquals(1, message.authoritySection.size());
assertFalse(message.recursionAvailable);
assertTrue(message.authenticData);
assertFalse(message.checkingDisabled);
assertFalse(message.qr);
assertTrue(message.authoritativeAnswer);
assertEquals(43, message.id);
assertEquals(DNSMessage.OPCODE.QUERY, message.opcode);
assertEquals(DNSMessage.RESPONSE_CODE.NO_ERROR, message.responseCode);
assertCsEquals("www.example.com", message.questions.get(0).name);
assertEquals(TYPE.NS, message.questions.get(0).type);
assertCsEquals("www.example.com", message.answerSection.get(0).name);
assertEquals(TYPE.NS, message.answerSection.get(0).type);
assertCsEquals("ns.example.com.", message.answerSection.get(0).payloadData.toString());
assertCsEquals("ns.example.com", message.additionalSection.get(0).name);
assertEquals(TYPE.A, message.additionalSection.get(0).type);
assertCsEquals("127.0.0.1", message.additionalSection.get(0).payloadData.toString());
assertCsEquals("ns.example.com", message.authoritySection.get(0).name);
assertEquals(TYPE.AAAA, message.authoritySection.get(0).type);
assertCsEquals("2001:0:0:0:0:0:0:1", message.authoritySection.get(0).payloadData.toString());
}
use of org.minidns.dnsmessage.Question in project minidns by MiniDNS.
the class DNSMessageTest method testMessageSelfQuestionReconstruction.
@Test
public void testMessageSelfQuestionReconstruction() throws Exception {
DNSMessage.Builder dmb = DNSMessage.builder();
dmb.setQuestion(new Question("www.example.com", TYPE.A));
dmb.setRecursionDesired(true);
dmb.setId(42);
dmb.setQrFlag(true);
DNSMessage message = new DNSMessage(dmb.build().toArray());
assertEquals(1, message.questions.size());
assertEquals(0, message.answerSection.size());
assertEquals(0, message.additionalSection.size());
assertEquals(0, message.authoritySection.size());
assertTrue(message.recursionDesired);
assertTrue(message.qr);
assertEquals(42, message.id);
assertCsEquals("www.example.com", message.questions.get(0).name);
assertEquals(TYPE.A, message.questions.get(0).type);
}
use of org.minidns.dnsmessage.Question in project minidns by MiniDNS.
the class NSIDTest method testNsidLRoot.
@IntegrationTest
public static NSID testNsidLRoot() {
DNSClient client = new DNSClient(null) {
@Override
protected Builder newQuestion(Builder message) {
message.getEdnsBuilder().addEdnsOption(NSID.REQUEST);
return super.newQuestion(message);
}
};
DNSMessage response = null;
Question q = new Question("de", TYPE.NS);
for (InetAddress lRoot : IterativeDNSClient.getRootServer('l')) {
try {
response = client.query(q, lRoot);
} catch (IOException e) {
continue;
}
break;
}
NSID nsid = response.getEdns().getEdnsOption(OptionCode.NSID);
assertNotNull(nsid);
return nsid;
}
Aggregations