Package org.xbill.DNS

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


      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

  }
 
  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

        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

    for (int j = 0; j < length; j++) {
      final Record record = queryResult[j];
      if(record instanceof NSRecord) {
        final NSRecord nsRecord = (NSRecord) record;
        final Name target = nsRecord.getTarget();
        result.add(new SRVRecord(name, DClass.IN, nsRecord.getTTL(), 0, 0, SimpleResolver.DEFAULT_PORT, target));
      }
    }
   
    //query for primary ns in SOA record (may overwrite/be equal to one of the ns records)
    query = new Lookup(zone, Type.SOA);
    query.setResolver(resolver);
    queryResult = query.run();
    //TODO file bug upstream that queryResult may never be null
    length = queryResult == null ? 0 : queryResult.length;
    for (int j = 0; j < length; j++) {
      final Record record = queryResult[j];
      if(record instanceof SOARecord) {
        final SOARecord soaRecord = (SOARecord) record;
        result.add(new SRVRecord(name, DClass.IN, soaRecord.getTTL(), 0, 0, SimpleResolver.DEFAULT_PORT, soaRecord.getHost()));
      }
    }
    return result;
  }
View Full Code Here

    return result;
  }

  private int compareSrvRecord(int result, final IServiceInfo serviceInfo,
      final Record record) {
    final SRVRecord srvRec = (SRVRecord) record;
    final String name = srvRec.getName().toString();
    final String string = "_" + DnsSdTestHelper.REG_SCHEME + "._" + DnsSdTestHelper.PROTO;
    if(name.startsWith(string)) {
      final String target = srvRec.getTarget().toString();
      result += serviceInfo.getPriority() == srvRec.getPriority() ? 1 : -1;
      result += serviceInfo.getWeight() == srvRec.getWeight() ? 1 : -1;
      result += DnsSdTestHelper.TTL == srvRec.getTTL() ? 1 : -1;
      result += serviceInfo.getLocation().getHost().equals(target.substring(0, target.length() - 1)) ? 1 : -1;
      result += serviceInfo.getLocation().getPort() == srvRec.getPort() ? 1 : -1;
    }
    return result;
  }
View Full Code Here

    final int priority = serviceInfo.getPriority();
    final int weight = serviceInfo.getWeight();
    final int port = serviceInfo.getLocation().getPort();
    final Name target = Name.fromString(serviceInfo.getLocation().getHost() + "."); //$NON-NLS-1$

    return new SRVRecord(name, DClass.IN, ttl, priority, weight, port, target);
  }
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.