Package org.xbill.DNS

Examples of org.xbill.DNS.SimpleResolver$Stream


        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

        _cacheMisses++;

        try {

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

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

          // 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));
View Full Code Here

   
    resolvers = new Resolver[nameservers.length];
    for(int i = 0 ; i < resolvers.length; ++i)
    {
      try {
        resolvers[i] = new SimpleResolver(nameservers[i]);
        resolvers[i].setTimeout(timeoutSecs);
      } catch (UnknownHostException e) {
        throw new RuntimeException("Could not initial resolver for host="+nameservers[i]);
      }
    }
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    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

        try {
            clone.resolver = new ExtendedResolver();
            PropertyIterator dnsServIt = dnsServers.iterator();
            while (dnsServIt.hasNext()) {
                String dnsServer = dnsServIt.next().getStringValue();
                ((ExtendedResolver) clone.resolver).addResolver(new SimpleResolver(dnsServer));
            }
            // resolvers will be chosen via round-robin
            ((ExtendedResolver) clone.resolver).setLoadBalance(true);
        } catch (UnknownHostException uhe) {
            log.warn("Failed to create Extended resolver: " + uhe.getMessage());
View Full Code Here

    String applicationFqdn = String.format("_%s._%s.%s",
        applicationId.toLowerCase(), transportProtocol.toLowerCase(),
        authoritativeFqdn);

    SimpleResolver resolver;
    try {
      if (mDNSHostname == null) {
        resolver = new SimpleResolver();
      } else {
        resolver = new SimpleResolver(mDNSHostname);
      }
    } catch (UnknownHostException e) {
      throw new LookupException("Error creating DNS Resolver", e);
    }
View Full Code Here

   * @return      Authoritative FQDN String
   * @throws LookupException
   */
  String resolveAuthoritativeFQDN() throws LookupException {
    try {
      SimpleResolver resolver;
      if (mDNSHostname == null) {
        resolver = new SimpleResolver();
      } else {
        resolver = new SimpleResolver(mDNSHostname);
      }
      Lookup lookup = new Lookup(getRadioDNSFqdn(), Type.CNAME);
      lookup.setResolver(resolver);
      org.xbill.DNS.Record[] records = lookup.run();

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

TOP

Related Classes of org.xbill.DNS.SimpleResolver$Stream

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.