Examples of SRVRecord


Examples of org.xbill.DNS.SRVRecord

  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

Examples of org.xbill.DNS.SRVRecord

    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

Examples of org.xbill.DNS.SRVRecord

  }

  @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

Examples of org.xbill.DNS.SRVRecord

                            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

Examples of org.xbill.DNS.SRVRecord

    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

Examples of org.xbill.DNS.SRVRecord

        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

Examples of org.xbill.DNS.SRVRecord

    /* (non-Javadoc)
     * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
     */
    public int compare(Object arg0, Object arg1) {
      if(arg0 instanceof SRVRecord && arg1 instanceof SRVRecord) {
        SRVRecord srv1 = (SRVRecord) arg0;
        SRVRecord srv2 = (SRVRecord) arg1;
        if(srv1.getPriority() > srv2.getPriority()) {
          return 1;
        } else if (srv1.getPriority() == srv2.getPriority()) {
          if(srv1.getWeight() > srv2.getWeight()) {
            return 1;
          }
          return -1;
        } else {
          return -1;
View Full Code Here

Examples of org.xbill.DNS.SRVRecord

      Record record = queryResult[j];
      if(record instanceof PTRRecord) {
        PTRRecord ptrRecord = (PTRRecord) record;
        result.add(new DnsSdServiceTypeID(getServicesNamespace(), ptrRecord.getTarget()));
      } else if (record instanceof SRVRecord) {
        SRVRecord srvRecord = (SRVRecord) record;
        result.add(new DnsSdServiceTypeID(getServicesNamespace(), srvRecord.getName()));
      }
    }
    return (IServiceTypeID[]) result.toArray(new IServiceTypeID[result.size()]);
  }
View Full Code Here

Examples of org.xbill.DNS.SRVRecord

  }
 
  private List getServiceInfos(Collection srvQueryResult) {
    List infos = new ArrayList();
    for (Iterator iterator = srvQueryResult.iterator(); iterator.hasNext();) {
      SRVRecord srvRecord = (SRVRecord) iterator.next();
      long ttl = srvRecord.getTTL();
      int priority = srvRecord.getPriority();
      int weight = srvRecord.getWeight();
      int port = srvRecord.getPort();
      Name target = srvRecord.getTarget();
      String host = target.toString();
      host = host.substring(0, host.length() - 1);
     
      IServiceTypeID aServiceTypeID = new DnsSdServiceTypeID(getConnectNamespace(), srvRecord.getName());
     
      // query for txt records (attributes)
      Properties props = new Properties();
      Lookup txtQuery = new Lookup(srvRecord.getName(), Type.TXT);
      txtQuery.setResolver(resolver);
      Record[] txtQueryResults = txtQuery.run();
      int length = txtQueryResults == null ? 0 : txtQueryResults.length;
      for (int l = 0; l < length; l++) {
        TXTRecord txtResult = (TXTRecord) txtQueryResults[l];
View Full Code Here

Examples of org.xbill.DNS.SRVRecord

        final Collection dnsServers = getUpdateDomain(zone);
        if(dnsServers.size() == 0) {
          throw new DnsSdDiscoveryException(Messages.DnsSdDiscoveryAdvertiser_No_DynDns_Servers_Found);
        }
        for (final Iterator iterator = dnsServers.iterator(); iterator.hasNext();) {
          final SRVRecord dnsServer = (SRVRecord) iterator.next();
         
          // try to send msg and fail gracefully if more dns servers are available
          final Name target = dnsServer.getTarget();
          final Message response;
          final InetAddress byName;
          try {
            byName = InetAddress.getByName(target.toString());

            ((SimpleResolver) resolver).setAddress(byName);
            ((SimpleResolver) resolver).setPort(dnsServer.getPort());
           
            response = resolver.send(update);
          } catch (UnknownHostException uhe) {
            if(iterator.hasNext()) {
              continue;
View Full Code Here
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.