类org.xbill.DNS.SRVRecord源码实例Demo

下面列出了怎么用org.xbill.DNS.SRVRecord的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: dns-java   文件: XBillDnsSrvResolver.java
private static List<LookupResult> toLookupResults(Record[] queryResult) {
  ImmutableList.Builder<LookupResult> builder = ImmutableList.builder();

  if (queryResult != null) {
    for (Record record: queryResult) {
      if (record instanceof SRVRecord) {
        SRVRecord srvRecord = (SRVRecord) record;
        builder.add(LookupResult.create(srvRecord.getTarget().toString(),
                                        srvRecord.getPort(),
                                        srvRecord.getPriority(),
                                        srvRecord.getWeight(),
                                        srvRecord.getTTL()));
      }
    }
  }

  return builder.build();
}
 
源代码2 项目: dns-java   文件: XBillDnsSrvResolverTest.java
private Message messageWithNodes(String query, String[] names) throws TextParseException {
  Name queryName = Name.fromString(query);
  Record question = Record.newRecord(queryName, Type.SRV, DClass.IN);
  Message queryMessage = Message.newQuery(question);
  Message result = new Message();
  result.setHeader(queryMessage.getHeader());
  result.addRecord(question, Section.QUESTION);

  for (String name1 : names) {
    result.addRecord(
        new SRVRecord(queryName, DClass.IN, 1, 1, 1, 8080, Name.fromString(name1)),
        Section.ANSWER);
  }

  return result;
}
 
源代码3 项目: cloudbreak   文件: DNSServiceAddressResolver.java
private String dnsSrvLookup(String query) throws ServiceAddressResolvingException {
    String result;
    try {
        Record[] records = new Lookup(query, Type.SRV).run();
        if (records != null && records.length > 0) {
            SRVRecord srv = (SRVRecord) records[0];
            result = srv.getTarget().toString().replaceFirst("\\.$", "") + ':' + srv.getPort();
        } else {
            throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved");
        }
    } catch (TextParseException e) {
        throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved", e);
    }
    return result;
}
 
源代码4 项目: cloudbreak   文件: DNSServiceAddressResolver.java
private String dnsSrvLookup(String query) throws ServiceAddressResolvingException {
    String result;
    try {
        Record[] records = new Lookup(query, Type.SRV).run();
        if (records != null && records.length > 0) {
            SRVRecord srv = (SRVRecord) records[0];
            result = srv.getTarget().toString().replaceFirst("\\.$", "") + ':' + srv.getPort();
        } else {
            throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved");
        }
    } catch (TextParseException e) {
        throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved", e);
    }
    return result;
}
 
源代码5 项目: cloudbreak   文件: DNSServiceAddressResolver.java
private String dnsSrvLookup(String query) throws ServiceAddressResolvingException {
    String result;
    try {
        Record[] records = new Lookup(query, Type.SRV).run();
        if (records != null && records.length > 0) {
            SRVRecord srv = (SRVRecord) records[0];
            result = srv.getTarget().toString().replaceFirst("\\.$", "") + ':' + srv.getPort();
        } else {
            throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved");
        }
    } catch (TextParseException e) {
        throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved", e);
    }
    return result;
}
 
源代码6 项目: cloudbreak   文件: DNSServiceAddressResolver.java
private String dnsSrvLookup(String query) {
    String result;
    try {
        Record[] records = new Lookup(query, Type.SRV).run();
        if (records != null && records.length > 0) {
            SRVRecord srv = (SRVRecord) records[0];
            result = srv.getTarget().toString().replaceFirst("\\.$", "") + ':' + srv.getPort();
        } else {
            throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved");
        }
    } catch (TextParseException e) {
        throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved", e);
    }
    return result;
}
 
源代码7 项目: cloudbreak   文件: DNSServiceAddressResolver.java
private String dnsSrvLookup(String query) throws ServiceAddressResolvingException {
    String result;
    try {
        Record[] records = new Lookup(query, Type.SRV).run();
        if (records != null && records.length > 0) {
            SRVRecord srv = (SRVRecord) records[0];
            result = srv.getTarget().toString().replaceFirst("\\.$", "") + ':' + srv.getPort();
        } else {
            throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved");
        }
    } catch (TextParseException e) {
        throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved", e);
    }
    return result;
}
 
源代码8 项目: cloudbreak   文件: DNSServiceAddressResolver.java
private String dnsSrvLookup(String query) throws ServiceAddressResolvingException {
    String result;
    try {
        Record[] records = new Lookup(query, Type.SRV).run();
        if (records != null && records.length > 0) {
            SRVRecord srv = (SRVRecord) records[0];
            result = srv.getTarget().toString().replaceFirst("\\.$", "") + ':' + srv.getPort();
        } else {
            throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved");
        }
    } catch (TextParseException e) {
        throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved", e);
    }
    return result;
}
 
源代码9 项目: MyVirtualDirectory   文件: ConnectionWrapper.java
private LDAPConnection createConnection() throws LDAPException {
	LDAPConnection ldapcon = null;
	switch (interceptor.type) {
		case LDAPS :
					if (this.interceptor.getSocketFactory() == null) {
						
						ldapcon = new LDAPConnection(new LDAPJSSESecureSocketFactory());
					} else {
						
						ldapcon = new LDAPConnection(new LDAPJSSESecureSocketFactory(this.interceptor.getSocketFactory().getSSLSocketFactory()));
					}
			//ldapcon = new LDAPConnection();
					break;
					
		case LDAP : ldapcon = new LDAPConnection();
		            break;
		case DSMLV2 : DsmlConnection con = new DsmlConnection();
					  con.setUseSoap(interceptor.isSoap);
					  ldapcon = con;
					  break;
		case SPML : SPMLConnection spml = new SPMLConnection(interceptor.spmlImpl);
					ldapcon = spml;
					break;
		
	}
	
	this.lastAccessed = System.currentTimeMillis();
	
	if (ldapcon == null) {
		return null;
	} else {
		String host = this.interceptor.host;

		if (this.interceptor.useSrvDNS) {
			Record[] records;
			try {
				records = new Lookup(host, Type.SRV).run();
			} catch (TextParseException e) {
				throw new LDAPException(LDAPException.resultCodeToString(LDAPException.OPERATIONS_ERROR),LDAPException.OPERATIONS_ERROR,"Could not lookup srv",e);
			}
			if (records == null) {
				throw new LDAPException("No SRV records",LDAPException.OPERATIONS_ERROR,"");
			}
			SRVRecord srv = (SRVRecord) records[0];
			host = srv.getTarget().toString();
		}

		ldapcon.connect(host,this.interceptor.port);
		return ldapcon;
	}
}