Browse Source

new/addtl column for bulk_query and new RR global data

boB Rudis 1 year ago
parent
commit
2702ed26f8
No known key found for this signature in database
10 changed files with 87 additions and 34 deletions
  1. 1
    1
      DESCRIPTION
  2. 3
    1
      NEWS.md
  3. 15
    0
      R/gdns-package.r
  4. 4
    0
      R/utils.R
  5. 38
    0
      R/zbulk-query.R
  6. 0
    29
      R/zgdns.r
  7. BIN
      data/resource_record_tbl.rda
  8. 2
    2
      man/bulk_query.Rd
  9. 23
    0
      man/resource_record_tbl.Rd
  10. 1
    1
      tests/testthat/test-gdns.R

+ 1
- 1
DESCRIPTION View File

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

+ 3
- 1
NEWS.md View File

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

+ 15
- 0
R/gdns-package.r View File

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

+ 4
- 0
R/utils.R View File

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

+ 38
- 0
R/zbulk-query.R View File

@@ -0,0 +1,38 @@
1
+#' Vectorized query, returning only answers in a data frame
2
+#'
3
+#' @param entities character vector of entities to query
4
+#' @param type RR type can be represented as a number in [1, 65535] or canonical
5
+#'        string (A, aaaa, etc). More information on RR types can be
6
+#'        found \href{http://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4}{here}.
7
+#' @param edns_client_subnet The edns0-client-subnet option. Format is an IP
8
+#'        address with a subnet mask. Examples: \code{1.2.3.4/24},
9
+#'        \code{2001:700:300::/48}.\cr
10
+#'        If you are using DNS-over-HTTPS because of privacy concerns, and do
11
+#'        not want any part of your IP address to be sent to authoritative
12
+#'        nameservers for geographic location accuracy, use
13
+#'        \code{edns_client_subnet=0.0.0.0/0}. Google Public DNS normally sends
14
+#'        approximate network information (usually replacing the last part of
15
+#'        your IPv4 address with zeroes). \code{0.0.0.0/0} is the default.
16
+#' @return \code{data.frame} of only answers (use \code{query()} for detailed responses)
17
+#' @references \url{https://developers.google.com/speed/public-dns/docs/dns-over-https}
18
+#' @export
19
+#' @note this is a fairly naive function. It expects \code{Answer} to be one of the
20
+#'       return value list slots. The intent for it was to make it easier
21
+#'       to do bulk forward queries. It will get smarter in future versions.
22
+#' @examples
23
+#' hosts <- c("rud.is", "r-project.org", "rstudio.com", "apple.com")
24
+#' gdns::bulk_query(hosts)
25
+bulk_query <- function(entities, type = 1, edns_client_subnet = "0.0.0.0/0") {
26
+
27
+  map(
28
+    entities,
29
+    gdns::query,
30
+    type = type,
31
+    edns_client_subnet = edns_client_subnet
32
+  ) -> results
33
+
34
+  results <- set_names(results, entities)
35
+
36
+  map_df(results, ~.x$Answer, .id = "query")
37
+
38
+}

+ 0
- 29
R/zgdns.r View File

@@ -77,32 +77,3 @@ query <- function(name, type="1", edns_client_subnet="0.0.0.0/0") {
77 77
   }
78 78
 
79 79
 }
80
-
81
-#' Vectorized query, returning only answers in a data frame
82
-#'
83
-#' @param entities character vector of entities to query
84
-#' @param type RR type can be represented as a number in [1, 65535] or canonical
85
-#'        string (A, aaaa, etc). More information on RR types can be
86
-#'        found \href{http://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4}{here}.
87
-#' @param edns_client_subnet The edns0-client-subnet option. Format is an IP
88
-#'        address with a subnet mask. Examples: \code{1.2.3.4/24},
89
-#'        \code{2001:700:300::/48}.\cr
90
-#'        If you are using DNS-over-HTTPS because of privacy concerns, and do
91
-#'        not want any part of your IP address to be sent to authoritative
92
-#'        nameservers for geographic location accuracy, use
93
-#'        \code{edns_client_subnet=0.0.0.0/0}. Google Public DNS normally sends
94
-#'        approximate network information (usually replacing the last part of
95
-#'        your IPv4 address with zeroes). \code{0.0.0.0/0} is the default.
96
-#' @return \code{data.frame} of only answers (use \code{query()} for detailed responses)
97
-#' @references \url{https://developers.google.com/speed/public-dns/docs/dns-over-https}
98
-#' @export
99
-#' @note this is a fairly naive function. It expects \code{Answer} to be one of the
100
-#'       return value list slots. The intent for it was to make it easier
101
-#'       to do bulk forward queries. It will get smarter in future versions.
102
-#' @examples
103
-#' hosts <- c("rud.is", "dds.ec", "r-project.org", "rstudio.com", "apple.com")
104
-#' gdns::bulk_query(hosts)
105
-bulk_query <- function(entities, type=1, edns_client_subnet="0.0.0.0/0") {
106
-  results <- map(entities, gdns::query, type=type, edns_client_subnet=edns_client_subnet)
107
-  map_df(results, ~.x$Answer)
108
-}

BIN
data/resource_record_tbl.rda View File


+ 2
- 2
man/bulk_query.Rd View File

@@ -1,5 +1,5 @@
1 1
 % Generated by roxygen2: do not edit by hand
2
-% Please edit documentation in R/zgdns.r
2
+% Please edit documentation in R/zbulk-query.R
3 3
 \name{bulk_query}
4 4
 \alias{bulk_query}
5 5
 \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
35 35
       to do bulk forward queries. It will get smarter in future versions.
36 36
 }
37 37
 \examples{
38
-hosts <- c("rud.is", "dds.ec", "r-project.org", "rstudio.com", "apple.com")
38
+hosts <- c("rud.is", "r-project.org", "rstudio.com", "apple.com")
39 39
 gdns::bulk_query(hosts)
40 40
 }
41 41
 \references{

+ 23
- 0
man/resource_record_tbl.Rd View File

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

+ 1
- 1
tests/testthat/test-gdns.R View File

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

Loading…
Cancel
Save