Explorar el Código

new/addtl column for bulk_query and new RR global data

tags/v0.3.1
boB Rudis hace 6 años
padre
commit
2702ed26f8
No se encontró ninguna clave conocida en la base de datos para esta firma ID de clave GPG: 1D7529BE14E2BBA9
  1. 2
      DESCRIPTION
  2. 4
      NEWS.md
  3. 15
      R/gdns-package.r
  4. 4
      R/utils.R
  5. 38
      R/zbulk-query.R
  6. 29
      R/zgdns.r
  7. BIN
      data/resource_record_tbl.rda
  8. 4
      man/bulk_query.Rd
  9. 23
      man/resource_record_tbl.Rd
  10. 2
      tests/testthat/test-gdns.R

2
DESCRIPTION

@ -1,6 +1,6 @@
Package: gdns
Title: Tools to Work with Google's 'DNS-over-HTTPS' ('DoH') 'API'
Version: 0.2.1
Version: 0.3.0
Authors@R: c(
person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5670-2640"))

4
NEWS.md

@ -1,6 +1,8 @@
# gdns 0.2.2
# gdns 0.3.0
* removed purrr, dplyr and tibble dependencies
* `bulk_query()` now returns the original query string in a `query` column
* added `resource_record_tbl` data frame of DNS RR metadata
# gdns 0.2.1

15
R/gdns-package.r

@ -26,3 +26,18 @@
#' stri_detect_fixed
#' @importFrom jsonlite fromJSON
NULL
#' An overview of resource records (RRs) permissible in zone files of the Domain Name System (DNS)
#'
#' A dataset containing the DNS resource record types, names, description and purpose
#'
#' @format A data frame with 39 rows and 4 variables:
#' \describe{
#' \item{type}{numeric type of the resource record}
#' \item{name}{short name of the resource record}
#' \item{description}{short description of the resource record}
#' \item{purpose}{long-form description of the resource record purpose/function/usage}
#' }
#' @source \url{https://en.wikipedia.org/wiki/List_of_DNS_record_types}
"resource_record_tbl"

4
R/utils.R

@ -0,0 +1,4 @@
set_names <- function (object = nm, nm) {
names(object) <- nm
object
}

38
R/zbulk-query.R

@ -0,0 +1,38 @@
#' 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{http://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4}{here}.
#' @param edns_client_subnet The edns0-client-subnet option. Format is an IP
#' address with a subnet mask. Examples: \code{1.2.3.4/24},
#' \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=0.0.0.0/0}. Google Public DNS normally sends
#' approximate network information (usually replacing the last part of
#' your IPv4 address with zeroes). \code{0.0.0.0/0} is the default.
#' @return \code{data.frame} of only answers (use \code{query()} for detailed responses)
#' @references \url{https://developers.google.com/speed/public-dns/docs/dns-over-https}
#' @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("rud.is", "r-project.org", "rstudio.com", "apple.com")
#' gdns::bulk_query(hosts)
bulk_query <- function(entities, type = 1, edns_client_subnet = "0.0.0.0/0") {
map(
entities,
gdns::query,
type = type,
edns_client_subnet = edns_client_subnet
) -> results
results <- set_names(results, entities)
map_df(results, ~.x$Answer, .id = "query")
}

29
R/zgdns.r

@ -77,32 +77,3 @@ query <- function(name, type="1", edns_client_subnet="0.0.0.0/0") {
}
}
#' 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{http://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4}{here}.
#' @param edns_client_subnet The edns0-client-subnet option. Format is an IP
#' address with a subnet mask. Examples: \code{1.2.3.4/24},
#' \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=0.0.0.0/0}. Google Public DNS normally sends
#' approximate network information (usually replacing the last part of
#' your IPv4 address with zeroes). \code{0.0.0.0/0} is the default.
#' @return \code{data.frame} of only answers (use \code{query()} for detailed responses)
#' @references \url{https://developers.google.com/speed/public-dns/docs/dns-over-https}
#' @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("rud.is", "dds.ec", "r-project.org", "rstudio.com", "apple.com")
#' gdns::bulk_query(hosts)
bulk_query <- function(entities, type=1, edns_client_subnet="0.0.0.0/0") {
results <- map(entities, gdns::query, type=type, edns_client_subnet=edns_client_subnet)
map_df(results, ~.x$Answer)
}

BIN
data/resource_record_tbl.rda

Archivo binario no mostrado.

4
man/bulk_query.Rd

@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/zgdns.r
% Please edit documentation in R/zbulk-query.R
\name{bulk_query}
\alias{bulk_query}
\title{Vectorized query, returning only answers in a data frame}
@ -35,7 +35,7 @@ this is a fairly naive function. It expects \code{Answer} to be one of the
to do bulk forward queries. It will get smarter in future versions.
}
\examples{
hosts <- c("rud.is", "dds.ec", "r-project.org", "rstudio.com", "apple.com")
hosts <- c("rud.is", "r-project.org", "rstudio.com", "apple.com")
gdns::bulk_query(hosts)
}
\references{

23
man/resource_record_tbl.Rd

@ -0,0 +1,23 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gdns-package.r
\docType{data}
\name{resource_record_tbl}
\alias{resource_record_tbl}
\title{An overview of resource records (RRs) permissible in zone files of the Domain Name System (DNS)}
\format{A data frame with 39 rows and 4 variables:
\describe{
\item{type}{numeric type of the resource record}
\item{name}{short name of the resource record}
\item{description}{short description of the resource record}
\item{purpose}{long-form description of the resource record purpose/function/usage}
}}
\source{
\url{https://en.wikipedia.org/wiki/List_of_DNS_record_types}
}
\usage{
resource_record_tbl
}
\description{
A dataset containing the DNS resource record types, names, description and purpose
}
\keyword{datasets}

2
tests/testthat/test-gdns.R

@ -6,6 +6,6 @@ test_that("we can do something", {
doms <- c("example.com", "example.org", "example.net")
qry <- gdns::bulk_query(doms)
expect_that(dim(qry), equals(c(3, 4)))
expect_that(dim(qry), equals(c(3, 5)))
})

Cargando…
Cancelar
Guardar