Query DNS for information.
    Where `lookup()` returns record data, `query()` tries to interpret the data and return it's results

    :param name: name to lookup
    :param rdtype: DNS record type
    :param method: gai (getaddrinfo()), pydns, dig, drill, host, nslookup or auto (default)
    :param servers: (list of) server(s) to try in-order
    :param timeout: query timeout or a valiant approximation of that
    :param secure: return only DNSSEC secured response
    :param walk: Walk the DNS upwards looking for the record type or name/recordtype if walk='name'.
    :param walk_tld: Include the top-level domain in the walk
    :return: [] of records

def query(
    name,
    rdtype,
    method=None,
    servers=None,
    timeout=None,
    walk=False,
    walk_tld=False,
    secure=None
):
    '''
    Query DNS for information.
    Where `lookup()` returns record data, `query()` tries to interpret the data and return it's results

    :param name: name to lookup
    :param rdtype: DNS record type
    :param method: gai (getaddrinfo()), pydns, dig, drill, host, nslookup or auto (default)
    :param servers: (list of) server(s) to try in-order
    :param timeout: query timeout or a valiant approximation of that
    :param secure: return only DNSSEC secured response
    :param walk: Walk the DNS upwards looking for the record type or name/recordtype if walk='name'.
    :param walk_tld: Include the top-level domain in the walk
    :return: [] of records
    '''
    rdtype = rdtype.upper()
    qargs = {
        'method':   method,
        'servers':  servers,
        'timeout':  timeout,
        'walk':     walk,
        'walk_tld': walk_tld,
        'secure':   secure
    }

    if rdtype == 'PTR' and not name.endswith('arpa'):
        name = ptr_name(name)

    if rdtype == 'SPF':
        # 'SPF' has become a regular 'TXT' again
        qres = [answer for answer in lookup(name, 'TXT', **qargs) if answer.startswith('v=spf')]
        if not qres:
            qres = lookup(name, rdtype, **qargs)
    else:
        qres = lookup(name, rdtype, **qargs)

    rec_map = {
        'A':     a_rec,
        'AAAA':  aaaa_rec,
        'CAA':   caa_rec,
        'MX':    mx_rec,
        'SOA':   soa_rec,
        'SPF':   spf_rec,
        'SRV':   srv_rec,
        'SSHFP': sshfp_rec,
        'TLSA':  tlsa_rec,
    }

    if not qres or rdtype not in rec_map:
        return qres
    elif rdtype in ('A', 'AAAA', 'SSHFP', 'TLSA'):
        res = [rec_map[rdtype](res) for res in qres]
    elif rdtype in ('SOA', 'SPF'):
        res = rec_map[rdtype](qres[0])
    else:
        res = rec_map[rdtype](qres)

    return res