Examples of Lookup


Examples of org.xbill.DNS.Lookup

                            return protocolAddresses;
                        }

                        Lookup.setDefaultResolver(resolver);

                        final Lookup lookup;
                        try {
                            lookup = new Lookup(hostname);
                        } catch (TextParseException e) {
                            throw new UnknownHostException(hostname);
                        }

                        lookup.run();

                        if (lookup.getResult() == Lookup.SUCCESSFUL) {
                            final Record[] records = lookup.getAnswers();
                            final int recordCount = records.length;

                            protocolAddresses = new ProtocolAddress[recordCount];

                            for (int i = 0; i < recordCount; i++) {
                                final Record record = records[i];
                                protocolAddresses[i] = new IPv4Address(record.rdataToString());
                            }
                        } else {
                            throw new UnknownHostException(lookup.getErrorString());
                        }

                        return protocolAddresses;
                    }
                };

Examples of org.xbill.DNS.Lookup

     */
    private MXRecord[] queryMxRecords() throws MxLookupException {
        org.xbill.DNS.Lookup lookup;

        try {
            lookup = new Lookup(domain.smtpText(), org.xbill.DNS.Type.MX);
        } catch (org.xbill.DNS.TextParseException e) {
            throw new MxLookupException(e,
                    EnhancedStatus.BAD_DESTINATION_MAILBOX_ADDRESS_SYNTAX);
        }

Examples of org.xbill.DNS.Lookup

                return null;
            }
        }

        private String queryReason() {
            Lookup lookup;
            try {
                lookup = new Lookup(queryDomain, Type.TXT);
            } catch (TextParseException e) {
                throw new RuntimeException(e);
            }
            Record[] records = lookup.run();
            if (lookup.getResult() != Lookup.SUCCESSFUL
                    && lookup.getResult() != Lookup.TYPE_NOT_FOUND) {
                logger.warn("Error while looking up TXT record for "
                        + "address {} in DNSBL {}: {}", new Object[] { address,
                        domain, lookup.getErrorString() });
            }
            String reason = concatenateTxtRecordValues(records);
            return reason;
        }

Examples of org.xbill.DNS.Lookup

        InetAddress[] addresses = convertAddressRecordsToAddresses(records);
        return addresses;
    }

    private Record[] queryAddressRecords() throws SendException {
        Lookup lookup = new Lookup(name);
        Record[] records = lookup.run();
        switch (lookup.getResult()) {
        case Lookup.SUCCESSFUL:
            return records;
        case Lookup.TYPE_NOT_FOUND:
            throw new SendException("Host " + name + " has no address record ("
                    + lookup.getErrorString() + ")",
                    EnhancedStatus.PERMANENT_UNABLE_TO_ROUTE, remoteMta);
        case Lookup.HOST_NOT_FOUND:
            throw new SendException("Host " + name + " is not found ("
                    + lookup.getErrorString() + ")",
                    EnhancedStatus.PERMANENT_UNABLE_TO_ROUTE, remoteMta);
        case Lookup.TRY_AGAIN:
            throw new SendException(
                    "DNS network failure while looking up address of " + name
                            + ": " + lookup.getErrorString(),
                    EnhancedStatus.TRANSIENT_DIRECTORY_SERVER_FAILURE,
                    remoteMta);
        case Lookup.UNRECOVERABLE:
            throw new SendException(
                    "Unrecoverable DNS error while looking up address of "
                            + name + ": " + lookup.getErrorString(),
                    EnhancedStatus.PERMANENT_UNABLE_TO_ROUTE, remoteMta);
        default:
            throw new SendException(
                    "Unknown DNS status while looking up address of " + name
                            + ": " + lookup.getResult() + ". "
                            + lookup.getErrorString(),
                    EnhancedStatus.PERMANENT_INTERNAL_ERROR, remoteMta);
        }
    }

