Package org.xbill.DNS

Examples of org.xbill.DNS.SimpleResolver


        }

        try {
            String key = _dnsserver.toString();
            if (!resolvers.containsKey(key)) {
                SimpleResolver simpleResolver = new SimpleResolver(key);
                resolver.addResolver(simpleResolver);
                resolvers.put(key, simpleResolver);
            }
        } catch (UnknownHostException e) {
            throw new NetworkException("Can't add DNS server", e);
View Full Code Here


    }

    public Producer createProducer() throws Exception {
        return new DefaultProducer(this) {
            public void process(Exchange exchange) throws Exception {
                SimpleResolver resolver = new SimpleResolver();
                int type = Type.TXT;
                Name name = Name.fromString(String.valueOf(exchange.getIn().getHeader(DnsConstants.TERM)) + ".wp.dg.cx", Name.root);
                Record rec = Record.newRecord(name, type, DClass.IN);
                Message query = Message.newQuery(rec);
                Message response = resolver.send(query);
                Record[] records = response.getSectionArray(Section.ANSWER);
                if (records.length > 0) {
                    exchange.getOut().setBody(records[0].rdataToString());
                } else {
                    exchange.getOut().setBody(null);
View Full Code Here

        return new DefaultProducer(this) {
            public void process(Exchange exchange) throws Exception {
                String server = exchange.getIn().getHeader(DnsConstants.DNS_SERVER, String.class);
                ObjectHelper.notEmpty(server, "Header " + DnsConstants.DNS_SERVER);

                SimpleResolver resolver = new SimpleResolver(server);
                int type = Type.value(exchange.getIn().getHeader(DnsConstants.DNS_TYPE, String.class));
                if (type == -1) {
                    // default: if unparsable value given, use A.
                    type = Type.A;
                }
                int dclass = DClass.value(exchange.getIn().getHeader(DnsConstants.DNS_CLASS, String.class));
                if (dclass == -1) {
                    // by default, value is IN.
                    dclass = DClass.IN;
                }

                Name name = Name.fromString(exchange.getIn().getHeader(DnsConstants.DNS_NAME, String.class), Name.root);
                Record rec = Record.newRecord(name, type, dclass);
                Message query = Message.newQuery(rec);
                Message response = resolver.send(query);
                exchange.getOut().setBody(response);
            }
        };
    }
View Full Code Here

     * @return a dns resolver pointing to the local fake server
     */
    protected DNSService getDNSServiceFakeServer() {
        Resolver resolver = null;
        try {
            resolver = new SimpleResolver("127.0.0.1");
        } catch (UnknownHostException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        resolver.setPort(FAKE_SERVER_PORT);
View Full Code Here

    getMXRecord(domain);
  }
 
  private static void getMXRecord(String name) throws TextParseException, UnknownHostException {
    Lookup lookup = new Lookup(name, Type.MX);
    Resolver resolver = new SimpleResolver();
//    lookup.setResolver(resolver);
//    lookup.setCache(null);
    for (Record dnsRecord: lookup.run()) {
      MXRecord record = (MXRecord)dnsRecord;
      System.out.println(record.getPriority() + " " + record.rdataToString());
View Full Code Here

  }
 
  private MXLookupResult getMXHostsDirectly(String atHost) throws MXResolverException {

    try {
      Resolver resolver = (this.nameserver==null) ? new SimpleResolver() : new SimpleResolver(this.nameserver);

      // try to lookup the MX records
      Lookup lookup = new Lookup(atHost,Type.MX);
      lookup.setResolver(resolver);
      lookup.run();
View Full Code Here

    }

    public Producer createProducer() throws Exception {
        return new DefaultProducer(this) {
            public void process(Exchange exchange) throws Exception {
                SimpleResolver resolver = new SimpleResolver();
                int type = Type.TXT;
                Name name = Name.fromString(String.valueOf(exchange.getIn().getHeader(DnsConstants.TERM)) + ".wp.dg.cx", Name.root);
                Record rec = Record.newRecord(name, type, DClass.IN);
                Message query = Message.newQuery(rec);
                Message response = resolver.send(query);
                Record[] records = response.getSectionArray(Section.ANSWER);
                if (records.length > 0) {
                    exchange.getIn().setBody(records[0].rdataToString());
                } else {
                    exchange.getIn().setBody(null);
View Full Code Here

        return new DefaultProducer(this) {
            public void process(Exchange exchange) throws Exception {
                String server = exchange.getIn().getHeader(DnsConstants.DNS_SERVER, String.class);
                ObjectHelper.notEmpty(server, "Header " + DnsConstants.DNS_SERVER);

                SimpleResolver resolver = new SimpleResolver(server);
                int type = Type.value(exchange.getIn().getHeader(DnsConstants.DNS_TYPE, String.class));
                if (type == -1) {
                    // default: if unparsable value given, use A.
                    type = Type.A;
                }
                int dclass = DClass.value(exchange.getIn().getHeader(DnsConstants.DNS_CLASS, String.class));
                if (dclass == -1) {
                    // by default, value is IN.
                    dclass = DClass.IN;
                }

                Name name = Name.fromString(exchange.getIn().getHeader(DnsConstants.DNS_NAME, String.class), Name.root);
                Record rec = Record.newRecord(name, type, dclass);
                Message query = Message.newQuery(rec);
                Message response = resolver.send(query);
                exchange.getIn().setBody(response);
            }
        };
    }
View Full Code Here

    public Producer createProducer() throws Exception {
        return new DefaultProducer(this) {
            public void process(Exchange exchange) throws Exception {
                String server = exchange.getIn().getHeader(DnsConstants.DNS_SERVER, String.class);

                SimpleResolver resolver = new SimpleResolver(server);
                int type = Type.value(exchange.getIn().getHeader(DnsConstants.DNS_TYPE, String.class));
                if (type == -1) {
                    // default: if unparsable value given, use A.
                    type = Type.A;
                }
               
                String dclassValue = exchange.getIn().getHeader(DnsConstants.DNS_CLASS, String.class);
                if (dclassValue == null) {
                    dclassValue = "";
                }
               
                int dclass = DClass.value(dclassValue);
                if (dclass == -1) {
                    // by default, value is IN.
                    dclass = DClass.IN;
                }

                Name name = Name.fromString(exchange.getIn().getHeader(DnsConstants.DNS_NAME, String.class), Name.root);
                Record rec = Record.newRecord(name, type, dclass);
                Message query = Message.newQuery(rec);
                Message response = resolver.send(query);
                exchange.getIn().setBody(response);
            }
        };
    }
View Full Code Here

    if (true) {

      try {

        // allocate a simple resolver object ...
        SimpleResolver resolver = new SimpleResolver(_dnsServerAddress);

        // use tcp if requested ...
        if (useTCP)
          resolver.setTCP(true);

        // set the timeout ...
        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;
        }
View Full Code Here

TOP

Related Classes of org.xbill.DNS.SimpleResolver

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.