本文整理匯總了Java中org.xbill.DNS.Type.AAAA屬性的典型用法代碼示例。如果您正苦於以下問題:Java Type.AAAA屬性的具體用法?Java Type.AAAA怎麽用?Java Type.AAAA使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.xbill.DNS.Type
的用法示例。
在下文中一共展示了Type.AAAA屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: resolve
public static String resolve(String host, int addrType) {
try {
Lookup lookup = new Lookup(host, addrType);
SimpleResolver resolver = new SimpleResolver("114.114.114.114");
resolver.setTimeout(5);
lookup.setResolver(resolver);
Record[] result = lookup.run();
if (result == null) return null;
List<Record> records = java.util.Arrays.asList(result);
java.util.Collections.shuffle(records);
for (Record record : records) {
if (addrType == Type.A) {
return ((ARecord) record).getAddress().getHostAddress();
} else if (addrType == Type.AAAA) {
return ((AAAARecord) record).getAddress().getHostAddress();
}
}
} catch (Exception ex) {
return null;
}
return null;
}
示例2: testDnsJavaWithDnsServer
@Test
public void testDnsJavaWithDnsServer() throws TextParseException, UnknownHostException {
final Lookup l = new Lookup("example.com", Type.AAAA);
final SimpleResolver resolver = new SimpleResolver("::1");
resolver.setPort(9153);
l.setResolver(resolver);
l.run();
System.out.println("result: " + l.getResult());
final Record[] answers = l.getAnswers();
assertEquals(answers.length, 1);
final Record record = answers[0];
System.err.println(record.getTTL());
if(l.getResult() == Lookup.SUCCESSFUL) {
System.out.println(l.getAnswers()[0].rdataToString());
}
assertTrue(l.getResult() == Lookup.SUCCESSFUL);
}
示例3: findAddresses
private String[] findAddresses(Name target, Record[] records) {
ArrayList<String> addresses = new ArrayList<String>();
for (Record record : records) {
if (target == null || target.equals(record.getName())) {
int recordType = record.getType();
if (Type.A == recordType)
addresses.add(((ARecord)record).getAddress().getHostAddress());
else if (Type.AAAA == recordType)
addresses.add(((AAAARecord)record).getAddress().getHostAddress());
}
}
if (addresses.size() == 0)
return null;
return addresses.toArray(new String[addresses.size()]);
}
示例4: testNoAnswer
@Test
@JUnitDNSServer(port=9153, zones={})
public void testNoAnswer() throws Exception {
final Lookup l = new Lookup("example.com", Type.AAAA);
final SimpleResolver resolver = new SimpleResolver("::1");
resolver.setPort(9153);
l.setResolver(resolver);
l.run();
System.out.println("result: " + l.getResult());
final Record[] answers = l.getAnswers();
assertNotNull(answers);
assertEquals(answers.length, 1);
final Record record = answers[0];
System.err.println(record.getTTL());
if(l.getResult() == Lookup.SUCCESSFUL) {
System.out.println(l.getAnswers()[0].rdataToString());
}
assertTrue(l.getResult() == Lookup.SUCCESSFUL);
}
示例5: testNoAnswer
@Test
@JUnitDNSServer(port=9153, zones={})
public void testNoAnswer() throws Exception {
final Lookup l = new Lookup("example.com", Type.AAAA);
final SimpleResolver resolver = new SimpleResolver("::1");
resolver.setPort(9153);
l.setResolver(resolver);
l.run();
System.out.println("result: " + l.getResult());
final Record[] answers = l.getAnswers();
assertEquals(answers.length, 1);
final Record record = answers[0];
System.err.println(record.getTTL());
if(l.getResult() == Lookup.SUCCESSFUL) {
System.out.println(l.getAnswers()[0].rdataToString());
}
assertTrue(l.getResult() == Lookup.SUCCESSFUL);
}
示例6: testDnsJavaQuadARecord
@Test
public void testDnsJavaQuadARecord() throws IOException {
final Lookup l = new Lookup("ipv6.example.com", Type.AAAA);
final SimpleResolver resolver = new SimpleResolver("::1");
resolver.setPort(9153);
l.setResolver(resolver);
l.run();
System.out.println("result: " + l.getResult());
if(l.getResult() == Lookup.SUCCESSFUL) {
System.out.println(l.getAnswers()[0].rdataToString());
}
assertTrue(l.getResult() == Lookup.SUCCESSFUL);
}
示例7: getIPV6ByName
public Inet6Address
getIPV6ByName(
String query )
throws UnknownHostException
{
try{
Lookup a6_l = new Lookup( query, Type.AAAA );
setCache( null, a6_l );
a6_l.run();
Record[] a6_results = a6_l.getAnswers();
if ( a6_results != null ){
for ( Record r: a6_results ){
AAAARecord a6_record = (AAAARecord)r;
return((Inet6Address)a6_record.getAddress());
}
}
throw( new UnknownHostException( query ));
}catch( Exception e ){
throw( new UnknownHostException( query + ": " + Debug.getNestedExceptionMessage( e )));
}
}