Examples of org.xbill.DNS.Lookup

  public Collection<URLName> getMXRecordsForHost(String hostName) {

    Vector<URLName> recordsColl = null;
    try {
      boolean foundOriginalMX = true;
      Record[] records = new Lookup(hostName, Type.MX).run();
     
      /*
       * Sometimes we should send an email to a subdomain which does not
       * have own MX record and MX server. At this point we should find an
       * upper level domain and server where we can deliver our email.
       * 
       * Example: subA.subB.domain.name has not own MX record and
       * subB.domain.name is the mail exchange master of the subA domain
       * too.
       */
      if( records == null || records.length == 0 )
      {
        foundOriginalMX = false;
        String upperLevelHostName = hostName;
        while(    records == null &&
              upperLevelHostName.indexOf(".") != upperLevelHostName.lastIndexOf(".") &&
              upperLevelHostName.lastIndexOf(".") != -1
          )
        {
          upperLevelHostName = upperLevelHostName.substring(upperLevelHostName.indexOf(".")+1);
          records = new Lookup(upperLevelHostName, Type.MX).run();
        }
      }

            if( records != null )
            {
              // Sort in MX priority (higher number is lower priority)
                Arrays.sort(records, new Comparator<Record>() {
                    @Override
                    public int compare(Record arg0, Record arg1) {
                        return ((MXRecord)arg0).getPriority()-((MXRecord)arg1).getPriority();
                    }
                });
                // Create records collection
                recordsColl = new Vector<URLName>(records.length);
                for (int i = 0; i < records.length; i++)
        {
          MXRecord mx = (MXRecord) records[i];
          String targetString = mx.getTarget().toString();
          URLName uName = new URLName(
              RemoteDelivery.SMTPScheme +
              targetString.substring(0, targetString.length() - 1)
          );
          recordsColl.add(uName);
        }
            }else
            {
              foundOriginalMX = false;
              recordsColl = new Vector<URLName>();
            }
           
            /*
             * If we found no MX record for the original hostname (the upper
             * level domains does not matter), then we add the original domain
             * name (identified with an A record) to the record collection,
             * because the mail exchange server could be the main server too.
       *
       * We append the A record to the first place of the record
       * collection, because the standard says if no MX record found then
       * we should to try send email to the server identified by the A
       * record.
             */
      if( !foundOriginalMX )
      {
        Record[] recordsTypeA = new Lookup(hostName, Type.A).run();
        if (recordsTypeA != null && recordsTypeA.length > 0)
        {
          recordsColl.add(0, new URLName(RemoteDelivery.SMTPScheme + hostName));
        }
      }

Examples of org.xbill.DNS.Lookup

    }

    public List<ResolvedAddress> resolveXmppServer(String domain) {
        List<ResolvedAddress> addresses = new ArrayList<ResolvedAddress>();
        try {
            Record[] records = new Lookup("_xmpp-server._tcp." + domain, Type.SRV).run();
            if(records != null) {
                for (int i = 0; i < records.length; i++) {
                    SRVRecord srv = (SRVRecord) records[i];
                    addresses.add(new ResolvedAddress(srv.getTarget(), srv.getPort(), srv.getPriority()));
                }

Examples of org.xbill.DNS.Lookup

                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.getOut().setBody(lookup.getAnswers());
                } else {
                    exchange.getOut().setBody(lookup.getErrorString());
                }
            }
        };
    }

Examples of org.xbill.DNS.Lookup

  public static void main(String[] args) throws Exception {
    int type = Type.A;
    String domainName = "www.twitter.com";
    for (int i = 0; i < 1; i++) {
      Thread.sleep(200);
      Lookup l = new Lookup(domainName, type);
      l.run();
      recordAnswer(domainName, l);
    }
  }

Examples of org.xbill.DNS.Lookup

        // domain need to be fully qualified with new dnsjava version
        if (domainNameToLookup.charAt(domainNameToLookup.length() - 1) != '.') {
            domainNameToLookup += ".";
        }

        Lookup lkup = null;

        try {
            lkup = new Lookup(domainNameToLookup, type);
        } catch (TextParseException e) {
            // we wants only one "checked" exception, lets wrap into a
            // DnsLookupFailedException
            throw new DnsLookupFailedException("Failed to lookup domain:" +
                domainNameToLookup + " error:" + e.getMessage());
        }

        Record[] records = lkup.run();
        int res = lkup.getResult();

        if (res == Lookup.TRY_AGAIN) {
            throw new DnsServerUnavailableException(lkup.getErrorString());
        } else if (lkup.getResult() != Lookup.SUCCESSFUL) {
            throw new DnsLookupFailedException("no such domain:" +
                domainNameToLookup + " error:" + lkup.getErrorString());
        }

        return records;
    }

Examples of org.xtreemfs.babudb.pbrpc.GlobalTypes.Lookup

     *          processRequest(org.xtreemfs.babudb.replication.transmission.dispatcher.Request)
     */
    @Override
    public void processRequest(final Request rq) {
       
        Lookup req = (Lookup) rq.getRequestMessage();
        byte[] key = rq.getData().array();
       
        Logging.logMessage(Logging.LEVEL_DEBUG, this, "LookupOperation:" +
                "db %s, index %d, key %s.", req.getDatabaseName(), req.getIndexId(),
                new String(key));
       
        try {
            dbs.getDatabase(req.getDatabaseName()).lookup(req.getIndexId(), key,
                    null).registerListener(new DatabaseRequestListener<byte[]>() {
               
                @Override
                public void finished(byte[] result, Object context) {
                    rq.sendSuccess(ErrorCodeResponse.getDefaultInstance(), (result == null) ?
TOP
Copyright © 2018 www.massapi.com. 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.