本文整理汇总了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 )));
}
}