Search in sources :

Example 11 with Question

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);
}
Also used : Question(org.minidns.dnsmessage.Question) TYPE(org.minidns.record.Record.TYPE)

Example 12 with Question

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();
}
Also used : DnsOverXmppManager(org.jivesoftware.smackx.dox.DnsOverXmppManager) XMPPTCPConnection(org.jivesoftware.smack.tcp.XMPPTCPConnection) Jid(org.jxmpp.jid.Jid) Question(org.minidns.dnsmessage.Question) DnsMessage(org.minidns.dnsmessage.DnsMessage)

Example 13 with Question

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());
}
Also used : Question(org.minidns.dnsmessage.Question) DNSMessage(org.minidns.dnsmessage.DNSMessage) Test(org.junit.Test)

Example 14 with Question

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);
}
Also used : Question(org.minidns.dnsmessage.Question) DNSMessage(org.minidns.dnsmessage.DNSMessage) Test(org.junit.Test)

Example 15 with Question

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;
}
Also used : IterativeDNSClient(org.minidns.iterative.IterativeDNSClient) DNSClient(org.minidns.DNSClient) NSID(org.minidns.edns.NSID) Builder(org.minidns.dnsmessage.DNSMessage.Builder) Question(org.minidns.dnsmessage.Question) IOException(java.io.IOException) InetAddress(java.net.InetAddress) DNSMessage(org.minidns.dnsmessage.DNSMessage)

Aggregations

Question (org.minidns.dnsmessage.Question)25 DNSMessage (org.minidns.dnsmessage.DNSMessage)15 Test (org.junit.Test)6 IOException (java.io.IOException)4 InetAddress (java.net.InetAddress)4 DNSName (org.minidns.dnsname.DNSName)3 Data (org.minidns.record.Data)3 Record (org.minidns.record.Record)3 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 Level (java.util.logging.Level)2 DnsMessage (org.minidns.dnsmessage.DnsMessage)2 TYPE (org.minidns.record.Record.TYPE)2 XMPPTCPConnection (org.jivesoftware.smack.tcp.XMPPTCPConnection)1 DnsOverXmppManager (org.jivesoftware.smackx.dox.DnsOverXmppManager)1 Test (org.junit.jupiter.api.Test)1 Jid (org.jxmpp.jid.Jid)1 DNSClient (org.minidns.DNSClient)1 DnsClient (org.minidns.DnsClient)1 Builder (org.minidns.dnsmessage.DNSMessage.Builder)1