Package org.xbill.DNS

Examples of org.xbill.DNS.Record


    }

    @Override
    public Record decode(byte[] message, Configuration configuration)
            throws ProtocolCodingException {
        Record rec = null;
        ByteBuffer buf = ByteBuffer.wrap(message);
        byte type = buf.get();
        InetAddress addr;

        try {
View Full Code Here


        if (message.getSrc().equals(this.channel.getAddress())) {
            // Ignore our own messages
            return;
        }

        Record record;
        try {
            record = protocol.decode(message.getBuffer(), this.configuration);
        } catch (Exception e) {
            logger.warn("Failed to decode message", e);
            return;
        }
        if(record == null) {
            logger.debug("Ignoring message [me={}, message={}]", this.channel.getName(), message);
            return;
        }
        logger.debug("Update from authority [me={}, update={}]", this.channel.getName(), record);

        Element lmnt = new Element(this.makeKey(record), record);
        lmnt.setTimeToLive((int) record.getTTL());
        this.cache.put(lmnt);
    }
View Full Code Here

        return this.prefix + ":" + record.getName();
    }

    @Override
    public void notify(Record question) throws BackendCommunicationException, ProtocolCodingException, NoSuchDomainException {
        Record adjusted = this.record.withName(question.getName());
        Element element = new Element(this.makeKey(question), adjusted);
        element.setTimeToLive((int) adjusted.getTTL());
        this.cache.put(element);
    }
View Full Code Here

    }
  }
 
  private Pair<Record, Message> process(DnsRequest req)
  {
    Record requestRecord = null;
    Pair<Record, Message> result = null;
   
    // pick a random nameserver
    int index = random.nextInt(resolvers.length);
    String nameserver = nameservers[index];
View Full Code Here

            if (response.findRRset(name, rrset.getType(), s))
                return;
        if ((flags & FLAG_SIGONLY) == 0) {
            Iterator<Record> it = rrset.rrs();
            while (it.hasNext()) {
                Record r = (Record) it.next();
                if (r.getName().isWild() && !name.isWild())
                    r = r.withName(name);
                response.addRecord(r, section);
            }
        }
        if ((flags & (FLAG_SIGONLY | FLAG_DNSSECOK)) != 0) {
            Iterator it = rrset.sigs();
            while (it.hasNext()) {
                Record r = (Record) it.next();
                if (r.getName().isWild() && !name.isWild())
                    r = r.withName(name);
                response.addRecord(r, section);
            }
        }
    }
View Full Code Here

    }

    private void addAdditional2(Message response, int section, int flags) {
        Record[] records = response.getSectionArray(section);
        for (int i = 0; i < records.length; i++) {
            Record r = records[i];
            Name glueName = r.getAdditionalName();
            if (glueName != null)
                addGlue(response, glueName, flags);
        }
    }
View Full Code Here

        if (header.getRcode() != Rcode.NOERROR)
            return errorMessage(query, Rcode.FORMERR);
        if (header.getOpcode() != Opcode.QUERY)
            return errorMessage(query, Rcode.NOTIMP);

        Record queryRecord = query.getQuestion();

        OPTRecord queryOPT = query.getOPT();
        if (queryOPT != null && queryOPT.getVersion() > 0) {
        }

        if (s != null)
            maxLength = 65535;
        else if (queryOPT != null)
            maxLength = Math.max(queryOPT.getPayloadSize(), 512);
        else
            maxLength = 512;

        if (queryOPT != null && (queryOPT.getFlags() & ExtendedFlags.DO) != 0)
            flags = FLAG_DNSSECOK;

        Message response = new Message(query.getHeader().getID());
        response.getHeader().setFlag(Flags.QR);
        if (query.getHeader().getFlag(Flags.RD))
            response.getHeader().setFlag(Flags.RD);
        response.addRecord(queryRecord, Section.QUESTION);

        Name name = queryRecord.getName();
        int type = queryRecord.getType();
        int dclass = queryRecord.getDClass();
        if (!Type.isRR(type) && type != Type.ANY)
            return errorMessage(query, Rcode.NOTIMP);

        byte rcode = addAnswer(response, name, type, dclass, 0, flags);
       
View Full Code Here

            case DNSRequest.TXT: type = Type.TXT; break;
            default:
                throw new UnsupportedOperationException("Unknown query type: "+request.getRecordType());
        }
       
        Record question = Record.newRecord(name, type, DClass.ANY);
        Message query = Message.newQuery(question);
        query.getHeader().setID(id);
        return query;
    }
View Full Code Here

     * @param hostname domain name to look up
     *
     * @return a list of MX records corresponding to this mail domain
     */
    public List findMXRecordsRaw(String hostname) {
        Record answers[] = lookup(hostname, Type.MX);
        List servers = new ArrayList();
        if (answers == null) {
            return servers;
        }

View Full Code Here

                    new StringBuffer(128)
                            .append("Couldn't resolve MX records for domain ")
                            .append(hostname)
                            .append(".");
                getLogger().info(logBuffer.toString());
                Record cnames[] = lookup(hostname, Type.CNAME);
                Collection cnameMXrecords = null;
                if (cnames!=null && cnames.length > 0) {
                    cnameMXrecords = findMXRecordsRaw(((CNAMERecord) cnames[0]).getTarget().toString());
                } else {
                    logBuffer = new StringBuffer(128)
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.