Tools to work with the Google DNS over HTTPS API in R
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
2.2 KiB

#' Vectorized query, returning only answers in a data frame
#' @param entities character vector of entities to query
#' @param type RR type can be represented as a number in [1, 65535] or canonical
#' string (A, aaaa, etc). More information on RR types can be
#' found \href{}{here}.
#' @param cd (Checking Disabled) flag. Use `TRUE` to disable DNSSEC validation;
#' Default: `FALSE`.
#' @param do (DNSSEC OK) flag. Use `TRUE` include DNSSEC records (RRSIG, NSEC, NSEC3);
#' Default: `FALSE`.
#' @param edns_client_subnet The edns0-client-subnet option. Format is an IP
#' address with a subnet mask. Examples: \code{},
#' \code{2001:700:300::/48}.\cr
#' If you are using DNS-over-HTTPS because of privacy concerns, and do
#' not want any part of your IP address to be sent to authoritative
#' nameservers for geographic location accuracy, use
#' \code{edns_client_subnet=}. Google Public DNS normally sends
#' approximate network information (usually replacing the last part of
#' your IPv4 address with zeroes). \code{} is the default.
#' @return \code{data.frame} of only answers (use \code{query()} for detailed responses)
#' @references \url{}
#' @export
#' @note this is a fairly naive function. It expects \code{Answer} to be one of the
#' return value list slots. The intent for it was to make it easier
#' to do bulk forward queries. It will get smarter in future versions.
#' @examples
#' hosts <- c("", "", "", "")
#' gdns::bulk_query(hosts)
bulk_query <- function(entities, type = 1, cd = FALSE, do = FALSE,
edns_client_subnet = "") {
query, type = type, cd = cd,
edns_client_subnet = edns_client_subnet
) -> results
lapply(seq_along(results), function(idx) {
res <-[[idx]])
res$entity <- entities[[idx]]
}) -> xlst
xdf <-, xlst)
class(xdf) <- c("tbl_df", "tbl", "data.frame")