Java 类org.xbill.DNS.Address 实例源码

项目:openvisualtraceroute    文件:DNSLookupService.java   
public static void main(final String[] args) throws UnknownHostException {
    long t = System.nanoTime();

    System.out.println(Address.getByName("www.google.fr").getHostAddress() + " " + (System.nanoTime() - t));
    t = System.nanoTime();
    System.out.println(InetAddress.getByName("www.google.fr").getHostAddress() + " " + (System.nanoTime() - t));
}
项目:BUbiNG    文件:DnsJavaResolver.java   
@Override
public InetAddress[] resolve(String hostname) throws UnknownHostException {
    if ("localhost".equals(hostname)) return Frontier.LOOPBACK;
    // DnsJava does not understand dotted-notation IP addresses with additional zeroes (e.g., 127.0.0.01).
    if (RuntimeConfiguration.DOTTED_ADDRESS.matcher(hostname).matches()) return InetAddress.getAllByName(hostname);
    // This avoid expensive trials with domain suffixes (but must not be applied to dotted-notation IP addresses).
    hostname = hostname.endsWith(".") ? hostname : hostname + ".";
    return Address.getAllByName(hostname);
}
项目:mireka    文件:Dnsbl.java   
/**
 * @return null if the host is not listed
 */
private InetAddress queryARecord() {
    try {
        return Address.getByName(queryDomain);
    } catch (UnknownHostException e) {
        return null;
    }
}
项目:Virtual-Hosts    文件:DnsChange.java   
public static ByteBuffer handle_dns_packet(Packet packet) {
    if (DOMAINS_IP_MAPS == null) {
        Log.d(TAG, "DOMAINS_IP_MAPS IS NULL HOST FILE ERROR");
        return null;
    }
    try {
        ByteBuffer packet_buffer=packet.backingBuffer;
        packet_buffer.mark();
        byte[] tmp_bytes = new byte[packet_buffer.remaining()];
        packet_buffer.get(tmp_bytes);
        packet_buffer.reset();
        Message message = new Message(tmp_bytes);
        Name query_domain = message.getQuestion().getName();
        String query_string = query_domain.toString();
        Log.d(TAG, "query: " + query_domain);
        if (!DOMAINS_IP_MAPS.containsKey(query_string)) {
            query_string="."+query_string;
            int j=0;
            while (true){
                int i=query_string.indexOf(".",j);
                if (i==-1){
                    return null;
                }
                String str=query_string.substring(i);
                if("".equals(str)){
                    return null;
                }
                if(DOMAINS_IP_MAPS.containsKey(str)){
                    query_string=str;
                    break;
                }
                j=i+1;
            }
        }
        InetAddress address = Address.getByAddress(DOMAINS_IP_MAPS.get(query_string));
        ARecord a_record = new ARecord(query_domain, 1, 86400, address);
        message.addRecord(a_record, 1);
        message.getHeader().setFlag(Flags.QR);
        packet_buffer.limit(packet_buffer.capacity());
        packet_buffer.put(message.toWire());
        packet_buffer.limit(packet_buffer.position());
        packet_buffer.reset();
        packet.swapSourceAndDestination();
        packet.updateUDPBuffer(packet_buffer, packet_buffer.remaining());
        packet_buffer.position(packet_buffer.limit());
        Log.d(TAG, "hit: " + query_domain.toString() + " " + address.getHostName());
        return packet_buffer;
    } catch (Exception e) {
        Log.d(TAG, "dns hook error", e);
        return null;
    }

}
项目:openvisualtraceroute    文件:DNSLookupService.java   
public InetAddress getIp(final String name) throws UnknownHostException {
    return Address.getByName(name);
}
项目:Camel    文件:DnsConverter.java   
@Converter
public static String toString(Address address) {
    return address.toString();
}
项目:Camel    文件:DnsConverter.java   
@Converter
public static InetAddress toInetAddress(String domain) throws UnknownHostException {
    return Address.getByName(domain);
}
项目:wot_gateways    文件:DNSUtils.java   
public InetAddress getIpAddress(String name) throws UnknownHostException {
    InetAddress addr = Address.getByName(name);
    return addr;
}
项目:KinoCast    文件:CustomDns.java   
@Override
public List<InetAddress> lookup(String hostname) throws UnknownHostException {
    // I'm initializing the DNS resolvers here to take advantage of this method being called in a background-thread managed by OkHttp
    init();
    return Collections.singletonList(Address.getByName(hostname));
}