當前位置: 首頁>>代碼示例>>Java>>正文


Java Lookup.getAnswers方法代碼示例

本文整理匯總了Java中org.xbill.DNS.Lookup.getAnswers方法的典型用法代碼示例。如果您正苦於以下問題:Java Lookup.getAnswers方法的具體用法?Java Lookup.getAnswers怎麽用?Java Lookup.getAnswers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.xbill.DNS.Lookup的用法示例。


在下文中一共展示了Lookup.getAnswers方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testDnsJavaWithDnsServer

import org.xbill.DNS.Lookup; //導入方法依賴的package包/類
@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,代碼行數:21,代碼來源:DnsMonitorTest.java

示例2: testNoAnswer

import org.xbill.DNS.Lookup; //導入方法依賴的package包/類
@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,代碼行數:23,代碼來源:DnsMonitorTest.java

示例3: testNoAnswer

import org.xbill.DNS.Lookup; //導入方法依賴的package包/類
@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,代碼行數:22,代碼來源:DnsMonitorTest.java

示例4: process

import org.xbill.DNS.Lookup; //導入方法依賴的package包/類
@Override
public void process(Exchange exchange) throws Exception {
    String dnsName = exchange.getIn().getHeader(DnsConstants.DNS_NAME, String.class);
    ObjectHelper.notEmpty(dnsName, "Header " + DnsConstants.DNS_NAME);

    Object type = exchange.getIn().getHeader(DnsConstants.DNS_TYPE);
    Integer dnsType = null;
    if (type != null) {
        dnsType = Type.value(String.valueOf(type));
    }
    Object dclass = exchange.getIn().getHeader(DnsConstants.DNS_CLASS);
    Integer dnsClass = null;
    if (dclass != null) {
        dnsClass = DClass.value(String.valueOf(dclass));
    }

    Lookup lookup = (dnsClass == null)
            ? (dnsType == null ? new Lookup(dnsName) : new Lookup(dnsName, dnsType))
            : new Lookup(dnsName, dnsType, dnsClass);

    lookup.run();
    if (lookup.getAnswers() != null) {
        exchange.getIn().setBody(lookup.getAnswers());
    } else {
        throw new CamelException(lookup.getErrorString());
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:28,代碼來源:DnsLookupProducer.java

示例5: main

import org.xbill.DNS.Lookup; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
	Lookup lookup = new Lookup("www.xqbase.com");
	lookup.setResolver(new SimpleResolver("localhost"));
	lookup.run();
	for (Record record : lookup.getAnswers()) {
		System.out.println(record);
	}
}
 
開發者ID:xqbase,項目名稱:ddns,代碼行數:9,代碼來源:TestLookup.java

示例6: getCnameForHost

import org.xbill.DNS.Lookup; //導入方法依賴的package包/類
/**
 * Gets the CNAME record for the host.
 *
 * @param host
 *            host
 * @return CNAME record may return null if not found.
 * @throws TextParseException
 */
private String getCnameForHost(final String host) throws TextParseException {

    final Lookup lookup = new Lookup(host, Type.CNAME);
    lookup.run();
    if (lookup.getAnswers().length == 0) {
        LOG.log(Level.SEVERE, "unableToFindCNAME", new Object[] {
            host
        });
        return null;
    }
    return ((CNAMERecord) lookup.getAnswers()[0]).getTarget().toString();
}
 
開發者ID:trajano,項目名稱:wagon-git,代碼行數:21,代碼來源:GitHubPagesWagon.java

示例7: main

import org.xbill.DNS.Lookup; //導入方法依賴的package包/類
public static void main(String[] args) {
//        System.err.println("Outcome: "
//                + CheckEmailObj.checkEmail("[email protected]"));

        String qqhostName = "qq.com";
        String qqhostName2 = "outlook.com";

        System.out.println(DNSResolver.checkDNS(qqhostName2, false));
       // System.out.println(DNSResolver.checkDNS("outlook.com", true));


        try {
            Lookup  lookup = new Lookup(qqhostName2, Type.A);

            lookup.run();

            for(Record r : lookup.getAnswers())
            System.out.println(r);


        } catch (TextParseException e) {
            e.printStackTrace();
        }





        // System.out.println( MailChecker.validate("[email protected]"));
    }
 
開發者ID:h819,項目名稱:spring-boot,代碼行數:31,代碼來源:DNSResolver.java

示例8: getIPV6ByName

import org.xbill.DNS.Lookup; //導入方法依賴的package包/類
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,代碼行數:33,代碼來源:DNSProvider.java

示例9: getTXTRecords

import org.xbill.DNS.Lookup; //導入方法依賴的package包/類
public List<String>
getTXTRecords(
	String		query )
{
	List<String>	result = new ArrayList<>(2);

	try{
		Lookup l = new Lookup( query, Type.TXT );
		
		setCache( null, l );
		
		l.run();
		
		Record[] records = l.getAnswers();
		
		if ( records != null ){
			
			for ( Record r: records ){
				
				TXTRecord txt = (TXTRecord)r;
				
				result.addAll((List<String>)txt.getStrings());
			}
		}
	}catch( Throwable e ){
		
	}
	
	return( result );
}
 
開發者ID:vuze,項目名稱:vuze-remote-for-android,代碼行數:31,代碼來源:DNSProvider.java

示例10: getTXTRecord

import org.xbill.DNS.Lookup; //導入方法依賴的package包/類
public String
getTXTRecord(
	String		query )

	throws UnknownHostException
{			
	try{
		Lookup l = new Lookup( query, Type.TXT );
		
		setCache( null, l );
		
		l.run();
		
		Record[] records = l.getAnswers();
		
		if ( records != null ){
			
			for ( Record r: records ){
				
				TXTRecord txt = (TXTRecord)r;
				
				List<String> strs = (List<String>)txt.getStrings();
				
				if ( strs.size() > 0 ){
					
					return( strs.get( 0 ));
				}
			}
		}
		
		return( null );
		
	}catch( Throwable e ){
		
		throw( new UnknownHostException( query + ": " + Debug.getNestedExceptionMessage( e )));
	}
}
 
開發者ID:vuze,項目名稱:vuze-remote-for-android,代碼行數:38,代碼來源:DNSProvider.java


注:本文中的org.xbill.DNS.Lookup.getAnswers方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。