Package org.xbill.DNS

Examples of org.xbill.DNS.SRVRecord


        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()));
                }
               
                // sort by priority
                Collections.sort(addresses, new Comparator<ResolvedAddress>() {
                    public int compare(ResolvedAddress a1, ResolvedAddress a2) {
View Full Code Here


    public SrvComparator() {
    }

    public int compare(Object o1, Object o2) {
        SRVRecord rec1 = (SRVRecord) o1;
        SRVRecord rec2 = (SRVRecord) o2;
        int comparison = comparePriority(rec1, rec2);

        if (comparison != compEQUAL) {
            return comparison;
        }
View Full Code Here

            int[] priorityGroupBoundaries = new int[records.length];
            int lastPrio = -1;
            int prioIndex = 0;

            for (int i = 0; i < records.length; i++) {
                SRVRecord srv = (SRVRecord) records[i];

                if (srv.getPriority() != lastPrio) {
                    lastPrio = srv.getPriority();
                    deltaSum = 0;
                    priorityGroupBoundaries[prioIndex] = i;
                    prioIndex++;
                    numPriorityGroups++;
                }

                deltaSum += srv.getWeight();
                runningSum[i] = deltaSum;

                //
                if (logger.isLoggable(Level.FINE)) {
                    logger.log(Level.FINE,
                        "SRVRecord.toString():" + srv.toString());
                }

                /*
                 * logger.log(Level.FINE, "SRVRecord.toString():" + srv.toString());
                 * //logger.log(Level.FINE, "Host " + srv.getTarget());
View Full Code Here

        int maxValue = runningSum[lastIndex] + 1;
        int testValue = getRandomIndex(maxValue);
        int ignoreIndex = -1;

        for (int i = firstIndex; i < (lastIndex + 1); i++) {
            SRVRecord srv = (SRVRecord) records[i];

            // logger.log(Level.FINE, "SRVRecord.toString():" + srv.toString());
            if (runningSum[i] >= testValue) {
                // this is it
                if (logger.isLoggable(Level.FINE)) {
                    logger.log(Level.FINE, "found srv:" + srv.toString());
                }

                TargetTuple targetTuple =
                        lookupNameFromSRV(srv, theProtocol);
                if(targetTuple != null){
                    return targetTuple;
                }
                else{
                    ignoreIndex = i;
                }
            }
        }
        //Since selective lookup failed, iterate over complete list
        for (int i = firstIndex; i < (lastIndex + 1); i++) {
            if(i == ignoreIndex){
                continue;
            }
            SRVRecord srv = (SRVRecord) records[i];

            TargetTuple targetTuple =
                        lookupNameFromSRV(srv, theProtocol);
            if(targetTuple != null){
                return targetTuple;
View Full Code Here

  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) {
        for (int i = 1; i < records.length; i++) {
          SRVRecord record = (SRVRecord)records[i];
          if (record.getPriority() < srv.getPriority()) {
            srv = record;
          }
        }
      }
View Full Code Here

    else if (rec instanceof NSRecord) {
      NSRecord nsrec = (NSRecord) rec;
      rmap.put("target", nsrec.getTarget().toString());
    }
    else if (rec instanceof SRVRecord) {
      SRVRecord srv = (SRVRecord) rec;
      rmap.put("target", srv.getTarget().toString());
      rmap.put("port", srv.getPort());
      rmap.put("priority", srv.getPriority());
      rmap.put("weight", srv.getWeight());
    }
    else if (rec instanceof SOARecord) {
      SOARecord soa = (SOARecord) rec;
      rmap.put("admin", soa.getAdmin().toString());
      rmap.put("expire", soa.getExpire());
View Full Code Here

  }

  @Override
  protected SRVRecord createRecord(final Name name, final int dclass,
      final long ttl, final ObjectNode recordNode) {
    return new SRVRecord(name, dclass, ttl, getNodeIntegerValue(recordNode,
        "priority"), getNodeIntegerValue(recordNode, "weight"),
        getNodeIntegerValue(recordNode, "port"), getNodeNameValue(
            recordNode, "target"));
  }
View Full Code Here

                            for (String srv : node.getServices()) {
                                try {
                                    String substitutedUrl = getSubstitutedData(fabricService.get().adapt(CuratorFramework.class), srv);
                                    URL serviceUrl = new URL(substitutedUrl);
                                    String groupName = node.getId();
                                    fabricZone.addRecord(new SRVRecord(Name.fromString(groupName, serivceDomain), DClass.IN, minimumTtl, priority++, 0, serviceUrl.getPort(), (Name.fromString(containerId, containerDomain))));
                                } catch (Exception e) {
                                    //ignore service that are not valid URLs.
                                }
                            }
                        }
View Full Code Here

    switch (lookup.getResult()) {
      case Lookup.SUCCESSFUL:
        final ImmutableList.Builder<URI> endpoints = ImmutableList.builder();
        for (Record record : queryResult) {
          if (record instanceof SRVRecord) {
            SRVRecord srv = (SRVRecord) record;
            endpoints.add(http(srv.getTarget().toString(), srv.getPort()));
          }
        }
        return endpoints.build();
      case Lookup.HOST_NOT_FOUND:
        // fallthrough
View Full Code Here

        if( stunRecords == null ) {
          stunAddresses = null ;
        } else {
          stunAddresses = new TransportAddress[stunRecords.length];
          for( int i=0; i<stunRecords.length; ++i ) {
            SRVRecord srv = (SRVRecord) stunRecords[i] ;
            stunAddresses[i] = new TransportAddress(srv.getTarget().toString().replaceFirst("\\.$", ""), srv.getPort(), Transport.UDP);
          }
        }
        if( turnRecords == null ) {
          turnAddresses = null ;
        } else {
          turnAddresses = new TransportAddress[stunRecords.length];
          for( int i=0; i<turnAddresses.length; ++i ) {
            SRVRecord srv = (SRVRecord) turnRecords[i] ;
            turnAddresses[i] = new TransportAddress(srv.getTarget().toString().replaceFirst("\\.$", ""), srv.getPort(), Transport.UDP);
          }
        }
      }

      private Record[] lookupSrv(String query) throws TextParseException {
View Full Code Here

TOP

Related Classes of org.xbill.DNS.SRVRecord

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.