Package org.xbill.DNS

Examples of org.xbill.DNS.Record


  m_rs.addRR(m_a1);
  assertEquals(m_a1.getTTL(), m_rs.getTTL());

  Iterator itr = m_rs.rrs();
  while( itr.hasNext() ){
      Record r = (Record)itr.next();
      assertEquals( m_a1.getTTL(), r.getTTL());
  }
    }
View Full Code Here


      Resolver resolver = new ExtendedResolver();
      resolver.setTimeout(timeoutInSeconds);
      resolver.setTCP(true);

      Name name = ReverseMap.fromAddress(hostIp);
      Record record = Record.newRecord(name, Type.PTR, DClass.IN);
      Message response = resolver.send(newQuery(record));

      Record[] answers = response.getSectionArray(Section.ANSWER);
      if (answers.length == 0) {
        return fallback(hostIp);
View Full Code Here

        resolver.setTimeout(timeoutValue);

        // create appropriate data structures ...

        Name name = ReverseMap.fromAddress(address);
        Record rec = Record.newRecord(name, Type.PTR, DClass.IN);
        Message query = Message.newQuery(rec);

        // send it off ...
        try {
          response = resolver.send(query);
        } catch (Exception e) {
          LOG.error("Reverse DNS Resolution for:" + address
              + " threw IOException:" + StringUtils.stringifyException(e));
          resolverException = e;
        }

        if (response != null && response.getRcode() == Rcode.NOERROR) {

          // get answer
          Record records[] = response.getSectionArray(Section.ANSWER);

          if (records != null) {

            // walk records ...
            for (Record record : records) {
View Full Code Here

          // set the timeout ...
          resolver.setTimeout(timeoutValue);

          // create appropriate data structures ...
          Name name = Name.fromString(hostName, Name.root);
          Record rec = Record.newRecord(name, Type.A, DClass.IN);
          Message query = Message.newQuery(rec);

          // send it off ...
          try {
            response = resolver.send(query);
          } catch (IOException e) {
            if (_logger != null)
              _logger.logDNSException(hostName, StringUtils
                  .stringifyException(e));

            resolverException = e;
            if (retryCount++ != MAX_DNS_RETRIES) {
              LOG.info("Waiting to Retry Failed DNS Query for:" + hostName);
              try {
                Thread.sleep(200);
              } catch (InterruptedException e1) {
              }
              LOG.info("Retrying Failed DNS Query for:" + hostName);
              retry = true;
            }
          }

          if (response != null && response.getRcode() == Rcode.NOERROR) {

            // get answer
            Record records[] = response.getSectionArray(Section.ANSWER);

            if (records != null) {

              // walk records ...
              for (Record record : records) {
View Full Code Here

        if (this.query.getMessage().getHeader().getOpcode() != Opcode.QUERY) {
            this.refuse();
            return;
        }

        Record question = this.query.getMessage().getQuestion();
        Backend backend = this.backends.lookup(question.getType());

        if (backend == null) {
            this.refuse();
            return;
        }

        this.ident = backend.makeKey(question);

        logger.debug("Checking cache [key={}]", this.ident);

        // check cache
        Element lmnt = this.cache.get(this.getIdent());
        if(lmnt != null) {
            if(lmnt.getObjectValue() == DontExist) {
                this.timeout();
            } else {
                Record record = (Record) lmnt.getObjectValue();
                this.answer(record, true);
            }
            return;
        }
View Full Code Here

    }

    @Override
    public void replyArrived(Ehcache cache, Element lmnt) throws CacheException {
        logger.debug("Cache update received [lmnt={}]", lmnt);
        Record record = (Record) lmnt.getObjectValue();
        FuturePackage pack;
        if(record == Unknown) {
            pack = this.futures.remove(lmnt.getObjectKey());
            pack.task.timeout();
            return;
        }

        Backend backend = this.repo.lookup(record.getType());
        String key = backend.makeKey(record);
        pack = this.futures.remove(key);

        if (pack == null) {
            logger.info("Unsolicited cache insert [key={}, record={}]", key, record);
View Full Code Here

    public void cacheHit() throws Exception {
        final List<Message> replies = new LinkedList<Message>();
        final Ehcache cache = TestUtils.getEhcache();
        Query query = TestUtils.getQuery(replies);

        Record reply = TestUtils.getReplyRecord();
        Element lmnt = new Element("A:" + reply.getName().toString(), reply);
        cache.put(lmnt);

        ResolveTask task = new ResolveTask(query);
        task.setCache(cache);
        final LinkedList<Record> notified = new LinkedList<Record>();
View Full Code Here

            @Override public void stop() {}
        });

        task.run();

        Record reply = new AAAARecord(new Name("foo.example.com."), DClass.IN,
                1800, InetAddress.getByName("2002:53fe:52a1:7::c9d9"));

        task.answer(reply, false);

        Message result = replies.get(0);
View Full Code Here

        ByteBuffer buf = ByteBuffer.allocate(100);
        channel2.read(buf);

        Message message = new Message(buf.array());
        Record answer = message.getSectionArray(Section.ANSWER)[0];
        String addr = ((ARecord)answer).getAddress().getHostAddress();
        Assert.assertEquals("1.2.3.4", addr);

        Thread.sleep(50); // in case 1 is a bit slow
View Full Code Here

        UDPServer server = new UDPServer(queue);
        server.port = 5354;
        server.setResolveTaskFactory(factory);
        server.start();

        Record rec = Record.newRecord(new Name("foo.example.com."), Type.A, DClass.IN);
        Message query = Message.newQuery(rec);

        byte[] qdata = query.toWire();
        DatagramPacket packet = new DatagramPacket(qdata, qdata.length, InetAddress.getLocalHost(), 5354);
        DatagramSocket socket = new DatagramSocket();
View Full Code Here

TOP

Related Classes of org.xbill.DNS.Record

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.