当前位置: 首页>>代码示例>>Java>>正文


Java Type.AAAA属性代码示例

本文整理汇总了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;
}
 
开发者ID:lparam,项目名称:xTun-android,代码行数:25,代码来源:Utils.java

示例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);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:20,代码来源:DnsMonitorTest.java

示例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()]);
}
 
开发者ID:wnagele,项目名称:dnsjava-recursive-resolver,代码行数:16,代码来源:RecursiveResolver.java

示例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);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:22,代码来源:DnsMonitorTest.java

示例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);
}
 
开发者ID:vishwaabhinav,项目名称:OpenNMS,代码行数:21,代码来源:DnsMonitorTest.java

示例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);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:14,代码来源:DnsMonitorTest.java

示例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 )));
	}		
}
 
开发者ID:vuze,项目名称:vuze-remote-for-android,代码行数:32,代码来源:DNSProvider.java


注:本文中的org.xbill.DNS.Type.AAAA属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。