Package org.xbill.DNS

Examples of org.xbill.DNS.Lookup


                Integer dnsClass = null;
                if (dclass != null) {
                    dnsClass = DClass.value(String.valueOf(dclass));
                }

                Lookup lookup = (dnsClass == null)
                    ? (dnsType == null ? new Lookup(dnsName) : new Lookup(dnsName, dnsType))
                        : new Lookup(dnsName, dnsType, dnsClass);

                lookup.run();
                if (lookup.getAnswers() != null) {
                    exchange.getIn().setBody(lookup.getAnswers());
                } else {
                    throw new CamelException(lookup.getErrorString());
                }
            }
        };
    }
View Full Code Here


   * @return an {@link InetSocketAddress}, or <code>null</code> if no SRV record was found.
   * @throws TextParseException if the hostname is malformed.
   */
  public static InetSocketAddress resolve(String hostname) throws TextParseException {
    String query = "_minecraft._tcp." + hostname.trim();
    Record[] records = new Lookup(query, Type.SRV).run();

    if ((records != null) && (records.length > 0)) {
      SRVRecord srv = (SRVRecord)records[0];

      if (records.length > 1) {
View Full Code Here

                Integer dnsClass = null;
                if (dclass != null) {
                    dnsClass = DClass.value(String.valueOf(dclass));
                }

                Lookup lookup;
                if (dnsType != null && dnsClass != null) {
                    lookup = new Lookup(dnsName, dnsType, dnsClass);
                } else {
                    if (dnsType != null) {
                        lookup = new Lookup(dnsName, dnsType);
                    } else {
                        lookup = new Lookup(dnsName);
                    }
                }

                lookup.run();
                if (lookup.getAnswers() != null) {
                    exchange.getIn().setBody(lookup.getAnswers());
                } else {
                    exchange.getIn().setBody(lookup.getErrorString());
                }
            }
        };
    }
View Full Code Here

        }
        try {

            log.debug("Start "+recordTypeDescription+"-Record lookup for : " + request.getHostname());

            Lookup query = new Lookup(request.getHostname(), dnsJavaType);
            query.setResolver(resolver);

            Record[] rr = query.run();
            int queryResult = query.getResult();
           

            if (queryResult == Lookup.TRY_AGAIN) {
                throw new TimeoutException(query.getErrorString());
            }
           
            List<String> records = convertRecordsToList(rr);
           
            log.debug("Found " + (rr != null ? rr.length : 0) + " "+recordTypeDescription+"-Records");
View Full Code Here

        // THIS WRITE a fully qualified MACHINE-NAME.MACHINE-DOMAIN
        System.out.println(InetAddress.getLocalHost().getCanonicalHostName());
        // THIS WRITE localhost
        System.out.println(InetAddress.getAllByName(null)[0]
                .getCanonicalHostName());
        Record[] record = new Lookup(Name.root, Type.ANY).run();
        if (record !=null) System.out.println(record[0]);
    }
View Full Code Here

     */
    private InetAddress[] requestLookup(String host) throws UnknownHostException {
        InetAddress[] addresses = null;
        if (isCustomResolver() && ((ExtendedResolver) resolver).getResolvers().length > 1) {
            try {
                Lookup lookup = new Lookup(host, Type.A);
                lookup.setCache(lookupCache);
                lookup.setResolver(resolver);
                Record[] records = lookup.run();
                if (records.length == 0) {
                    throw new UnknownHostException("Failed to resolve host name: " + host);
                }
                addresses = new InetAddress[records.length];
                for (int i = 0; i < records.length; i++) {
View Full Code Here

        // Try to get the records for this host (assume domain name)
        // TODO: Bug #935119 concerns potential hang here
        String lookupName = dnsName.endsWith(".") ? dnsName : dnsName + ".";
        try {
            rrecordSet = (new Lookup(lookupName, TypeType, ClassType)).run();
        } catch (TextParseException e) {
            rrecordSet = null;
        }
        curi.setContentType("text/dns");
        if (rrecordSet != null) {
View Full Code Here

      }
    } catch (UnknownHostException e) {
      throw new LookupException("Error creating DNS Resolver", e);
    }

    Lookup lookup;
    try {
      lookup = new Lookup(applicationFqdn, Type.SRV);
    } catch (TextParseException e) {
      throw new LookupException("Error parsing DNS response", e);
    }
    lookup.setResolver(resolver);
    org.xbill.DNS.Record[] records = lookup.run();

    if (records != null) {
      List<Record> servers = new ArrayList<Record>();
      for (org.xbill.DNS.Record r : records) {
        if (r.getType() == Type.SRV) {
View Full Code Here

      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();

      if (records != null) {
        for (org.xbill.DNS.Record record : records) {
          if (record.getType() == Type.CNAME) {
            return ((CNAMERecord) record).getTarget().toString();
View Full Code Here

     */
    protected Record[] lookup(String namestr, int type, String typeDesc) throws TemporaryResolutionException {
        // Name name = null;
        try {
            // name = Name.fromString(namestr, Name.root);
            Lookup l = new Lookup(namestr, type);

            l.setCache(cache);
            l.setResolver(resolver);
            l.setCredibility(dnsCredibility);
            l.setSearchPath(searchPaths);
            Record[] r = l.run();

            try {
                if (l.getResult() == Lookup.TRY_AGAIN) {
                    throw new TemporaryResolutionException("DNSService is temporary not reachable");
                } else {
                    return r;
                }
            } catch (IllegalStateException ise) {
View Full Code Here

TOP

Related Classes of org.xbill.DNS.Lookup

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.