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


Java ResolverConfig类代码示例

本文整理汇总了Java中org.xbill.DNS.ResolverConfig的典型用法代码示例。如果您正苦于以下问题:Java ResolverConfig类的具体用法?Java ResolverConfig怎么用?Java ResolverConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ResolverConfig类属于org.xbill.DNS包,在下文中一共展示了ResolverConfig类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hostToAddr

import org.xbill.DNS.ResolverConfig; //导入依赖的package包/类
public String hostToAddr(String hostname) {
    if (hostname == null || hostname=="") {
        hostname = ResolverConfig.getCurrentConfig().server();
        if (hostname==null){
            hostname="0";
        }
    }
    InetAddress addr;
    try {
        if (hostname.equals("0"))
            addr = InetAddress.getLocalHost();
        else
            addr = InetAddress.getByName(hostname);
        InetSocketAddress address = new InetSocketAddress(addr, 53);
        return address.getAddress().getHostAddress();
    } catch (UnknownHostException e){

    }
    return "";
}
 
开发者ID:gryphius,项目名称:androdns,代码行数:21,代码来源:DNSFormActivity.java

示例2: getSystemDNSServers

import org.xbill.DNS.ResolverConfig; //导入依赖的package包/类
/**
 * Get System DNS Servers
 * @return A list of InetAddress objects contains the system's configured DNS servers
 */
public List<InetAddress> getSystemDNSServers() {

    List<InetAddress> dnsServers = new ArrayList<InetAddress>();
    ResolverConfig resolverConfig = new ResolverConfig();

    try {
        for(String dnsHostIp : resolverConfig.servers()) {
            if(dnsHostIp.equals("")) continue;
            dnsServers.add(InetAddress.getByName(dnsHostIp));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return dnsServers;
}
 
开发者ID:netkicorp,项目名称:java-wns-resolver,代码行数:20,代码来源:DNSBootstrapService.java

示例3: singleDnsServer

import org.xbill.DNS.ResolverConfig; //导入依赖的package包/类
@Test
public void singleDnsServer() {

    String[] dnsServers = { "8.8.8.8" };

    try {
        ResolverConfig mockResolver = PowerMockito.mock(ResolverConfig.class);
        when(mockResolver.servers()).thenReturn(dnsServers);
        PowerMockito.whenNew(ResolverConfig.class).withNoArguments().thenReturn(mockResolver);
    } catch (Exception e) {
        fail("Test Setup Failed: " + e.toString());
    }

    DNSBootstrapService testService = new DNSBootstrapService();

    List<InetAddress> addrs = testService.getSystemDNSServers();

    assertEquals("Validate Addr Count", 1, addrs.size());
    assertEquals("Validate Address", "8.8.8.8", addrs.get(0).getHostAddress());
}
 
开发者ID:netkicorp,项目名称:java-wns-resolver,代码行数:21,代码来源:DNSBootstrapServiceTest.java

示例4: multipleDnsServers

import org.xbill.DNS.ResolverConfig; //导入依赖的package包/类
@Test
public void multipleDnsServers() {

    String[] dnsServers = { "8.8.8.8", "8.8.4.4" };

    try {
        ResolverConfig mockResolver = PowerMockito.mock(ResolverConfig.class);
        when(mockResolver.servers()).thenReturn(dnsServers);
        PowerMockito.whenNew(ResolverConfig.class).withNoArguments().thenReturn(mockResolver);
    } catch (Exception e) {
        fail("Test Setup Failed: " + e.toString());
    }

    DNSBootstrapService testService = new DNSBootstrapService();
    List<InetAddress> addrs = testService.getSystemDNSServers();

    assertEquals("Validate Addr Count", 2, addrs.size());
    assertEquals("Validate Address", "8.8.8.8", addrs.get(0).getHostAddress());
    assertEquals("Validate Address", "8.8.4.4", addrs.get(1).getHostAddress());
}
 
开发者ID:netkicorp,项目名称:java-wns-resolver,代码行数:21,代码来源:DNSBootstrapServiceTest.java

示例5: noDnsServers

import org.xbill.DNS.ResolverConfig; //导入依赖的package包/类
@Test
public void noDnsServers() {

    String[] dnsServers = { };

    try {
        ResolverConfig mockResolver = PowerMockito.mock(ResolverConfig.class);
        when(mockResolver.servers()).thenReturn(dnsServers);
        PowerMockito.whenNew(ResolverConfig.class).withNoArguments().thenReturn(mockResolver);
    } catch (Exception e) {
        fail("Test Setup Failed: " + e.toString());
    }

    DNSBootstrapService testService = new DNSBootstrapService();
    List<InetAddress> addrs = testService.getSystemDNSServers();

    assertEquals("Validate Addr Count", 0, addrs.size());
}
 
开发者ID:netkicorp,项目名称:java-wns-resolver,代码行数:19,代码来源:DNSBootstrapServiceTest.java

示例6: getResolvers

import org.xbill.DNS.ResolverConfig; //导入依赖的package包/类
/**
 * Instantiate a set of default DNS <code>Resolver</code> by the provided Server. In case of
 * DNSSEC validation is needed, <code>ValidatingResolver</code> will be instantiated.
 *
 * @param dnsSec <code>true</code> iff DNSSEC is enabled
 * @param trustAnchor Public cryptographic to validate against
 *
 * @return A list of default <code>Resolver</code>
 *
 * @throws ConfigurationException
 *      Exceptional circumstances in which no default <code>Resolver</code> can be created.
 */
public static Map<String, Resolver> getResolvers(boolean dnsSec, String trustAnchor)
                                        throws ConfigurationException
{
    String[] servers = ResolverConfig.getCurrentConfig().servers();
    Map<String, Resolver> resolvers = new LinkedHashMap<>(servers.length);
    for (String server : servers) {
        Resolver resolver = instantiateResolver(dnsSec, trustAnchor, server);
        if (resolver != null) {
            resolvers.put(server, resolver);
        }
    }

    if (resolvers.isEmpty()) {
        throw new ConfigurationException("Unable to retrieve Default Resolvers");
    }

    return resolvers;
}
 
开发者ID:eclipse,项目名称:tiaki-java,代码行数:31,代码来源:DnsUtil.java

示例7: discoverResources

import org.xbill.DNS.ResolverConfig; //导入依赖的package包/类
@Override
public Set<DiscoveredResourceDetails> discoverResources(
        ResourceDiscoveryContext context)
        throws InvalidPluginConfigurationException, Exception {
    
    ResolverConfig conf = new ResolverConfig();
    
    Set<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
    for (String server: conf.servers()) {
        String name = "DNS server " + server;
        DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
                context.getResourceType(),
                server, // database key
                name, // UI name
                null, // Version
                name,
                context.getDefaultPluginConfiguration(),
                null); // process info
        set.add(detail); 
    }
    return set;
}
 
开发者ID:genman,项目名称:rhq-plugins,代码行数:23,代码来源:DNSDiscovery.java

示例8: onReceive

import org.xbill.DNS.ResolverConfig; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    ResolverConfig.refresh();
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:5,代码来源:SmackAndroid.java

示例9: onReceive

import org.xbill.DNS.ResolverConfig; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
	ResolverConfig.refresh();
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:5,代码来源:SmackAndroid.java


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