當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。