Package org.xbill.DNS

Examples of org.xbill.DNS.ExtendedResolver$Resolution


            if (resolver == null) {
                final String[] server = new String[] {_dnsserver.toString()};
                try {
                    AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                        public Object run() throws Exception {
                            resolver = new ExtendedResolver(server);
                            Lookup.setDefaultResolver(resolver);
                            return null;
                        }
                    });
                } catch (PrivilegedActionException x) {
View Full Code Here


   *      the resolved DNS name or in some cases the IP address as a string
   */
  @Override
  public String apply(String hostIp) {
    try {
      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) {
        LOG.warn("no answer to DNS resolution attempt for "+hostIp+"; using fallback");
        return fallback(hostIp);
View Full Code Here

   * @param hostIp
   * @return
   * @throws IOException
   */
  public static String resolveAddress(String hostIp) throws IOException {
    Resolver res = new ExtendedResolver();
    res.setTimeout(5); // seconds

    Name name = ReverseMap.fromAddress(hostIp);
    int type = Type.PTR;
    int dclass = DClass.IN;
    Record rec = Record.newRecord(name, type, dclass);
    Message query = Message.newQuery(rec);
    Message response = res.send(query);

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

   * @param hostIp
   * @return The resolved DNS name.
   * @throws IOException
   */
  public static String resolveAddress(String hostIp) throws IOException {
    Resolver res = new ExtendedResolver();
    res.setTimeout(5); // seconds

    Name name = ReverseMap.fromAddress(hostIp);
    int type = Type.PTR;
    int dclass = DClass.IN;
    Record rec = Record.newRecord(name, type, dclass);
    Message query = Message.newQuery(rec);
    Message response = res.send(query);

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

     * @param ip, like "192.168.1.1"
     * @return the complete DNS record for that IP.
     */
    @Converter
    public static Record toRecord(String ip) throws IOException {
        Resolver res = new ExtendedResolver();

        Name name = ReverseMap.fromAddress(ip);
        int type = Type.PTR;
        int dclass = DClass.IN;
        Record rec = Record.newRecord(name, type, dclass);
        Message query = Message.newQuery(rec);
        Message response = res.send(query);

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

   * @param hostIp
   * @return The resolved DNS name.
   * @throws IOException
   */
  public static String resolveAddress(String hostIp) throws IOException {
    Resolver res = new ExtendedResolver();
    res.setTimeout(5); // seconds

    Name name = ReverseMap.fromAddress(hostIp);
    int type = Type.PTR;
    int dclass = DClass.IN;
    Record rec = Record.newRecord(name, type, dclass);
    Message query = Message.newQuery(rec);
    Message response = res.send(query);

    Record[] answers = response.getSectionArray(Section.ANSWER);
    if (answers.length == 0) {
      // Fall back to standard Java: in contrast to dnsjava, this also reads /etc/hosts
      return new InetSocketAddress(hostIp, 0).getAddress().getCanonicalHostName();
View Full Code Here

                logger.info("DNS Server is: " + serversArray[c]);
            }
        }

        try {
            resolver = new ExtendedResolver( serversArray );
        } catch (UnknownHostException uhe) {
            logger.error("DNS service could not be initialized.  The DNS servers specified are not recognized hosts.", uhe);
            throw uhe;
        }
View Full Code Here

                getLogger().info("DNS Server is: " + serversArray[c]);
            }
        }

        try {
            resolver = new ExtendedResolver( serversArray );
            Lookup.setDefaultResolver(resolver);
        } catch (UnknownHostException uhe) {
            getLogger().fatalError("DNS service could not be initialized.  The DNS servers specified are not recognized hosts.", uhe);
            throw uhe;
        }
View Full Code Here

   *      the resolved DNS name or in some cases the IP address as a string
   */
  @Override
  public String apply(String hostIp) {
    try {
      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

                getLogger().info("DNS Server is: " + serversArray[c]);
            }
        }

        try {
            resolver = new ExtendedResolver( serversArray );
            Lookup.setDefaultResolver(resolver);
        } catch (UnknownHostException uhe) {
            getLogger().fatalError("DNS service could not be initialized.  The DNS servers specified are not recognized hosts.", uhe);
            throw uhe;
        }
View Full Code Here

TOP

Related Classes of org.xbill.DNS.ExtendedResolver$Resolution

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.