Search in sources :

Example 1 with DNSQuery

use of org.exobel.routerkeygen.utils.dns.DNSQuery in project routerkeygenAndroid by routerkeygen.

the class AlcatelLucentKeygen method getKeys.

@Override
public List<String> getKeys() {
    if (getMacAddress().length() != 12) {
        setErrorCode(R.string.msg_errpirelli);
        return null;
    }
    DNSQuery dnsquery = new DNSQuery(getMacAddress(), 255, 1);
    DatagramSocket datagramsocket = null;
    try {
        datagramsocket = new DatagramSocket();
        datagramsocket.setSoTimeout(5000);
        int i = 0;
        boolean noReply = false;
        do {
            try {
                sendQuery(dnsquery, datagramsocket, InetAddress.getByName("hak.im"));
                noReply = true;
            } catch (IOException e) {
                e.printStackTrace();
            }
            ++i;
            if (i >= 3) {
                //Give up.
                return getResults();
            }
        } while (!noReply);
        getResponse(dnsquery, datagramsocket);
        addPassword(NSLookup.getKey(dnsquery));
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (datagramsocket != null) {
            datagramsocket.close();
        }
    }
    return getResults();
}
Also used : DatagramSocket(java.net.DatagramSocket) DNSQuery(org.exobel.routerkeygen.utils.dns.DNSQuery) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 DatagramSocket (java.net.DatagramSocket)1 DNSQuery (org.exobel.routerkeygen.utils.dns.DNSQuery)1