package com.mayi.fastdevelop.okhttp;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;

import okhttp3.Dns;

public class HttpDns implements Dns {
    @Override
    public List<InetAddress> lookup(String hostname) {
        List<InetAddress> inetAddresses = new ArrayList<>();
        List<InetAddress> hostNameInetAddresses = null;
        try {
            hostNameInetAddresses = Dns.SYSTEM.lookup(hostname);
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        if (hostNameInetAddresses != null && hostNameInetAddresses.size() > 0) {
            inetAddresses.addAll(hostNameInetAddresses);
        }
        return inetAddresses;
    }
}