boB Rudis 4 months ago
parent
commit
515e696d1d
No known key found for this signature in database
52 changed files with 1401 additions and 90 deletions
  1. 8
    8
      DESCRIPTION
  2. 10
    0
      NAMESPACE
  3. 83
    0
      R/DNSHeader-class.R
  4. 43
    0
      R/DNSLabel-class.R
  5. 51
    0
      R/DNSQuestion-class.R
  6. 90
    0
      R/DNSRecord-class.R
  7. 25
    0
      R/RcppExports.R
  8. 9
    1
      R/aaa.R
  9. 3
    1
      R/clandnstine-package.R
  10. 98
    0
      R/doh-query.R
  11. 118
    0
      R/globals.R
  12. 7
    0
      R/is.R
  13. 46
    19
      R/resolver.R
  14. 1
    0
      R/set-res-types.R
  15. 24
    0
      R/to-inaddr-arpa.R
  16. 4
    0
      R/utils-infix-helpers.R
  17. 9
    0
      R/utils.R
  18. 62
    16
      README.Rmd
  19. 159
    40
      README.md
  20. 1
    1
      man/clandnstine.Rd
  21. 29
    0
      man/doh_post.Rd
  22. 32
    0
      man/doh_servers.Rd
  23. 5
    0
      man/gdns_context.Rd
  24. 5
    0
      man/gdns_get_address.Rd
  25. 17
    0
      man/gdns_get_hosts.Rd
  26. 17
    0
      man/gdns_get_resolution_type.Rd
  27. 17
    0
      man/gdns_get_resolvconf.Rd
  28. 31
    0
      man/gdns_get_root_servers.Rd
  29. 17
    0
      man/gdns_get_timeout.Rd
  30. 17
    0
      man/gdns_get_tls_ca_file.Rd
  31. 17
    0
      man/gdns_get_tls_ca_path.Rd
  32. 17
    0
      man/gdns_get_transports.Rd
  33. 1
    0
      man/gdns_lib_version.Rd
  34. 9
    2
      man/gdns_query.Rd
  35. 18
    1
      man/gdns_set_hosts.Rd
  36. 17
    0
      man/gdns_set_resolution_type.Rd
  37. 17
    0
      man/gdns_set_round_robin_upstreams.Rd
  38. 17
    0
      man/gdns_set_timeout.Rd
  39. 17
    0
      man/gdns_set_tls_ca_file.Rd
  40. 17
    0
      man/gdns_set_tls_ca_path.Rd
  41. 18
    1
      man/gdns_update_resolvers.Rd
  42. 15
    0
      man/int_gdns_get_root_servers.Rd
  43. 14
    0
      man/is_gctx.Rd
  44. 17
    0
      man/tidy.Rd
  45. 16
    0
      man/tidy.gdns_doh_response.Rd
  46. 14
    0
      man/to_inaddr_arpa.Rd
  47. BIN
      src/.vscode/ipch/fbe8796a0b446fa3/mmap_address.bin
  48. BIN
      src/.vscode/ipch/fbe8796a0b446fa3/resolver.ipch
  49. 24
    0
      src/RcppExports.cpp
  50. 51
    0
      src/clandnstine-main.cpp
  51. 45
    0
      src/from-wire.cpp
  52. 2
    0
      src/resolver.cpp

+ 8
- 8
DESCRIPTION View File

@@ -1,17 +1,14 @@
1 1
 Package: clandnstine
2 2
 Type: Package
3 3
 Title: Perform Secure-by-default 'DNS' Queries
4
-Version: 0.1.0
5
-Date: 2019-01-18
4
+Version: 0.2.1
5
+Date: 2019-05-26
6 6
 Authors@R: c(
7 7
     person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"), 
8 8
            comment = c(ORCID = "0000-0001-5670-2640"))
9 9
   )
10 10
 Maintainer: Bob Rudis <bob@rud.is>
11
-Description: Methods are provided to query 'Domain Name System' ('DNS') stub 
12
-    and recursive resolvers for all 'DNS' resource record types using 'UDP', 
13
-    'TCP', and/or 'TLS' transport layers. 'DNS' query support is provided
14
-    by the 'getdns' (<getdnsapi.net>) C library.
11
+Description: Perform and process 'DNS over TLS' and 'DNS over HTTPS' queries.
15 12
 SystemRequirements: C++11; libgetdns v1.5.1 or higher
16 13
 URL: https://gitlab.com/hrbrmstr/clandnstine
17 14
 BugReports: https://gitlab.com/hrbrmstr/clandnstine/issues
@@ -25,8 +22,11 @@ Depends:
25 22
 Imports:
26 23
     jsonlite,
27 24
     Rcpp,
28
-    magrittr
25
+    magrittr,
26
+    glue,
27
+    httr,
28
+    R6
29 29
 Roxygen: list(markdown = TRUE)
30 30
 RoxygenNote: 6.1.1
31 31
 LinkingTo: 
32
-    Rcpp
32
+    Rcpp

+ 10
- 0
NAMESPACE View File

@@ -2,12 +2,16 @@
2 2
 
3 3
 S3method(print,gctx)
4 4
 S3method(print,gdns_response)
5
+S3method(tidy,gdns_doh_response)
5 6
 export("%>%")
7
+export(doh_post)
8
+export(doh_servers)
6 9
 export(gdns_context)
7 10
 export(gdns_get_address)
8 11
 export(gdns_get_hosts)
9 12
 export(gdns_get_resolution_type)
10 13
 export(gdns_get_resolvconf)
14
+export(gdns_get_root_servers)
11 15
 export(gdns_get_timeout)
12 16
 export(gdns_get_tls_ca_file)
13 17
 export(gdns_get_tls_ca_path)
@@ -22,7 +26,13 @@ export(gdns_set_tls_ca_file)
22 26
 export(gdns_set_tls_ca_path)
23 27
 export(gdns_set_transports)
24 28
 export(gdns_update_resolvers)
29
+export(is_gctx)
30
+export(tidy)
31
+export(to_inaddr_arpa)
32
+import(R6)
33
+import(httr)
25 34
 importFrom(Rcpp,sourceCpp)
35
+importFrom(glue,glue_data)
26 36
 importFrom(jsonlite,fromJSON)
27 37
 importFrom(magrittr,"%>%")
28 38
 useDynLib(clandnstine, .registration = TRUE)

+ 83
- 0
R/DNSHeader-class.R View File

@@ -0,0 +1,83 @@
1
+R6Class(
2
+
3
+  classname = "DNSHeader",
4
+
5
+  public = list(
6
+
7
+    q = NULL,
8
+    a = NULL,
9
+    id = NULL,
10
+    auth = NULL,
11
+    bitmap = 0L,
12
+    qr = NULL,
13
+    opcode = NULL,
14
+    aa = NULL,
15
+    tc = NULL,
16
+    rd = NULL,
17
+    ra = NULL,
18
+    z = NULL,
19
+    ad = NULL,
20
+    ar = NULL,
21
+    cd = NULL,
22
+    rcode = NULL,
23
+
24
+    set_rd = function(val) {
25
+
26
+      bits(self$bitmap, 8) <- as.integer(val)
27
+
28
+    },
29
+
30
+    initialize = function(id = NULL, bitmap = NULL, q = 0L,
31
+                          a = 0L, auth = 0L, ar = 0L, ...) {
32
+
33
+      self$id <- id %||% sample(0:65535, 1)
34
+
35
+      self$bitmap <- bitmap %||% 0L
36
+      if (is.null(bitmap)) self$set_rd(1L)
37
+
38
+      self$q <- q
39
+      self$a <- a
40
+      self$auth <- auth
41
+      self$ar <- ar
42
+
43
+      valid <- c("qr", "opcode", "aa", "tc", "rd", "ra", "z", "ad", "cd", "rcode")
44
+
45
+      args <- list(...)
46
+      args <- setNames(args, tolower(colnames(args)))
47
+      args <- Filter(Negate(is.null), args[valid])
48
+
49
+      for (n in names(args)) self[[n]] <- args[[n]]
50
+
51
+    },
52
+
53
+    parse = function(buf, buf_pos = 1L) {
54
+
55
+      self$id <- readBin(buf[buf_pos:(buf_pos+1)], "int", size = 2, endian = "big")
56
+      self$bitmap <- readBin(buf[(buf_pos+2):(buf_pos+3)], "int", size = 2, endian = "big")
57
+      self$q <- readBin(buf[(buf_pos+4):(buf_pos+5)], "int", size = 2, endian = "big")
58
+      self$a <- readBin(buf[(buf_pos+6):(buf_pos+7)], "int", size = 2, endian = "big")
59
+      self$auth <- readBin(buf[(buf_pos+8):(buf_pos+9)], "int", size = 2, endian = "big")
60
+      self$ar <- readBin(buf[(buf_pos+10):(buf_pos+11)], "int", size = 2, endian = "big")
61
+
62
+      attr(self, "buflen") <- 12L
63
+
64
+      self
65
+
66
+    },
67
+
68
+    pack = function() {
69
+
70
+      c(
71
+        writeBin(as.integer(self$id), raw(), size = 2, endian = "big"),
72
+        writeBin(as.integer(self$bitmap), raw(), size = 2, endian = "big"),
73
+        writeBin(as.integer(self$q), raw(), size = 2, endian = "big"),
74
+        writeBin(as.integer(self$a), raw(), size = 2, endian = "big"),
75
+        writeBin(as.integer(self$auth), raw(), size = 2, endian = "big"),
76
+        writeBin(as.integer(self$ar), raw(), size = 2, endian = "big")
77
+      )
78
+
79
+    }
80
+
81
+  )
82
+
83
+) -> DNSHeader

+ 43
- 0
R/DNSLabel-class.R View File

@@ -0,0 +1,43 @@
1
+R6Class(
2
+
3
+  classname = "DNSLabel",
4
+
5
+  public = list(
6
+
7
+    label = NULL,
8
+
9
+    initialize = function(label) {
10
+
11
+      if (inherits(label, "DNSLabel")) {
12
+
13
+        self$label <- label$label
14
+
15
+      } else if (length(label) > 1) {
16
+
17
+        self$label <- as.character(label)
18
+
19
+      } else if (is.character(label)) {
20
+        label <- sub("\\.$", "", label)
21
+        self$label <- unlist(strsplit(label, "\\."), use.names = FALSE)
22
+      }
23
+
24
+    },
25
+
26
+    encode = function() {
27
+
28
+      sz <- nchar(self$label)
29
+      out <- raw()
30
+      for (i in seq_along(self$label)) {
31
+        out <- c(out, as.raw(sz[[i]]), charToRaw(self$label[[i]]))
32
+      }
33
+      c(out, as.raw(0x00))
34
+
35
+    },
36
+
37
+    parse = function(buf, buf_pos) {
38
+
39
+    }
40
+
41
+  )
42
+
43
+) -> DNSLabel

+ 51
- 0
R/DNSQuestion-class.R View File

@@ -0,0 +1,51 @@
1
+R6Class(
2
+
3
+  classname = "DNSQuestion",
4
+
5
+  public = list(
6
+
7
+    qname = NULL,
8
+    qtype = NULL,
9
+    qclass = NULL,
10
+
11
+    initialize = function(qname = NULL, qtype = 1L, qclass = 1L) {
12
+
13
+      if (inherits(qname, "DNSLabel")) {
14
+        self$qname <- qname
15
+      } else {
16
+        if (length(qname)) self$qname <- DNSLabel$new(qname)
17
+      }
18
+
19
+      self$qtype <- qtype
20
+      self$qclass <- qclass
21
+
22
+    },
23
+
24
+    pack = function() {
25
+      c(
26
+        self$qname$encode(),
27
+        writeBin(as.integer(self$qtype), raw(), size = 2, endian = "big"),
28
+        writeBin(as.integer(self$qclass), raw(), size = 2, endian = "big")
29
+      )
30
+    },
31
+
32
+    parse = function(buf, buf_pos = 1L) {
33
+
34
+      ret <- DNSLabel$new()$parse(buf, buf_pos)
35
+
36
+      self$qname <- ret
37
+
38
+      buf_pos <- buf_pos + attr(ret, "buflen")
39
+
40
+      self$qtype <- readBin(buf[buf_pos:(buf_pos+1)], "int", size = 2, endian = "big")
41
+      self$qclass <- readBin(buf[(buf_pos+2):(buf_pos+3)], "int", size = 2, endian = "big")
42
+
43
+      attr(self, "buflen") <- attr(ret, "buflen") + 4L
44
+
45
+      self
46
+
47
+    }
48
+
49
+  )
50
+
51
+) -> DNSQuestion

+ 90
- 0
R/DNSRecord-class.R View File

@@ -0,0 +1,90 @@
1
+R6Class(
2
+
3
+  classname = "DNSRecord",
4
+
5
+  public = list(
6
+
7
+    header = NULL,
8
+    questions = list(),
9
+    rr = list(),
10
+    auth = list(),
11
+    ar = list(),
12
+
13
+    initialize = function(header = NULL, questions = NULL,
14
+                          rr = NULL, q = NULL, a = NULL,
15
+                          auth = NULL, ar = NULL) {
16
+
17
+      self$header <- header %||% DNSHeader$new()
18
+      self$questions <- questions %||% list()
19
+      self$rr <- rr %||% list()
20
+      self$auth <- auth %||% list()
21
+      self$ar <- ar %||% list()
22
+
23
+      if (length(q)) self$questions <- append(self$questions, q)
24
+      if (length(a)) self$rr <- append(self$rr, a)
25
+
26
+      self$set_header_qa()
27
+
28
+    },
29
+
30
+    question = function(qname, qtype = "A", qclass = "IN") {
31
+      DNSRecord$new(
32
+        q = DNSQuestion$new(
33
+          qname = qname,
34
+          qtype = .qtype[toupper(qtype)],
35
+          qclass = .class[toupper(qclass)]
36
+        )
37
+      )
38
+    },
39
+
40
+    parse = function(buf, buf_pos = 1L) {
41
+
42
+      #self$header <- NULL
43
+      self$questions <- list()
44
+      self$rr <- list()
45
+      self$auth <- list()
46
+      self$ar <- list()
47
+
48
+      buf_pos <- 1L
49
+
50
+      ret <- DNSHeader$new()$parse(buf)
51
+
52
+      self$header <- ret
53
+
54
+      buf_pos <- attr(ret, "buflen") + 1L
55
+
56
+      message(buf_pos)
57
+
58
+      self$questions <- lapply(1:self$header$q, function(.idx) {
59
+
60
+        ret <- DNSQuestion$new()$parse(buf, buf_pos)
61
+        buf_pos <<- buf_pos + attr(ret, "buflen")
62
+        ret
63
+
64
+      })
65
+
66
+      self
67
+
68
+    },
69
+
70
+    # Reset header q/a/auth/ar counts to match numver of records (normally done transparently)
71
+
72
+    set_header_qa = function() {
73
+      self$header$q <- length(self$questions)
74
+      self$header$a <- length(self$rr)
75
+      self$header$auth <- length(self$auth)
76
+      self$header$ar <- length(self$ar)
77
+    },
78
+
79
+    pack = function() {
80
+      out <- self$header$pack()
81
+      for (q in self$questions) out <- c(out, q$pack())
82
+      out
83
+    }
84
+
85
+  ),
86
+
87
+  private = list(
88
+  )
89
+
90
+) -> DNSRecord

+ 25
- 0
R/RcppExports.R View File

@@ -3,6 +3,7 @@
3 3
 
4 4
 #' Return gdns library version
5 5
 #'
6
+#' @family utlity functions
6 7
 #' @export
7 8
 gdns_lib_version <- function() {
8 9
     .Call(`_clandnstine_gdns_lib_version`)
@@ -18,6 +19,7 @@ int_gdns_update_resolvers <- function(gctx, resolvers) {
18 19
 #'
19 20
 #' @param gctx gdns resolver context created with [gdns_resolver()]
20 21
 #' @param timeout number of milliseconds (integer; i.e. not-fractional)
22
+#' @family context functions
21 23
 #' @export
22 24
 gdns_set_timeout <- function(gctx, timeout) {
23 25
     .Call(`_clandnstine_gdns_set_timeout`, gctx, timeout)
@@ -26,6 +28,7 @@ gdns_set_timeout <- function(gctx, timeout) {
26 28
 #' Retreive the number of milliseconds to wait for request to return
27 29
 #'
28 30
 #' @param gctx gdns resolver context created with [gdns_resolver()]
31
+#' @family context functions
29 32
 #' @export
30 33
 gdns_get_timeout <- function(gctx) {
31 34
     .Call(`_clandnstine_gdns_get_timeout`, gctx)
@@ -37,6 +40,7 @@ gdns_get_timeout <- function(gctx) {
37 40
 #' @md
38 41
 #' @param gctx gdns resolver context created with [gdns_resolver()]
39 42
 #' @param flag if `TRUE` (the default) round robin queries when using more than one stub resolver,
43
+#' @family context functions
40 44
 #' @export
41 45
 gdns_set_round_robin_upstreams <- function(gctx, flag = TRUE) {
42 46
     .Call(`_clandnstine_gdns_set_round_robin_upstreams`, gctx, flag)
@@ -63,6 +67,7 @@ int_gdns_set_resolution_type <- function(gctx, res_type) {
63 67
 #' Retreive what transports are used for DNS lookups.
64 68
 #'
65 69
 #' @param gctx gdns resolver context created with [gdns_resolver()]
70
+#' @family context functions
66 71
 #' @export
67 72
 gdns_get_transports <- function(gctx) {
68 73
     .Call(`_clandnstine_gdns_get_transports`, gctx)
@@ -71,6 +76,7 @@ gdns_get_transports <- function(gctx) {
71 76
 #' Retreive the value of the localnames namespace
72 77
 #'
73 78
 #' @param gctx gdns resolver context created with [gdns_resolver()]
79
+#' @family context functions
74 80
 #' @export
75 81
 gdns_get_hosts <- function(gctx) {
76 82
     .Call(`_clandnstine_gdns_get_hosts`, gctx)
@@ -79,6 +85,7 @@ gdns_get_hosts <- function(gctx) {
79 85
 #' Retreive the value with which the context's upstream recursive servers and suffixes were initialized
80 86
 #'
81 87
 #' @param gctx gdns resolver context created with [gdns_resolver()]
88
+#' @family context functions
82 89
 #' @export
83 90
 gdns_get_resolvconf <- function(gctx) {
84 91
     .Call(`_clandnstine_gdns_get_resolvconf`, gctx)
@@ -87,6 +94,7 @@ gdns_get_resolvconf <- function(gctx) {
87 94
 #' Retreive the value with which the context's upstream recursive servers and suffixes were initialized
88 95
 #'
89 96
 #' @param gctx gdns resolver context created with [gdns_resolver()]
97
+#' @family context functions
90 98
 #' @export
91 99
 gdns_get_tls_ca_path <- function(gctx) {
92 100
     .Call(`_clandnstine_gdns_get_tls_ca_path`, gctx)
@@ -95,6 +103,7 @@ gdns_get_tls_ca_path <- function(gctx) {
95 103
 #' Retreive the file location with CA certificates for verification purposes
96 104
 #'
97 105
 #' @param gctx gdns resolver context created with [gdns_resolver()]
106
+#' @family context functions
98 107
 #' @export
99 108
 gdns_get_tls_ca_file <- function(gctx) {
100 109
     .Call(`_clandnstine_gdns_get_tls_ca_file`, gctx)
@@ -104,6 +113,7 @@ gdns_get_tls_ca_file <- function(gctx) {
104 113
 #'
105 114
 #' @param gctx gdns resolver context created with [gdns_resolver()]
106 115
 #' @param ca_path directory with Certificate Authority certificates
116
+#' @family context functions
107 117
 #' @export
108 118
 gdns_set_tls_ca_path <- function(gctx, ca_path) {
109 119
     .Call(`_clandnstine_gdns_set_tls_ca_path`, gctx, ca_path)
@@ -113,11 +123,24 @@ gdns_set_tls_ca_path <- function(gctx, ca_path) {
113 123
 #'
114 124
 #' @param gctx gdns resolver context created with [gdns_resolver()]
115 125
 #' @param ca_file file with Certificate Authority certificates
126
+#' @family context functions
116 127
 #' @export
117 128
 gdns_set_tls_ca_file <- function(gctx, ca_file) {
118 129
     .Call(`_clandnstine_gdns_set_tls_ca_file`, gctx, ca_file)
119 130
 }
120 131
 
132
+#' Retrieve the list of addresses in use for looking up top-level domains in use by the context.
133
+#'
134
+#' @param gctx gdns resolver context created with [gdns_resolver()]
135
+#' @keywords internal
136
+int_gdns_get_root_servers <- function(gctx) {
137
+    .Call(`_clandnstine_int_gdns_get_root_servers`, gctx)
138
+}
139
+
140
+int_dns_wire_to_list <- function(buf) {
141
+    .Call(`_clandnstine_int_dns_wire_to_list`, buf)
142
+}
143
+
121 144
 #' Test whether an object is an external pointer
122 145
 #'
123 146
 #' @param x object to test
@@ -144,6 +167,7 @@ int_gdns_context <- function(resolvers) {
144 167
 #'
145 168
 #' @param gctx gdns resolver context created with [gdns_resolver()]
146 169
 #' @param host to lookup
170
+#' @family query functions
147 171
 #' @export
148 172
 #' @examples
149 173
 #' x <- gdns_resolver()
@@ -165,6 +189,7 @@ int_gdns_query <- function(gctx, name, rr, include_reporting = FALSE) {
165 189
 #'
166 190
 #' @param gctx gdns resolver context created with [gdns_resolver()]
167 191
 #' @export
192
+#' @family context functions
168 193
 #' @examples
169 194
 #' x <- gdns_context()
170 195
 #' gdns_get_resolution_type(x)

+ 9
- 1
R/aaa.R View File

@@ -89,4 +89,12 @@ ta = 32768,
89 89
 dlv = 32769
90 90
 )
91 91
 
92
-rr_types_rev <- set_names(names(rr_types), as.character(rr_types))
92
+rr_types_rev <- set_names(names(rr_types), as.character(rr_types))
93
+
94
+httr::user_agent(
95
+  sprintf(
96
+    "clandnstine package v%s: (<%s>)",
97
+    utils::packageVersion("clandnstine"),
98
+    utils::packageDescription("clandnstine")$URL
99
+  )
100
+) -> .CLANDNSTINE_UA

+ 3
- 1
R/clandnstine-package.R View File

@@ -1,4 +1,4 @@
1
-#' Perform Secure-by-default 'DNS' Queries
1
+#' Perform Secure-by-Default 'DNS' Queries
2 2
 #'
3 3
 #' Methods are provided to query 'Domain Name System' ('DNS') stub
4 4
 #' and recursive resolvers for all 'DNS' resource record types using 'UDP',
@@ -14,6 +14,8 @@
14 14
 #' @docType package
15 15
 #' @author Bob Rudis (bob@@rud.is)
16 16
 #' @keywords internal
17
+#' @import httr R6
18
+#' @importFrom glue glue_data
17 19
 #' @importFrom jsonlite fromJSON
18 20
 #' @useDynLib clandnstine, .registration = TRUE
19 21
 #' @importFrom Rcpp sourceCpp

+ 98
- 0
R/doh-query.R View File

@@ -0,0 +1,98 @@
1
+#' Make a DoH Request (POST/wireformat)
2
+#'
3
+#' Issue a `POST` wireformat query of type `type` for `name` to
4
+#' the DoH endpoint specified at `server_path`.
5
+#'
6
+#' @param name name to query for
7
+#' @param type DNS query type (defaults to "`A`")
8
+#' @param server_path full URL path to the DoH server quer endpoint (defaults to Quad9).
9
+#' @return `NULL` (if the query failed) or a `data.frame` (tibble)
10
+#' @references <https://tools.ietf.org/id/draft-ietf-doh-dns-over-https-05.html>
11
+#' @export
12
+#' @examples
13
+#' doh_post("rud.is", "A")
14
+doh_post <- function(name, type = "A", server_path = "https://dns.quad9.net/dns-query") {
15
+
16
+  DNSRecord$new()$question(
17
+    qname = tolower(name[1]),
18
+    qtype = toupper(type[1]),
19
+    qclass = "IN"
20
+  ) -> q
21
+
22
+  # now, send it off to the server
23
+
24
+  httr::POST(
25
+    url = server_path[1],
26
+    httr::add_headers(
27
+      `Content-Type` = "application/dns-message",
28
+      `Accept` = "application/dns-message"
29
+    ),
30
+    .CLANDNSTINE_UA,
31
+    encode = "raw",
32
+    body = q$pack()
33
+  ) -> res
34
+
35
+  httr::stop_for_status(res)
36
+
37
+  res <- int_dns_wire_to_list(httr::content(res, as = "raw"))
38
+
39
+  if (length(res)) {
40
+    out <- jsonlite::fromJSON(res)
41
+    class(out) <- c("gdns_doh_response", "list")
42
+    out
43
+  } else {
44
+    NULL
45
+  }
46
+
47
+}
48
+
49
+#' Tidy generic
50
+#'
51
+#' @keywords internal
52
+#' @export
53
+#' @param x an object
54
+#' @param ... unused
55
+tidy <- function (x, ...) {
56
+  UseMethod("tidy")
57
+}
58
+
59
+#' Tidy a DoH POST response
60
+#'
61
+#' @param x a DoH POST response
62
+#' @param ... unused
63
+#' @export
64
+tidy.gdns_doh_response <- function(x, ...) {
65
+
66
+  rawdat <- x$answer[, c("rdata")]
67
+
68
+  nr <- colnames(rawdat)
69
+  if ("txt_strings" %in% nr) {
70
+    vapply(rawdat[["txt_strings"]], function(.x) {
71
+      .x
72
+    }, FUN.VALUE = character(1)) -> rawdat[["txt_strings"]]
73
+  }
74
+
75
+  lapply(rawdat[["rdata_raw"]], function(.x) {
76
+
77
+    if (x$question$qtype %in% c(2, 5, 12)) {
78
+      charToRaw(.x)
79
+    } else {
80
+      as.raw(.x)
81
+    }
82
+
83
+  }) -> rawdat[["rdata_raw"]]
84
+
85
+  cbind.data.frame(
86
+    x$answer[, c("name", "class", "type", "ttl")],
87
+    rawdat,
88
+    stringsAsFactors = FALSE
89
+  ) -> out
90
+
91
+  class(out) <- c("tbl_df", "tbl", "data.frame")
92
+
93
+  out
94
+
95
+}
96
+
97
+
98
+

+ 118
- 0
R/globals.R View File

@@ -0,0 +1,118 @@
1
+c(
2
+  'A' = 1L, 'NS' = 2L, 'CNAME' = 5L, 'SOA' = 6L, 'PTR' = 12L, 'HINFO' = 13L,
3
+  'MX' = 15L, 'TXT' = 16L, 'RP' = 17L, 'AFSDB' = 18L, 'SIG' = 24L,
4
+  'KEY' = 25L, 'AAAA' = 28L, 'LOC' = 29, 'SRV' = 33L, 'NAPTR' = 35L,
5
+  'KX' = 36L, 'CERT' = 37L, 'A6' = 38L, 'DNAME' = 39L, 'OPT' = 41,
6
+  'APL' = 42L, 'DS' = 43L, 'SSHFP' = 44L, 'IPSECKEY' = 45L, 'RRSIG' = 46L,
7
+  'NSEC' = 47L, 'DNSKEY' = 48L, 'DHCID' = 49L, 'NSEC3' = 50L,
8
+  'NSEC3PARAM' = 51L, 'TLSA' = 52L, 'HIP' = 55L, 'CDS' = 59L,
9
+  'CDNSKEY' = 60L, 'OPENPGPKEY' = 61L, 'SPF' = 99L, 'TKEY' = 249L,
10
+  'TSIG' = 250L, 'IXFR' = 251L, 'AXFR' = 252L, 'ANY' = 255L,
11
+  'URI' = 256L, 'CAA' = 257L, 'TA' = 32768L, 'DLV' = 32769L
12
+) -> .qtype
13
+
14
+c(
15
+  'IN' = 1L,
16
+  'CS' = 2L,
17
+  'CH' = 3L,
18
+  'Hesiod' = 4L,
19
+  'None' = 254L,
20
+  '*' = 255L
21
+) -> .class
22
+
23
+.qr <- c('QUERY' = 0, 'RESPONSE' = 1)
24
+
25
+c(
26
+  'NOERROR' = 0L,
27
+  'FORMERR' = 1L,
28
+  'SERVFAIL' = 2L,
29
+  'NXDOMAIN' = 3L,
30
+  'NOTIMP' = 4L,
31
+  'REFUSED' = 5L,
32
+  'YXDOMAIN' = 6L,
33
+  'YXRRSET' = 7L,
34
+  'NXRRSET' = 8L,
35
+  'NOTAUTH' = 9L,
36
+  'NOTZONE' = 10L
37
+) -> .rcode
38
+
39
+c(
40
+  'QUERY' = 0L,
41
+  'IQUERY' = 1L,
42
+  'STATUS' = 2L,
43
+  'UPDATE' = 5L
44
+) -> .opcode
45
+
46
+#' Built-in list of DoH Servers
47
+#'
48
+#' The `url` element has the URL for `GET`/`POST` requests and
49
+#' the `extra_params` element has any needed query parameters
50
+#' for `GET` requests.
51
+#'
52
+#' The list so far.
53
+#' - `google`: <https://dns.google.com/experimental>
54
+#' - `cloudflare`: <https://cloudflare-dns.com/dns-query>
55
+#' - `quad9`: <https://dns.quad9.net/dns-query>
56
+#' - `securedns_eu`: <https://doh.securedns.eu/dns-query>
57
+#' - `dnswarden_adblock`: <https://doh.dnswarden.com/adblock>
58
+#' - `dnswarden_uncensored`: <https://doh.dnswarden.com/uncensored>
59
+#' - `cleanbrowsing_security`: <https://doh.cleanbrowsing.org/doh/security-filter/>
60
+#' - `cleanbrowsing_family`: <https://doh.cleanbrowsing.org/doh/family-filter/>
61
+#' - `cleanbrowsing_adult`: <https://doh.cleanbrowsing.org/doh/adult-filter/>
62
+#' - `power_dns`: <https://doh.powerdns.org>
63
+#' - `appliedprivacy`: <https://doh.appliedprivacy.net/query>
64
+#'
65
+#' @docType data
66
+#' @export
67
+list(
68
+  google = list(
69
+    url = "https://dns.google.com/experimental",
70
+    extra_params = list()
71
+  ),
72
+  cloudflare = list(
73
+    url = "https://cloudflare-dns.com/dns-query",
74
+    extra_params = list(
75
+      cd = "false",
76
+      do = "true",
77
+      ct = "application/dns-json"
78
+    )
79
+  ),
80
+  quad9 = list(
81
+    url = "https://dns.quad9.net/dns-query",
82
+    extra_params = list()
83
+  ),
84
+  securedns_eu = list(
85
+    url = "https://doh.securedns.eu/dns-query",
86
+    extra_params = list(
87
+      edns_client_subnet = NULL
88
+    )
89
+  ),
90
+  dnswarden_adblock = list(
91
+    url = "https://doh.dnswarden.com/adblock",
92
+    extra_params = list()
93
+  ),
94
+  dnswarden_uncensored = list(
95
+    url = "https://doh.dnswarden.com/uncensored",
96
+    extra_params = list()
97
+  ),
98
+  cleanbrowsing_security = list(
99
+    url = "https://doh.cleanbrowsing.org/doh/security-filter/",
100
+    extra_params = list(cd = "false")
101
+  ),
102
+  cleanbrowsing_family = list(
103
+    url = "https://doh.cleanbrowsing.org/doh/family-filter/",
104
+    extra_params = list()
105
+  ),
106
+  cleanbrowsing_adult = list(
107
+    url = "https://doh.cleanbrowsing.org/doh/adult-filter/",
108
+    extra_params = list()
109
+  ),
110
+  power_dns = list(
111
+    url = "https://doh.powerdns.org",
112
+    extra_params = list()
113
+  ),
114
+  appliedprivacy = list(
115
+    url = "https://doh.appliedprivacy.net/query",
116
+    extra_params = list()
117
+  )
118
+) -> doh_servers

+ 7
- 0
R/is.R View File

@@ -0,0 +1,7 @@
1
+#' Test whether an object is a `gctx` context
2
+#'
3
+#' @param x object
4
+#' @export
5
+is_gctx <- function(x) {
6
+   inherits(x, "gctx")
7
+}

+ 46
- 19
R/resolver.R View File

@@ -6,6 +6,7 @@
6 6
 #' @param resolvers character vector of valid DNS over TLS resolvers;
7 7
 #'        Defaults to Quad9 (`9.9.9.9`).
8 8
 #' @export
9
+#' @family query functions
9 10
 #' @examples
10 11
 #' x <- gdns_context()
11 12
 #' x <- gdns_context("1.1.1.1")
@@ -19,10 +20,11 @@ gdns_context <- function(resolvers = "9.9.9.9") {
19 20
 #'       maintains a list of DNS over TLS servers.
20 21
 #' @param gctx gdns resolver context created with [gdns_resolver()]
21 22
 #' @param resolvers character vector of valid DNS over TLS resolvers
23
+#' @family context functions
22 24
 #' @export
23 25
 #' @examples
24 26
 #' x <- gdns_context()
25
-#' x <- gdns_update_resolvers("1.1.1.1")
27
+#' x <- gdns_update_resolvers(x, "1.1.1.1")
26 28
 gdns_update_resolvers<- function(gctx, resolvers) {
27 29
   int_gdns_update_resolvers(gctx, resolvers)
28 30
 }
@@ -33,15 +35,27 @@ gdns_update_resolvers<- function(gctx, resolvers) {
33 35
 #' @param hosts_file path to a valid `hosts` file (e.g. "`/etc/hosts`). This value
34 36
 #'        will be [path.expand()]ed.
35 37
 #' @export
38
+#' @family context functions
36 39
 #' @examples
37 40
 #' x <- gdns_context()
38
-#' x <- gdns_set_hosts(x, "/etc/hosts")
41
+#' gdns_set_hosts(x, "/etc/hosts")
39 42
 gdns_set_hosts<- function(gctx, hosts_file) {
40 43
   hosts_file <- path.expand(hosts_file[1])
41 44
   stopifnot(file.exists(hosts_file))
42 45
   int_gdns_set_hosts(gctx, hosts_file)
43 46
 }
44 47
 
48
+#' Retrieve the list of addresses in use for looking up top-level domains in use by the context.
49
+#'
50
+#' @param gctx gdns resolver context created with [gdns_resolver()]
51
+#' @export
52
+#' @family context functions
53
+# x <- gdns_context()
54
+# gdns_get_root_servers(x)
55
+gdns_get_root_servers <- function(gctx) {
56
+  x <- int_gdns_get_root_servers(gctx);
57
+  if (length(x)) jsonlite::fromJSON(x) else NULL
58
+}
45 59
 
46 60
 #' Arbitrary DNS queries
47 61
 #'
@@ -142,19 +156,26 @@ gdns_set_hosts<- function(gctx, hosts_file) {
142 156
 #' - `zonemd`
143 157
 #'
144 158
 #' @note Local hosts files are ignored when using this `getdns` API endpoint
145
-#' @param gctx gdns resolver context created with [gdns_resolver()]
159
+#' @param gctx gdns resolver context created with [gdns_resolver()]. If `NULL` a
160
+#'        temporary context will be created but is not ideal since there is overhead
161
+#'        associated with context creation and garbage collection.
146 162
 #' @param name an entity to query for
147 163
 #' @param rr_type what resource record type do you want to queyr for? See `Details`.
148 164
 #' @param include_reporting if `TRUE` include debugging information for queries
149 165
 #'        such as the length of time it takes for each query. Default: `FALSE`
150 166
 #' @references <https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml>
167
+#' @family query functions
151 168
 #' @export
152 169
 #' @examples
153 170
 #' x <- gdns_resolver()
154 171
 #' gdns_query(x, "example.com")
155
-gdns_query <- function(gctx, name, rr_type = "txt", rr_class = 1L,
172
+gdns_query <- function(gctx = NULL, name, rr_type = "txt", rr_class = 1L,
156 173
                        include_reporting = FALSE) {
157 174
 
175
+  if (is.null(gctx)) gctx <- gdns_context()
176
+
177
+  stopifnot(is_gctx(gctx))
178
+
158 179
   rr_class <- rr_class[1]
159 180
   if (!rr_class %in% c(1, 3, 4, 254, 255)) rr_class <- 1
160 181
 
@@ -171,21 +192,6 @@ gdns_query <- function(gctx, name, rr_type = "txt", rr_class = 1L,
171 192
 
172 193
 }
173 194
 
174
-list(
175
-  `1` = "ipv4_address",
176
-  `2` = "nsdname",
177
-  `6` = c("expire", "minimum", "mname", "refresh", "retry", "rname", "serial"),
178
-  `16` = "txt_strings",
179
-  `28` = "ipv6_address",
180
-  `43` = c("algorithm", "digest", "digest_type", "key_tag"),
181
-  `46` = c(
182
-    "algorithm", "key_tag", "labels", "original_ttl", "signature",
183
-    "signature_expiration", "signature_inception", "signers_name", "type_covered"
184
-  ),
185
-  `47` = c("next_domain_name", "type_bit_maps"),
186
-  `48` = c("algorithm", "flags", "protocol", "public_key")
187
-) -> rr_fields
188
-
189 195
 #' Printer for gdns_response objects
190 196
 #'
191 197
 #' @param x a `gdns_response` object
@@ -214,6 +220,20 @@ print.gdns_response <- function(x, ...) {
214 220
         "\n", sep=""
215 221
       )
216 222
     },
223
+    "2" ={
224
+      cat(
225
+        "Answer: ",
226
+        paste0(ans$rdata$nsdname, collapse=", "),
227
+        "\n", sep=""
228
+      )
229
+    },
230
+    "15" = {
231
+      cat(
232
+        "Answer: \n",
233
+        paste0(glue::glue_data(ans$rdata, "{preference} {exchange}"), collapse="\n"),
234
+        "\n", sep=""
235
+      )
236
+    },
217 237
     "16" = {
218 238
       rd <- ans$rdata
219 239
       typs <- ans$type
@@ -233,6 +253,13 @@ print.gdns_response <- function(x, ...) {
233 253
         "\n", sep=""
234 254
       )
235 255
     },
256
+    "257" = {
257
+      cat(
258
+        "Answer: \n",
259
+        paste0(glue::glue_data(ans$rdata, "{flags} {tag} {value}"), collapse="\n"),
260
+        "\n", sep=""
261
+      )
262
+    },
236 263
     {
237 264
       print(str(ans$rdata, give.attr = FALSE))
238 265
     }

+ 1
- 0
R/set-res-types.R View File

@@ -4,6 +4,7 @@
4 4
 #'
5 5
 #' @param gctx gdns resolver context created with [gdns_resolver()]
6 6
 #' @param res_type length 1 character vector of either "`stub`" or "`recursive`"
7
+#' @family context functions
7 8
 #' @export
8 9
 #' @examples
9 10
 #' x <- gdns_context()

+ 24
- 0
R/to-inaddr-arpa.R View File

@@ -0,0 +1,24 @@
1
+ipv4_regex <-
2
+  "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
3
+
4
+#' Convert a vector of IPv4 addresses to in-addr.arpa format
5
+#'
6
+#' @md
7
+#' @param ipv4 vector of ipv4 addresses
8
+#' @export
9
+to_inaddr_arpa <- function(ipv4) {
10
+
11
+  ifelse(
12
+    test = grepl(ipv4_regex, ipv4),
13
+    yes =  paste0(
14
+      c(
15
+        rev(unlist(strsplit(ipv4, ".", 4), use.names = FALSE)),
16
+        "in-addr.arpa."
17
+      ),
18
+      sep = "",
19
+      collapse = "."
20
+    ),
21
+    no = ipv4
22
+  )
23
+
24
+}

+ 4
- 0
R/utils-infix-helpers.R View File

@@ -0,0 +1,4 @@
1
+`%l0%` <- function(x, y) if (length(x) == 0) y else x
2
+`%||%` <- function(x, y) if (is.null(x)) y else x
3
+`%@%` <- function(x, name) attr(x, name, exact = TRUE)
4
+`%nin%` <- function(x, table)  match(x, table, nomatch = 0) == 0

+ 9
- 0
R/utils.R View File

@@ -0,0 +1,9 @@
1
+"bits" <- function(object, bit) {
2
+  (object %/% (2^bit)) %% 2
3
+}
4
+
5
+"bits<-" <- function(object, bit, value) {
6
+  mask <- 2^bit
7
+  object <- object+(value - ((object %/% mask) %% 2))*mask
8
+  object
9
+}

+ 62
- 16
README.Rmd View File

@@ -18,7 +18,7 @@ Perform Secure-by-default 'DNS' Queries
18 18
 
19 19
 ## Description
20 20
 
21
-Methods are provided to query 'Domain Name System' ('DNS') stub and recursive resolvers for all 'DNS' resource record types using 'UDP',  'TCP', and/or 'TLS' transport layers. 'DNS' query support is provided by the 'getdns' (<getdnsapi.net>) C library.
21
+Perform and process 'DNS over TLS' and 'DNS over HTTPS' queries.
22 22
 
23 23
 ## NOTE
24 24
 
@@ -35,15 +35,15 @@ I've gotten this running on macOS and Ubuntu 16.04. For the latter I had to ensu
35 35
 
36 36
 ## TODO/WAT
37 37
 
38
-I finally grok the getdns api so the package api is going to change wildly and fast. The default mode will be to perform queries using DNS over TLS but support is also provided for UDP and TCP transports and either stub or recursive resolvers.
38
+I finally grok the getdns api so the package api is going to change wildly and fast. The default mode will be to perform queries using DNS over TLS but also supports UDP and TCP transports along with support for DNS over HTTPS.
39 39
 
40 40
 ## Why?
41 41
 
42
-Well, for starters, to help research DNS over TLS servers. Plus, for fun!
42
+Well, for starters, to help research DNS over TLS/DNS over HTTPS servers. Plus, for fun!
43 43
 
44
-If you're asking "Why DNS over TLS at all?" then "faux" privacy. Why "faux"? Well, _something_ is handing your query and that something knows your IP address and what you looked for. So, you're relying on the good faith, honest nature and technical capability of the destination server to not mess with you. I don't trust Cloudflare or Google and am witholding judgement on Quad9 either way (they've been doing good things and are less "look at how cool we are" than CF is).
44
+If you're asking "Why DNS over TLS/HTTPS at all?" then "faux" privacy. Why "faux"? Well, _something_ is handing your query and that something knows your IP address and what you looked for. So, you're relying on the good faith, honest nature and technical capability of the destination server to not mess with you. I don't trust Cloudflare or Google and am witholding judgement on Quad9 either way (they've been doing good things and are less "look at how cool we are" than CF is).
45 45
 
46
-Also "faux" in that you're going to be using a standard port (853) and a TLS session for the queries so your internet provider will know you're doing _something_ and the current, sorry state of SSL certificates, certificate authorities, and authoritarian companies and regimes combined means confidentiality and integrity are always kinda in question unless done super-well.
46
+Also "faux" in that you're going to be using (for DoT) a standard port (853) and a TLS session for the queries so your internet provider will know you're doing _something_ and the current, sorry state of SSL certificates, certificate authorities, and authoritarian companies and regimes combined means confidentiality and integrity are always kinda in question unless done super-well.
47 47
 
48 48
 ## What's Different About This vs Regular DNS?
49 49
 
@@ -85,28 +85,42 @@ It's stupid slow, consumes more CPU and bandwidth but forces adversaries to work
85 85
 
86 86
 The following functions are implemented:
87 87
 
88
+### Utility
89
+
90
+- `to_inaddr_arpa`: Convert a vector of IPv4 addresses to in-addr.arpa format
91
+
92
+### DNS over HTTPS
93
+
94
+- `doh_post`:   Make a DoH Request (POST/wireformat)
95
+- `doh_servers`:    Built-in list of DoH servers.
96
+- `tidy.gdns_doh_response`: Tidy a DoH POST response
97
+
98
+### DNS over TLS
99
+
100
+- `gdns_query`:  Arbitrary DNS queries
88 101
 - `gdns_context`:  Create a gdns DNS over TLS context and populate it with a resolver for use in resolution functions
89 102
 - `gdns_get_address`:  Resolve a host to an addrss
90
-- `gdns_get_resolution_type`:	Get the current resolution type setting
103
+- `gdns_get_resolution_type`:   Get the current resolution type setting
91 104
 - `gdns_get_timeout`:  Retreive the number of milliseconds to wait for request to return
92
-- `gdns_get_tls_ca_file`:	Retreive the file location with CA certificates for verification purposes
93
-- `gdns_get_tls_ca_path`:	Retreive the value with which the context's upstream recursive servers and suffixes were initialized
94
-- `gdns_get_transports`:	Retreive what transports are used for DNS lookups.
105
+- `gdns_get_tls_ca_file`:   Retreive the file location with CA certificates for verification purposes
106
+- `gdns_get_tls_ca_path`:   Retreive the value with which the context's upstream recursive servers and suffixes were initialized
107
+- `gdns_get_transports`:    Retreive what transports are used for DNS lookups.
95 108
 - `gdns_lib_version`:  Return gdns library version
96
-- `gdns_query`:  Arbitrary DNS queries
97 109
 - `gdns_set_hosts`:  Initialized the context's local names namespace with values from the given hosts file.
98
-- `gdns_set_resolution_type`:	Specify whether DNS queries are performed with recursive lookups or as a stub resolver
110
+- `gdns_set_resolution_type`:   Specify whether DNS queries are performed with recursive lookups or as a stub resolver
99 111
 - `gdns_set_round_robin_upstreams`:  Set/unset context to round robin queries over the available upstreams when resolving with the stub resolution type.
100 112
 - `gdns_set_timeout`:  Specify the number of milliseconds to wait for request to return
101
-- `gdns_set_tls_ca_file`:	Specify the file with CA certificates for verification purposes
102
-- `gdns_set_tls_ca_path`:	Specify where the location for CA certificates for verification purposes are located
103
-- `gdns_set_transports`:	Specifies what transport(s) is/ar used for DNS lookups
113
+- `gdns_set_tls_ca_file`:   Specify the file with CA certificates for verification purposes
114
+- `gdns_set_tls_ca_path`:   Specify where the location for CA certificates for verification purposes are located
115
+- `gdns_set_transports`:    Specifies what transport(s) is/ar used for DNS lookups
104 116
 - `gdns_update_resolvers`: Changes the list of resolvers in an already created context for use in resolution functions
105 117
 
106 118
 ## Installation
107 119
 
108 120
 ```{r install-ex, eval=FALSE}
109
-devtools::install_git("https://gitlab.com/hrbrmstr/clandnstine.git")
121
+devtools::install_git("https://git.sr.ht/~hrbrmstr/clandnstine")
122
+# or 
123
+devtools::install_gitlab("hrbrmstr/clandnstine.git")
110 124
 # or
111 125
 devtools::install_github("hrbrmstr/clandnstine")
112 126
 ```
@@ -155,6 +169,38 @@ sort(unlist(leno$replies_tree$answer[[1]]$rdata$txt_strings))
155 169
 
156 170
 Yep. Advertising even in DNS `TXT` records (see item number 8).
157 171
 
172
+### DOH
173
+
174
+```{r doh}
175
+str(doh_post("rud.is")$answer)
176
+```
177
+
178
+```{r doh2}
179
+a <- doh_post("apple.com", "A")
180
+tidy(a)
181
+
182
+aaaa <- doh_post("rud.is", "AAAA")
183
+tidy(aaaa)
184
+
185
+mx <- doh_post("rud.is", "MX")
186
+tidy(mx)
187
+
188
+txt <- doh_post("lenovo.com", "TXT")
189
+tidy(txt)
190
+
191
+cname <- doh_post("dataassurance.pwc.com", "CNAME")
192
+tidy(cname)
193
+
194
+ns <- doh_post("rud.is", "NS")
195
+tidy(ns)
196
+
197
+soa <- doh_post("rud.is", "SOA")
198
+tidy(soa)
199
+
200
+ptr <- doh_post(to_inaddr_arpa("104.244.13.104"), "PTR")
201
+tidy(ptr)
202
+```
203
+
158 204
 ## clandnstine Metrics
159 205
 
160 206
 ```{r cloc, echo=FALSE}
@@ -164,4 +210,4 @@ cloc::cloc_pkg_md()
164 210
 ## Code of Conduct
165 211
 
166 212
 Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). 
167
-By participating in this project you agree to abide by its terms.
213
+By participating in this project you agree to abide by its terms.

+ 159
- 40
README.md View File

@@ -11,10 +11,7 @@ Perform Secure-by-default ‘DNS’ Queries
11 11
 
12 12
 ## Description
13 13
 
14
-Methods are provided to query ‘Domain Name System’ (‘DNS’) stub and
15
-recursive resolvers for all ‘DNS’ resource record types using ‘UDP’,
16
-‘TCP’, and/or ‘TLS’ transport layers. ‘DNS’ query support is provided
17
-by the ‘getdns’ (\<getdnsapi.net\>) C library.
14
+Perform and process ‘DNS over TLS’ and ‘DNS over HTTPS’ queries.
18 15
 
19 16
 ## NOTE
20 17
 
@@ -39,34 +36,33 @@ extract it and `config`/`make`/`make install` (plus `ldconfig` after).
39 36
 
40 37
 I finally grok the getdns api so the package api is going to change
41 38
 wildly and fast. The default mode will be to perform queries using DNS
42
-over TLS but support is also provided for UDP and TCP transports and
43
-either stub or recursive resolvers.
39
+over TLS but also supports UDP and TCP transports along with support for
40
+DNS over HTTPS.
44 41
 
45 42
 ## Why?
46 43
 
47
-Well, for starters, to help research DNS over TLS servers. Plus, for
48
-fun\!
44
+Well, for starters, to help research DNS over TLS/DNS over HTTPS
45
+servers. Plus, for fun\!
49 46
 
50
-If you’re asking “Why DNS over TLS at all?” then “faux” privacy. Why
51
-“faux”? Well, *something* is handing your query and that something
47
+If you’re asking “Why DNS over TLS/HTTPS at all?” then “faux” privacy.
48
+Why “faux”? Well, *something* is handing your query and that something
52 49
 knows your IP address and what you looked for. So, you’re relying on the
53 50
 good faith, honest nature and technical capability of the destination
54 51
 server to not mess with you. I don’t trust Cloudflare or Google and am
55 52
 witholding judgement on Quad9 either way (they’ve been doing good things
56 53
 and are less “look at how cool we are” than CF is).
57 54
 
58
-Also “faux” in that you’re going to be using a standard port (853) and a
59
-TLS session for the queries so your internet provider will know you’re
60
-doing *something* and the current, sorry state of SSL certificates,
61
-certificate authorities, and authoritarian companies and regimes
62
-combined means confidentiality and integrity are always kinda in
55
+Also “faux” in that you’re going to be using (for DoT) a standard port
56
+(853) and a TLS session for the queries so your internet provider will
57
+know you’re doing *something* and the current, sorry state of SSL
58
+certificates, certificate authorities, and authoritarian companies and
59
+regimes combined means confidentiality and integrity are always kinda in
63 60
 question unless done super-well.
64 61
 
65 62
 ## What’s Different About This vs Regular DNS?
66 63
 
67 64
 Well, if we lookup the addresses for `yahoo.com` the old-fashioned way
68
-it’s cleartext UDP on the
69
-    wire:
65
+it’s cleartext UDP on the wire:
70 66
 
71 67
     1   0.000000   10.1.10.57 → 10.1.10.200  DNS 80 Standard query 0x8af8 A yahoo.com OPT
72 68
     2   0.003297  10.1.10.200 → 10.1.10.57   DNS 176 Standard query response 0x8af8 A yahoo.com A 72.30.35.10 A 98.138.219.231 A 72.30.35.9 A 98.137.246.7 A 98.138.219.232 A 98.137.246.8 OPT
@@ -79,8 +75,7 @@ server forwards all queries to a custom DNS over TLS server since I
79 75
 really don’t trust any of the providers when it comes down to it. So, in
80 76
 reality for me, it’s even slower than the below — at least initially).
81 77
 
82
-This is the same query via DNS over
83
-TLS
78
+This is the same query via DNS over TLS
84 79
 
85 80
 ``` 
86 81
  1   0.000000   10.1.10.57 → 9.9.9.9      TCP 78 52128 → 853 [SYN] Seq=0 Win=65535 Len=0 MSS=1460 WS=64 TSval=602885491 TSecr=0 SACK_PERM=1 TFO=R
@@ -114,6 +109,20 @@ to work pretty hard to try to figure out what you’re looking for.
114 109
 
115 110
 The following functions are implemented:
116 111
 
112
+### Utility
113
+
114
+  - `to_inaddr_arpa`: Convert a vector of IPv4 addresses to in-addr.arpa
115
+    format
116
+
117
+### DNS over HTTPS
118
+
119
+  - `doh_post`: Make a DoH Request (POST/wireformat)
120
+  - `doh_servers`: Built-in list of DoH servers.
121
+  - `tidy.gdns_doh_response`: Tidy a DoH POST response
122
+
123
+### DNS over TLS
124
+
125
+  - `gdns_query`: Arbitrary DNS queries
117 126
   - `gdns_context`: Create a gdns DNS over TLS context and populate it
118 127
     with a resolver for use in resolution functions
119 128
   - `gdns_get_address`: Resolve a host to an addrss
@@ -127,7 +136,6 @@ The following functions are implemented:
127 136
   - `gdns_get_transports`: Retreive what transports are used for DNS
128 137
     lookups.
129 138
   - `gdns_lib_version`: Return gdns library version
130
-  - `gdns_query`: Arbitrary DNS queries
131 139
   - `gdns_set_hosts`: Initialized the context’s local names namespace
132 140
     with values from the given hosts file.
133 141
   - `gdns_set_resolution_type`: Specify whether DNS queries are
@@ -149,7 +157,9 @@ The following functions are implemented:
149 157
 ## Installation
150 158
 
151 159
 ``` r
152
-devtools::install_git("https://gitlab.com/hrbrmstr/clandnstine.git")
160
+devtools::install_git("https://git.sr.ht/~hrbrmstr/clandnstine")
161
+# or 
162
+devtools::install_gitlab("hrbrmstr/clandnstine.git")
153 163
 # or
154 164
 devtools::install_github("hrbrmstr/clandnstine")
155 165
 ```
@@ -161,7 +171,7 @@ library(clandnstine)
161 171
 
162 172
 # current version
163 173
 packageVersion("clandnstine")
164
-## [1] '0.1.0'
174
+## [1] '0.2.0'
165 175
 ```
166 176
 
167 177
 ### Get an address(es) from a name:
@@ -189,12 +199,12 @@ gdns_lib_version()
189 199
 ## <gdns v1.5.1 resolver context; resolvers: [1.1.1.1]; timeout: 2,000 ms; lookup transport(s): [udp, tls, tcp]; resolution type: stub>
190 200
 
191 201
 (gdns_get_address(x, "rud.is"))
192
-## [1] "2604:a880:800:10::6bc:2001" "104.236.112.222"
202
+## [1] "2602:ff16:3::4dfb:9ac5" "172.93.49.183"
193 203
 
194 204
 (gdns_get_address(x, "yahoo.com"))
195 205
 ##  [1] "2001:4998:44:41d::4"   "2001:4998:58:1836::10" "2001:4998:58:1836::11" "2001:4998:c:1023::4"  
196
-##  [5] "2001:4998:c:1023::5"   "2001:4998:44:41d::3"   "98.137.246.8"          "98.138.219.231"       
197
-##  [9] "98.138.219.232"        "72.30.35.9"            "72.30.35.10"           "98.137.246.7"
206
+##  [5] "2001:4998:c:1023::5"   "2001:4998:44:41d::3"   "98.138.219.231"        "98.138.219.232"       
207
+##  [9] "72.30.35.9"            "72.30.35.10"           "98.137.246.7"          "98.137.246.8"
198 208
 
199 209
 (gdns_get_address(x, "yahoo.commmm"))
200 210
 ## character(0)
@@ -207,35 +217,144 @@ str(leno <- gdns_query(x, "lenovo.com", "txt"), 1)
207 217
 ## List of 5
208 218
 ##  $ answer_type   : int 800
209 219
 ##  $ canonical_name: chr "lenovo.com."
210
-##  $ replies_full  : int [1, 1:600] 192 224 129 128 0 1 0 8 0 0 ...
220
+##  $ replies_full  : int [1, 1:762] 81 128 129 128 0 1 0 10 0 0 ...
211 221
 ##  $ replies_tree  :'data.frame':  1 obs. of  7 variables:
212 222
 ##  $ status        : int 900
213 223
 ##  - attr(*, "class")= chr [1:2] "gdns_response" "list"
214 224
 
215 225
 sort(unlist(leno$replies_tree$answer[[1]]$rdata$txt_strings))
216
-## [1] "a82c74b37aa84e7c8580f0e32f4d795d"                                                        
217
-## [2] "ece42d7743c84d6889abda7011fe6f53"                                                        
218
-## [3] "facebook-domain-verification=1r2am7c2bhzrxpqyt0mda0djoquqsi"                             
219
-## [4] "google-site-verification=VxW_e6r_Ka7A518qfX2MmIMHGnkpGbnACsjSxKFCBw0"                    
220
-## [5] "iHzQJvsKnyGP2Nm2qBgL3fyBJ0CC9z4GkY/flfk4EzLP8lPxWHDDPKqZWm1TkeF5kEIL+NotYOF1wo7JtUDXXw=="
221
-## [6] "qh7hdmqm4lzs85p704d6wsybgrpsly0j"                                                        
222
-## [7] "v=spf1 include:spf.messagelabs.com include:_netblocks.eloqua.com ~all"                   
223
-## [8] "Visit www.lenovo.com/think for information about Lenovo products and services"
226
+##  [1] "a82c74b37aa84e7c8580f0e32f4d795d"                                                        
227
+##  [2] "ece42d7743c84d6889abda7011fe6f53"                                                        
228
+##  [3] "facebook-domain-verification=1r2am7c2bhzrxpqyt0mda0djoquqsi"                             
229
+##  [4] "google-site-verification=nGgukcp60rC-gFxMOJw1NHH0B4VnSchRrlfWV-He_tE"                    
230
+##  [5] "google-site-verification=sHIlSlj0U6UnCDkfHp1AolWgVEvDjWvc0TR4KaysD2c"                    
231
+##  [6] "google-site-verification=VxW_e6r_Ka7A518qfX2MmIMHGnkpGbnACsjSxKFCBw0"                    
232
+##  [7] "iHzQJvsKnyGP2Nm2qBgL3fyBJ0CC9z4GkY/flfk4EzLP8lPxWHDDPKqZWm1TkeF5kEIL+NotYOF1wo7JtUDXXw=="
233
+##  [8] "qh7hdmqm4lzs85p704d6wsybgrpsly0j"                                                        
234
+##  [9] "v=spf1 include:spf.messagelabs.com include:_netblocks.eloqua.com ~all"                   
235
+## [10] "Visit www.lenovo.com/think for information about Lenovo products and services"
224 236
 ```
225 237
 
226
-Yep. Advertising even in DNS `TXT` records (see item number
227
-8).
238
+Yep. Advertising even in DNS `TXT` records (see item number 8).
239
+
240
+### DOH
241
+
242
+``` r
243
+str(doh_post("rud.is")$answer)
244
+## 'data.frame':    1 obs. of  5 variables:
245
+##  $ class: int 1
246
+##  $ name : chr "rud.is."
247
+##  $ rdata:'data.frame':   1 obs. of  2 variables:
248
+##   ..$ ipv4_address: chr "172.93.49.183"
249
+##   ..$ rdata_raw   :List of 1
250
+##   .. ..$ : int  172 93 49 183
251
+##  $ ttl  : int 685
252
+##  $ type : int 1
253
+```
254
+
255
+``` r
256
+a <- doh_post("apple.com", "A")
257
+tidy(a)
258
+##         name class type ttl  ipv4_address      rdata_raw
259
+## 1 apple.com.     1    1 738 17.142.160.59 11, 8e, a0, 3b
260
+## 2 apple.com.     1    1 738  17.178.96.59 11, b2, 60, 3b
261
+## 3 apple.com.     1    1 738 17.172.224.47 11, ac, e0, 2f
262
+
263
+aaaa <- doh_post("rud.is", "AAAA")
264
+tidy(aaaa)
265
+##      name class type   ttl           ipv6_address                                                      rdata_raw
266
+## 1 rud.is.     1   28 43200 2602:ff16:3::4dfb:9ac5 26, 02, ff, 16, 00, 03, 00, 00, 00, 00, 00, 00, 4d, fb, 9a, c5
267
+
268
+mx <- doh_post("rud.is", "MX")
269
+tidy(mx)
270
+##      name class type   ttl                 exchange preference
271
+## 1 rud.is.     1   15 43200 alt2.aspmx.l.google.com.         30
272
+## 2 rud.is.     1   15 43200      aspmx.l.google.com.         10
273
+## 3 rud.is.     1   15 43200   aspmx2.googlemail.com.         40
274
+## 4 rud.is.     1   15 43200 alt1.aspmx.l.google.com.         20
275
+##                                                                                                    rdata_raw
276
+## 1 00, 1e, 04, 61, 6c, 74, 32, 05, 61, 73, 70, 6d, 78, 01, 6c, 06, 67, 6f, 6f, 67, 6c, 65, 03, 63, 6f, 6d, 00
277
+## 2                     00, 0a, 05, 61, 73, 70, 6d, 78, 01, 6c, 06, 67, 6f, 6f, 67, 6c, 65, 03, 63, 6f, 6d, 00
278
+## 3         00, 28, 06, 61, 73, 70, 6d, 78, 32, 0a, 67, 6f, 6f, 67, 6c, 65, 6d, 61, 69, 6c, 03, 63, 6f, 6d, 00
279
+## 4 00, 14, 04, 61, 6c, 74, 31, 05, 61, 73, 70, 6d, 78, 01, 6c, 06, 67, 6f, 6f, 67, 6c, 65, 03, 63, 6f, 6d, 00
280
+
281
+txt <- doh_post("lenovo.com", "TXT")
282
+tidy(txt)
283
+##           name class type  ttl
284
+## 1  lenovo.com.     1   16 4990
285
+## 2  lenovo.com.     1   16 4990
286
+## 3  lenovo.com.     1   16 4990
287
+## 4  lenovo.com.     1   16 4990
288
+## 5  lenovo.com.     1   16 4990
289
+## 6  lenovo.com.     1   16 4990
290
+## 7  lenovo.com.     1   16 4990
291
+## 8  lenovo.com.     1   16 4990
292
+## 9  lenovo.com.     1   16 4990
293
+## 10 lenovo.com.     1   16 4990
294
+##                                                                                                                                                                                                                                                                                                                                                             rdata_raw
295
+## 1                                                                                  44, 67, 6f, 6f, 67, 6c, 65, 2d, 73, 69, 74, 65, 2d, 76, 65, 72, 69, 66, 69, 63, 61, 74, 69, 6f, 6e, 3d, 73, 48, 49, 6c, 53, 6c, 6a, 30, 55, 36, 55, 6e, 43, 44, 6b, 66, 48, 70, 31, 41, 6f, 6c, 57, 67, 56, 45, 76, 44, 6a, 57, 76, 63, 30, 54, 52, 34, 4b, 61, 79, 73, 44, 32, 63
296
+## 2                                                                                  44, 67, 6f, 6f, 67, 6c, 65, 2d, 73, 69, 74, 65, 2d, 76, 65, 72, 69, 66, 69, 63, 61, 74, 69, 6f, 6e, 3d, 56, 78, 57, 5f, 65, 36, 72, 5f, 4b, 61, 37, 41, 35, 31, 38, 71, 66, 58, 32, 4d, 6d, 49, 4d, 48, 47, 6e, 6b, 70, 47, 62, 6e, 41, 43, 73, 6a, 53, 78, 4b, 46, 43, 42, 77, 30
297
+## 3                                                                              45, 76, 3d, 73, 70, 66, 31, 20, 69, 6e, 63, 6c, 75, 64, 65, 3a, 73, 70, 66, 2e, 6d, 65, 73, 73, 61, 67, 65, 6c, 61, 62, 73, 2e, 63, 6f, 6d, 20, 69, 6e, 63, 6c, 75, 64, 65, 3a, 5f, 6e, 65, 74, 62, 6c, 6f, 63, 6b, 73, 2e, 65, 6c, 6f, 71, 75, 61, 2e, 63, 6f, 6d, 20, 7e, 61, 6c, 6c
298
+## 4  58, 69, 48, 7a, 51, 4a, 76, 73, 4b, 6e, 79, 47, 50, 32, 4e, 6d, 32, 71, 42, 67, 4c, 33, 66, 79, 42, 4a, 30, 43, 43, 39, 7a, 34, 47, 6b, 59, 2f, 66, 6c, 66, 6b, 34, 45, 7a, 4c, 50, 38, 6c, 50, 78, 57, 48, 44, 44, 50, 4b, 71, 5a, 57, 6d, 31, 54, 6b, 65, 46, 35, 6b, 45, 49, 4c, 2b, 4e, 6f, 74, 59, 4f, 46, 31, 77, 6f, 37, 4a, 74, 55, 44, 58, 58, 77, 3d, 3d
299
+## 5                                                                                                                                                                                                                                  20, 71, 68, 37, 68, 64, 6d, 71, 6d, 34, 6c, 7a, 73, 38, 35, 70, 37, 30, 34, 64, 36, 77, 73, 79, 62, 67, 72, 70, 73, 6c, 79, 30, 6a
300
+## 6                                                                                                                                                                                                                                  20, 65, 63, 65, 34, 32, 64, 37, 37, 34, 33, 63, 38, 34, 64, 36, 38, 38, 39, 61, 62, 64, 61, 37, 30, 31, 31, 66, 65, 36, 66, 35, 33
301
+## 7                                              4d, 56, 69, 73, 69, 74, 20, 77, 77, 77, 2e, 6c, 65, 6e, 6f, 76, 6f, 2e, 63, 6f, 6d, 2f, 74, 68, 69, 6e, 6b, 20, 66, 6f, 72, 20, 69, 6e, 66, 6f, 72, 6d, 61, 74, 69, 6f, 6e, 20, 61, 62, 6f, 75, 74, 20, 4c, 65, 6e, 6f, 76, 6f, 20, 70, 72, 6f, 64, 75, 63, 74, 73, 20, 61, 6e, 64, 20, 73, 65, 72, 76, 69, 63, 65, 73
302
+## 8                                                                                  44, 67, 6f, 6f, 67, 6c, 65, 2d, 73, 69, 74, 65, 2d, 76, 65, 72, 69, 66, 69, 63, 61, 74, 69, 6f, 6e, 3d, 6e, 47, 67, 75, 6b, 63, 70, 36, 30, 72, 43, 2d, 67, 46, 78, 4d, 4f, 4a, 77, 31, 4e, 48, 48, 30, 42, 34, 56, 6e, 53, 63, 68, 52, 72, 6c, 66, 57, 56, 2d, 48, 65, 5f, 74, 45
303
+## 9                                                                                                                      3b, 66, 61, 63, 65, 62, 6f, 6f, 6b, 2d, 64, 6f, 6d, 61, 69, 6e, 2d, 76, 65, 72, 69, 66, 69, 63, 61, 74, 69, 6f, 6e, 3d, 31, 72, 32, 61, 6d, 37, 63, 32, 62, 68, 7a, 72, 78, 70, 71, 79, 74, 30, 6d, 64, 61, 30, 64, 6a, 6f, 71, 75, 71, 73, 69
304
+## 10                                                                                                                                                                                                                                 20, 61, 38, 32, 63, 37, 34, 62, 33, 37, 61, 61, 38, 34, 65, 37, 63, 38, 35, 38, 30, 66, 30, 65, 33, 32, 66, 34, 64, 37, 39, 35, 64
305
+##                                                                                 txt_strings
306
+## 1                      google-site-verification=sHIlSlj0U6UnCDkfHp1AolWgVEvDjWvc0TR4KaysD2c
307
+## 2                      google-site-verification=VxW_e6r_Ka7A518qfX2MmIMHGnkpGbnACsjSxKFCBw0
308
+## 3                     v=spf1 include:spf.messagelabs.com include:_netblocks.eloqua.com ~all
309
+## 4  iHzQJvsKnyGP2Nm2qBgL3fyBJ0CC9z4GkY/flfk4EzLP8lPxWHDDPKqZWm1TkeF5kEIL+NotYOF1wo7JtUDXXw==
310
+## 5                                                          qh7hdmqm4lzs85p704d6wsybgrpsly0j
311
+## 6                                                          ece42d7743c84d6889abda7011fe6f53
312
+## 7             Visit www.lenovo.com/think for information about Lenovo products and services
313
+## 8                      google-site-verification=nGgukcp60rC-gFxMOJw1NHH0B4VnSchRrlfWV-He_tE
314
+## 9                               facebook-domain-verification=1r2am7c2bhzrxpqyt0mda0djoquqsi
315
+## 10                                                         a82c74b37aa84e7c8580f0e32f4d795d
316
+
317
+cname <- doh_post("dataassurance.pwc.com", "CNAME")
318
+tidy(cname)
319
+##                     name class type  ttl                   cname
320
+## 1 dataassurance.pwc.com.     1    5 1346 f6759d2.x.incapdns.net.
321
+##                                                                                    rdata_raw
322
+## 1 66, 36, 37, 35, 39, 64, 32, 2e, 78, 2e, 69, 6e, 63, 61, 70, 64, 6e, 73, 2e, 6e, 65, 74, 2e
323
+
324
+ns <- doh_post("rud.is", "NS")
325
+tidy(ns)
326
+##      name class type   ttl          nsdname                                                      rdata_raw
327
+## 1 rud.is.     1    2 43200  dns.mwebdns.eu.     64, 6e, 73, 2e, 6d, 77, 65, 62, 64, 6e, 73, 2e, 65, 75, 2e
328
+## 2 rud.is.     1    2 43200  dns.mwebdns.de.     64, 6e, 73, 2e, 6d, 77, 65, 62, 64, 6e, 73, 2e, 64, 65, 2e
329
+## 3 rud.is.     1    2 43200 dns.mwebdns.net. 64, 6e, 73, 2e, 6d, 77, 65, 62, 64, 6e, 73, 2e, 6e, 65, 74, 2e
330
+
331
+soa <- doh_post("rud.is", "SOA")
332
+tidy(soa)
333
+##      name class type   ttl expire minimum           mname
334
+## 1 rud.is.     1    6 43200 604800   86400 dns.mwebdns.de.
335
+##                                                                                                                                                                                                                                                rdata_raw
336
+## 1 03, 64, 6e, 73, 07, 6d, 77, 65, 62, 64, 6e, 73, 02, 64, 65, 00, 0a, 68, 6f, 73, 74, 6d, 61, 73, 74, 65, 72, 0a, 6d, 61, 6e, 64, 6f, 72, 61, 77, 65, 62, 02, 64, 65, 00, 77, ce, 5b, f3, 00, 00, 2a, 30, 00, 00, 0e, 10, 00, 09, 3a, 80, 00, 01, 51, 80
337
+##   refresh retry                     rname     serial
338
+## 1   10800  3600 hostmaster.mandoraweb.de. 2010012659
339
+
340
+ptr <- doh_post(to_inaddr_arpa("104.244.13.104"), "PTR")
341
+tidy(ptr)
342
+##                           name class type   ttl                      ptrdname
343
+## 1 104.13.244.104.in-addr.arpa.     1   12 43200 archive.farsightsecurity.com.
344
+##                                                                                                            rdata_raw
345
+## 1 61, 72, 63, 68, 69, 76, 65, 2e, 66, 61, 72, 73, 69, 67, 68, 74, 73, 65, 63, 75, 72, 69, 74, 79, 2e, 63, 6f, 6d, 2e
346
+```
228 347
 
229 348
 ## clandnstine Metrics
230 349
 
231 350
 | Lang | \# Files |  (%) | LoC |  (%) | Blank lines |  (%) | \# Lines |  (%) |
232 351
 | :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | ---: |
233
-| C++  |        3 | 0.21 | 608 | 0.65 |         196 | 0.62 |      138 | 0.27 |
234
-| R    |       10 | 0.71 | 306 | 0.33 |          68 | 0.22 |      283 | 0.55 |
235
-| Rmd  |        1 | 0.07 |  19 | 0.02 |          51 | 0.16 |       97 | 0.19 |
352
+| R    |       20 | 0.80 | 686 | 0.49 |         188 | 0.40 |      370 | 0.58 |
353
+| C++  |        4 | 0.16 | 681 | 0.49 |         220 | 0.46 |      163 | 0.25 |
354
+| Rmd  |        1 | 0.04 |  37 | 0.03 |          66 | 0.14 |      110 | 0.17 |
236 355
 
237 356
 ## Code of Conduct
238 357
 
239 358
 Please note that this project is released with a [Contributor Code of
240 359
 Conduct](CONDUCT.md). By participating in this project you agree to
241
-abide by its terms.
360
+abide by its terms.

+ 1
- 1
man/clandnstine.Rd View File

@@ -4,7 +4,7 @@
4 4
 \name{clandnstine}
5 5
 \alias{clandnstine}
6 6
 \alias{clandnstine-package}
7
-\title{Perform Secure-by-default 'DNS' Queries}
7
+\title{Perform Secure-by-Default 'DNS' Queries}
8 8
 \description{
9 9
 Methods are provided to query 'Domain Name System' ('DNS') stub
10 10
 and recursive resolvers for all 'DNS' resource record types using 'UDP',

+ 29
- 0
man/doh_post.Rd View File

@@ -0,0 +1,29 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/doh-query.R
3
+\name{doh_post}
4
+\alias{doh_post}
5
+\title{Make a DoH Request (POST/wireformat)}
6
+\usage{
7
+doh_post(name, type = "A",
8
+  server_path = "https://dns.quad9.net/dns-query")
9
+}
10
+\arguments{
11
+\item{name}{name to query for}
12
+
13
+\item{type}{DNS query type (defaults to "\code{A}")}
14
+
15
+\item{server_path}{full URL path to the DoH server quer endpoint (defaults to Quad9).}
16
+}
17
+\value{
18
+\code{NULL} (if the query failed) or a \code{data.frame} (tibble)
19
+}
20
+\description{
21
+Issue a \code{POST} wireformat query of type \code{type} for \code{name} to
22
+the DoH endpoint specified at \code{server_path}.
23
+}
24
+\examples{
25
+doh_post("rud.is", "A")
26
+}
27
+\references{
28
+\url{https://tools.ietf.org/id/draft-ietf-doh-dns-over-https-05.html}
29
+}

+ 32
- 0
man/doh_servers.Rd View File

@@ -0,0 +1,32 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/globals.R
3
+\docType{data}
4
+\name{doh_servers}
5
+\alias{doh_servers}
6
+\title{Built-in list of DoH Servers}
7
+\format{An object of class \code{list} of length 11.}
8
+\usage{
9
+doh_servers
10
+}
11
+\description{
12
+The \code{url} element has the URL for \code{GET}/\code{POST} requests and
13
+the \code{extra_params} element has any needed query parameters
14
+for \code{GET} requests.
15
+}
16
+\details{
17
+The list so far.
18
+\itemize{
19
+\item \code{google}: \url{https://dns.google.com/experimental}
20
+\item \code{cloudflare}: \url{https://cloudflare-dns.com/dns-query}
21
+\item \code{quad9}: \url{https://dns.quad9.net/dns-query}
22
+\item \code{securedns_eu}: \url{https://doh.securedns.eu/dns-query}
23
+\item \code{dnswarden_adblock}: \url{https://doh.dnswarden.com/adblock}
24
+\item \code{dnswarden_uncensored}: \url{https://doh.dnswarden.com/uncensored}
25
+\item \code{cleanbrowsing_security}: \url{https://doh.cleanbrowsing.org/doh/security-filter/}
26
+\item \code{cleanbrowsing_family}: \url{https://doh.cleanbrowsing.org/doh/family-filter/}
27
+\item \code{cleanbrowsing_adult}: \url{https://doh.cleanbrowsing.org/doh/adult-filter/}
28
+\item \code{power_dns}: \url{https://doh.powerdns.org}
29
+\item \code{appliedprivacy}: \url{https://doh.appliedprivacy.net/query}
30
+}
31
+}
32
+\keyword{datasets}

+ 5
- 0
man/gdns_context.Rd View File

@@ -23,3 +23,8 @@ maintains a list of DNS over TLS servers.
23 23
 x <- gdns_context()
24 24
 x <- gdns_context("1.1.1.1")
25 25
 }
26
+\seealso{
27
+Other query functions: \code{\link{gdns_get_address}},
28
+  \code{\link{gdns_query}}
29
+}
30
+\concept{query functions}

+ 5
- 0
man/gdns_get_address.Rd View File

@@ -19,3 +19,8 @@ x <- gdns_resolver()
19 19
 gdns_get_address(x, "yahoo.com")
20 20
 x \%>\% gdns_get_address("yahoo.com")
21 21
 }
22
+\seealso{
23
+Other query functions: \code{\link{gdns_context}},
24
+  \code{\link{gdns_query}}
25
+}
26
+\concept{query functions}

+ 17
- 0
man/gdns_get_hosts.Rd View File

@@ -12,3 +12,20 @@ gdns_get_hosts(gctx)
12 12
 \description{
13 13
 Retreive the value of the localnames namespace
14 14
 }
15
+\seealso{
16
+Other context functions: \code{\link{gdns_get_resolution_type}},
17
+  \code{\link{gdns_get_resolvconf}},
18
+  \code{\link{gdns_get_root_servers}},
19
+  \code{\link{gdns_get_timeout}},
20
+  \code{\link{gdns_get_tls_ca_file}},
21
+  \code{\link{gdns_get_tls_ca_path}},
22
+  \code{\link{gdns_get_transports}},
23
+  \code{\link{gdns_set_hosts}},
24
+  \code{\link{gdns_set_resolution_type}},
25
+  \code{\link{gdns_set_round_robin_upstreams}},
26
+  \code{\link{gdns_set_timeout}},
27
+  \code{\link{gdns_set_tls_ca_file}},
28
+  \code{\link{gdns_set_tls_ca_path}},
29
+  \code{\link{gdns_update_resolvers}}
30
+}
31
+\concept{context functions}

+ 17
- 0
man/gdns_get_resolution_type.Rd View File

@@ -16,3 +16,20 @@ Get the current resolution type setting
16 16
 x <- gdns_context()
17 17
 gdns_get_resolution_type(x)
18 18
 }
19
+\seealso{
20
+Other context functions: \code{\link{gdns_get_hosts}},
21
+  \code{\link{gdns_get_resolvconf}},
22
+  \code{\link{gdns_get_root_servers}},
23
+  \code{\link{gdns_get_timeout}},
24
+  \code{\link{gdns_get_tls_ca_file}},
25
+  \code{\link{gdns_get_tls_ca_path}},
26
+  \code{\link{gdns_get_transports}},
27
+  \code{\link{gdns_set_hosts}},
28
+  \code{\link{gdns_set_resolution_type}},
29
+  \code{\link{gdns_set_round_robin_upstreams}},
30
+  \code{\link{gdns_set_timeout}},
31
+  \code{\link{gdns_set_tls_ca_file}},
32
+  \code{\link{gdns_set_tls_ca_path}},
33
+  \code{\link{gdns_update_resolvers}}
34
+}
35
+\concept{context functions}

+ 17
- 0
man/gdns_get_resolvconf.Rd View File

@@ -12,3 +12,20 @@ gdns_get_resolvconf(gctx)
12 12
 \description{
13 13
 Retreive the value with which the context's upstream recursive servers and suffixes were initialized
14 14
 }
15
+\seealso{
16
+Other context functions: \code{\link{gdns_get_hosts}},
17
+  \code{\link{gdns_get_resolution_type}},
18
+  \code{\link{gdns_get_root_servers}},
19
+  \code{\link{gdns_get_timeout}},
20
+  \code{\link{gdns_get_tls_ca_file}},
21
+  \code{\link{gdns_get_tls_ca_path}},
22
+  \code{\link{gdns_get_transports}},
23
+  \code{\link{gdns_set_hosts}},
24
+  \code{\link{gdns_set_resolution_type}},
25
+  \code{\link{gdns_set_round_robin_upstreams}},
26
+  \code{\link{gdns_set_timeout}},
27
+  \code{\link{gdns_set_tls_ca_file}},
28
+  \code{\link{gdns_set_tls_ca_path}},
29
+  \code{\link{gdns_update_resolvers}}
30
+}
31
+\concept{context functions}

+ 31
- 0
man/gdns_get_root_servers.Rd View File

@@ -0,0 +1,31 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/resolver.R
3
+\name{gdns_get_root_servers}
4
+\alias{gdns_get_root_servers}
5
+\title{Retrieve the list of addresses in use for looking up top-level domains in use by the context.}
6
+\usage{
7
+gdns_get_root_servers(gctx)
8
+}
9
+\arguments{
10
+\item{gctx}{gdns resolver context created with \code{\link[=gdns_resolver]{gdns_resolver()}}}
11
+}
12
+\description{
13
+Retrieve the list of addresses in use for looking up top-level domains in use by the context.
14
+}
15
+\seealso{
16
+Other context functions: \code{\link{gdns_get_hosts}},
17
+  \code{\link{gdns_get_resolution_type}},
18
+  \code{\link{gdns_get_resolvconf}},
19
+  \code{\link{gdns_get_timeout}},
20
+  \code{\link{gdns_get_tls_ca_file}},
21
+  \code{\link{gdns_get_tls_ca_path}},
22
+  \code{\link{gdns_get_transports}},
23
+  \code{\link{gdns_set_hosts}},
24
+  \code{\link{gdns_set_resolution_type}},
25
+  \code{\link{gdns_set_round_robin_upstreams}},
26
+  \code{\link{gdns_set_timeout}},
27
+  \code{\link{gdns_set_tls_ca_file}},
28
+  \code{\link{gdns_set_tls_ca_path}},
29
+  \code{\link{gdns_update_resolvers}}
30
+}
31
+\concept{context functions}

+ 17
- 0
man/gdns_get_timeout.Rd View File

@@ -12,3 +12,20 @@ gdns_get_timeout(gctx)
12 12
 \description{
13 13
 Retreive the number of milliseconds to wait for request to return
14 14
 }
15
+\seealso{
16
+Other context functions: \code{\link{gdns_get_hosts}},
17
+  \code{\link{gdns_get_resolution_type}},
18
+  \code{\link{gdns_get_resolvconf}},
19
+  \code{\link{gdns_get_root_servers}},
20
+  \code{\link{gdns_get_tls_ca_file}},
21
+  \code{\link{gdns_get_tls_ca_path}},
22
+  \code{\link{gdns_get_transports}},
23
+  \code{\link{gdns_set_hosts}},
24
+  \code{\link{gdns_set_resolution_type}},
25
+  \code{\link{gdns_set_round_robin_upstreams}},
26
+  \code{\link{gdns_set_timeout}},
27
+  \code{\link{gdns_set_tls_ca_file}},
28
+  \code{\link{gdns_set_tls_ca_path}},
29
+  \code{\link{gdns_update_resolvers}}
30
+}
31
+\concept{context functions}

+ 17
- 0
man/gdns_get_tls_ca_file.Rd View File

@@ -12,3 +12,20 @@ gdns_get_tls_ca_file(gctx)
12 12
 \description{
13 13
 Retreive the file location with CA certificates for verification purposes
14 14
 }
15
+\seealso{
16
+Other context functions: \code{\link{gdns_get_hosts}},
17
+  \code{\link{gdns_get_resolution_type}},
18
+  \code{\link{gdns_get_resolvconf}},
19
+  \code{\link{gdns_get_root_servers}},
20
+  \code{\link{gdns_get_timeout}},
21
+  \code{\link{gdns_get_tls_ca_path}},
22
+  \code{\link{gdns_get_transports}},
23
+  \code{\link{gdns_set_hosts}},
24
+  \code{\link{gdns_set_resolution_type}},
25
+  \code{\link{gdns_set_round_robin_upstreams}},
26
+  \code{\link{gdns_set_timeout}},
27
+  \code{\link{gdns_set_tls_ca_file}},
28
+  \code{\link{gdns_set_tls_ca_path}},
29
+  \code{\link{gdns_update_resolvers}}
30
+}
31
+\concept{context functions}

+ 17
- 0
man/gdns_get_tls_ca_path.Rd View File

@@ -12,3 +12,20 @@ gdns_get_tls_ca_path(gctx)
12 12
 \description{
13 13
 Retreive the value with which the context's upstream recursive servers and suffixes were initialized
14 14
 }
15
+\seealso{
16
+Other context functions: \code{\link{gdns_get_hosts}},
17
+  \code{\link{gdns_get_resolution_type}},
18
+  \code{\link{gdns_get_resolvconf}},
19
+  \code{\link{gdns_get_root_servers}},
20
+  \code{\link{gdns_get_timeout}},
21
+  \code{\link{gdns_get_tls_ca_file}},
22
+  \code{\link{gdns_get_transports}},
23
+  \code{\link{gdns_set_hosts}},
24
+  \code{\link{gdns_set_resolution_type}},
25
+  \code{\link{gdns_set_round_robin_upstreams}},
26
+  \code{\link{gdns_set_timeout}},
27
+  \code{\link{gdns_set_tls_ca_file}},
28
+  \code{\link{gdns_set_tls_ca_path}},
29
+  \code{\link{gdns_update_resolvers}}
30
+}
31
+\concept{context functions}

+ 17
- 0
man/gdns_get_transports.Rd View File

@@ -12,3 +12,20 @@ gdns_get_transports(gctx)
12 12
 \description{
13 13
 Retreive what transports are used for DNS lookups.
14 14
 }
15
+\seealso{
16
+Other context functions: \code{\link{gdns_get_hosts}},
17
+  \code{\link{gdns_get_resolution_type}},
18
+  \code{\link{gdns_get_resolvconf}},
19
+  \code{\link{gdns_get_root_servers}},
20
+  \code{\link{gdns_get_timeout}},
21
+  \code{\link{gdns_get_tls_ca_file}},
22
+  \code{\link{gdns_get_tls_ca_path}},
23
+  \code{\link{gdns_set_hosts}},
24
+  \code{\link{gdns_set_resolution_type}},
25
+  \code{\link{gdns_set_round_robin_upstreams}},
26
+  \code{\link{gdns_set_timeout}},
27
+  \code{\link{gdns_set_tls_ca_file}},
28
+  \code{\link{gdns_set_tls_ca_path}},
29
+  \code{\link{gdns_update_resolvers}}
30
+}
31
+\concept{context functions}

+ 1
- 0
man/gdns_lib_version.Rd View File

@@ -9,3 +9,4 @@ gdns_lib_version()
9 9
 \description{
10 10
 Return gdns library version
11 11
 }
12
+\concept{utlity functions}

+ 9
- 2
man/gdns_query.Rd View File

@@ -4,11 +4,13 @@
4 4
 \alias{gdns_query}
5 5
 \title{Arbitrary DNS queries}
6 6
 \usage{
7
-gdns_query(gctx, name, rr_type = "txt", rr_class = 1L,
7
+gdns_query(gctx = NULL, name, rr_type = "txt", rr_class = 1L,
8 8
   include_reporting = FALSE)
9 9
 }
10 10
 \arguments{
11
-\item{gctx}{gdns resolver context created with \code{\link[=gdns_resolver]{gdns_resolver()}}}
11
+\item{gctx}{gdns resolver context created with \code{\link[=gdns_resolver]{gdns_resolver()}}. If \code{NULL} a
12
+temporary context will be created but is not ideal since there is overhead
13
+associated with context creation and garbage collection.}
12 14
 
13 15
 \item{name}{an entity to query for}
14 16
 
@@ -127,3 +129,8 @@ gdns_query(x, "example.com")
127 129
 \references{
128 130
 \url{https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml}
129 131
 }
132
+\seealso{
133
+Other query functions: \code{\link{gdns_context}},
134
+  \code{\link{gdns_get_address}}
135
+}
136
+\concept{query functions}

+ 18
- 1
man/gdns_set_hosts.Rd View File

@@ -17,5 +17,22 @@ Initialized the context's local names namespace with values from the given hosts
17 17
 }
18 18
 \examples{
19 19
 x <- gdns_context()
20
-x <- gdns_set_hosts(x, "/etc/hosts")
20
+gdns_set_hosts(x, "/etc/hosts")
21 21
 }
22
+\seealso{
23
+Other context functions: \code{\link{gdns_get_hosts}},
24
+  \code{\link{gdns_get_resolution_type}},
25
+  \code{\link{gdns_get_resolvconf}},
26
+  \code{\link{gdns_get_root_servers}},
27
+  \code{\link{gdns_get_timeout}},
28
+  \code{\link{gdns_get_tls_ca_file}},
29
+  \code{\link{gdns_get_tls_ca_path}},
30
+  \code{\link{gdns_get_transports}},
31
+  \code{\link{gdns_set_resolution_type}},
32
+  \code{\link{gdns_set_round_robin_upstreams}},
33
+  \code{\link{gdns_set_timeout}},
34
+  \code{\link{gdns_set_tls_ca_file}},
35
+  \code{\link{gdns_set_tls_ca_path}},
36
+  \code{\link{gdns_update_resolvers}}
37
+}
38
+\concept{context functions}

+ 17
- 0
man/gdns_set_resolution_type.Rd View File

@@ -18,3 +18,20 @@ Specify whether DNS queries are performed with recursive lookups or as a stub re
18 18
 x <- gdns_context()
19 19
 x <- gdns_set_resolution_type(x, "stub")
20 20
 }
21
+\seealso{
22
+Other context functions: \code{\link{gdns_get_hosts}},
23
+  \code{\link{gdns_get_resolution_type}},
24
+  \code{\link{gdns_get_resolvconf}},
25
+  \code{\link{gdns_get_root_servers}},
26
+  \code{\link{gdns_get_timeout}},
27
+  \code{\link{gdns_get_tls_ca_file}},
28
+  \code{\link{gdns_get_tls_ca_path}},
29
+  \code{\link{gdns_get_transports}},
30
+  \code{\link{gdns_set_hosts}},
31
+  \code{\link{gdns_set_round_robin_upstreams}},
32
+  \code{\link{gdns_set_timeout}},
33
+  \code{\link{gdns_set_tls_ca_file}},
34
+  \code{\link{gdns_set_tls_ca_path}},
35
+  \code{\link{gdns_update_resolvers}}
36
+}
37
+\concept{context functions}

+ 17
- 0
man/gdns_set_round_robin_upstreams.Rd View File

@@ -16,3 +16,20 @@ gdns_set_round_robin_upstreams(gctx, flag = TRUE)
16 16
 Set/unset context to round robin queries over the available upstreams
17 17
 when resolving with the stub resolution type.
18 18
 }
19
+\seealso{
20
+Other context functions: \code{\link{gdns_get_hosts}},
21
+  \code{\link{gdns_get_resolution_type}},
22
+  \code{\link{gdns_get_resolvconf}},
23
+  \code{\link{gdns_get_root_servers}},
24
+  \code{\link{gdns_get_timeout}},
25
+  \code{\link{gdns_get_tls_ca_file}},
26
+  \code{\link{gdns_get_tls_ca_path}},
27
+  \code{\link{gdns_get_transports}},
28
+  \code{\link{gdns_set_hosts}},
29
+  \code{\link{gdns_set_resolution_type}},
30
+  \code{\link{gdns_set_timeout}},
31
+  \code{\link{gdns_set_tls_ca_file}},
32
+  \code{\link{gdns_set_tls_ca_path}},
33
+  \code{\link{gdns_update_resolvers}}
34
+}
35
+\concept{context functions}

+ 17
- 0
man/gdns_set_timeout.Rd View File

@@ -14,3 +14,20 @@ gdns_set_timeout(gctx, timeout)
14 14
 \description{
15 15
 Specify the number of milliseconds to wait for request to return
16 16
 }
17
+\seealso{
18
+Other context functions: \code{\link{gdns_get_hosts}},
19
+  \code{\link{gdns_get_resolution_type}},
20
+  \code{\link{gdns_get_resolvconf}},
21
+  \code{\link{gdns_get_root_servers}},
22
+  \code{\link{gdns_get_timeout}},
23
+  \code{\link{gdns_get_tls_ca_file}},
24
+  \code{\link{gdns_get_tls_ca_path}},
25
+  \code{\link{gdns_get_transports}},
26
+  \code{\link{gdns_set_hosts}},
27
+  \code{\link{gdns_set_resolution_type}},
28
+  \code{\link{gdns_set_round_robin_upstreams}},
29
+  \code{\link{gdns_set_tls_ca_file}},
30
+  \code{\link{gdns_set_tls_ca_path}},
31
+  \code{\link{gdns_update_resolvers}}
32
+}
33
+\concept{context functions}

+ 17
- 0
man/gdns_set_tls_ca_file.Rd View File

@@ -14,3 +14,20 @@ gdns_set_tls_ca_file(gctx, ca_file)
14 14
 \description{
15 15
 Specify the file with CA certificates for verification purposes
16 16
 }
17
+\seealso{
18
+Other context functions: \code{\link{gdns_get_hosts}},
19
+  \code{\link{gdns_get_resolution_type}},
20
+  \code{\link{gdns_get_resolvconf}},
21
+  \code{\link{gdns_get_root_servers}},
22
+  \code{\link{gdns_get_timeout}},
23
+  \code{\link{gdns_get_tls_ca_file}},
24
+  \code{\link{gdns_get_tls_ca_path}},
25
+  \code{\link{gdns_get_transports}},
26
+  \code{\link{gdns_set_hosts}},
27
+  \code{\link{gdns_set_resolution_type}},
28
+  \code{\link{gdns_set_round_robin_upstreams}},
29
+  \code{\link{gdns_set_timeout}},
30
+  \code{\link{gdns_set_tls_ca_path}},
31
+  \code{\link{gdns_update_resolvers}}
32
+}
33
+\concept{context functions}

+ 17
- 0
man/gdns_set_tls_ca_path.Rd View File

@@ -14,3 +14,20 @@ gdns_set_tls_ca_path(gctx, ca_path)
14 14
 \description{
15 15
 Specify where the location for CA certificates for verification purposes are located
16 16
 }
17
+\seealso{
18
+Other context functions: \code{\link{gdns_get_hosts}},
19
+  \code{\link{gdns_get_resolution_type}},
20
+  \code{\link{gdns_get_resolvconf}},
21
+  \code{\link{gdns_get_root_servers}},
22
+  \code{\link{gdns_get_timeout}},
23
+  \code{\link{gdns_get_tls_ca_file}},
24
+  \code{\link{gdns_get_tls_ca_path}},
25
+  \code{\link{gdns_get_transports}},
26
+  \code{\link{gdns_set_hosts}},
27
+  \code{\link{gdns_set_resolution_type}},
28
+  \code{\link{gdns_set_round_robin_upstreams}},
29
+  \code{\link{gdns_set_timeout}},
30
+  \code{\link{gdns_set_tls_ca_file}},
31
+  \code{\link{gdns_update_resolvers}}
32
+}
33
+\concept{context functions}

+ 18
- 1
man/gdns_update_resolvers.Rd View File

@@ -20,5 +20,22 @@ maintains a list of DNS over TLS servers.
20 20
 }
21 21
 \examples{
22 22
 x <- gdns_context()
23
-x <- gdns_update_resolvers("1.1.1.1")
23
+x <- gdns_update_resolvers(x, "1.1.1.1")
24 24
 }
25
+\seealso{
26
+Other context functions: \code{\link{gdns_get_hosts}},
27
+  \code{\link{gdns_get_resolution_type}},
28
+  \code{\link{gdns_get_resolvconf}},
29
+  \code{\link{gdns_get_root_servers}},
30
+  \code{\link{gdns_get_timeout}},
31
+  \code{\link{gdns_get_tls_ca_file}},
32
+  \code{\link{gdns_get_tls_ca_path}},
33
+  \code{\link{gdns_get_transports}},
34
+  \code{\link{gdns_set_hosts}},
35
+  \code{\link{gdns_set_resolution_type}},
36
+  \code{\link{gdns_set_round_robin_upstreams}},
37
+  \code{\link{gdns_set_timeout}},
38
+  \code{\link{gdns_set_tls_ca_file}},
39
+  \code{\link{gdns_set_tls_ca_path}}
40
+}
41
+\concept{context functions}

+ 15
- 0
man/int_gdns_get_root_servers.Rd View File

@@ -0,0 +1,15 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/RcppExports.R
3
+\name{int_gdns_get_root_servers}
4
+\alias{int_gdns_get_root_servers}
5
+\title{Retrieve the list of addresses in use for looking up top-level domains in use by the context.}
6
+\usage{
7
+int_gdns_get_root_servers(gctx)
8
+}
9
+\arguments{
10
+\item{gctx}{gdns resolver context created with \code{\link[=gdns_resolver]{gdns_resolver()}}}
11
+}
12
+\description{
13
+Retrieve the list of addresses in use for looking up top-level domains in use by the context.
14
+}
15
+\keyword{internal}

+ 14
- 0
man/is_gctx.Rd View File

@@ -0,0 +1,14 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/is.R
3
+\name{is_gctx}
4
+\alias{is_gctx}
5
+\title{Test whether an object is a \code{gctx} context}
6
+\usage{
7
+is_gctx(x)
8
+}
9
+\arguments{
10
+\item{x}{object}
11
+}
12
+\description{
13
+Test whether an object is a \code{gctx} context
14
+}

+ 17
- 0
man/tidy.Rd View File

@@ -0,0 +1,17 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/doh-query.R
3
+\name{tidy}
4
+\alias{tidy}
5
+\title{Tidy generic}
6
+\usage{
7
+tidy(x, ...)
8
+}
9
+\arguments{
10
+\item{x}{an object}
11
+
12
+\item{...}{unused}
13
+}
14
+\description{
15
+Tidy generic
16
+}
17
+\keyword{internal}

+ 16
- 0
man/tidy.gdns_doh_response.Rd View File

@@ -0,0 +1,16 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/doh-query.R
3
+\name{tidy.gdns_doh_response}
4
+\alias{tidy.gdns_doh_response}
5
+\title{Tidy a DoH POST response}
6
+\usage{
7
+\method{tidy}{gdns_doh_response}(x, ...)
8
+}
9
+\arguments{
10
+\item{x}{a DoH POST response}
11
+
12
+\item{...}{unused}
13
+}
14
+\description{
15
+Tidy a DoH POST response
16
+}

+ 14
- 0
man/to_inaddr_arpa.Rd View File

@@ -0,0 +1,14 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/to-inaddr-arpa.R
3
+\name{to_inaddr_arpa}
4
+\alias{to_inaddr_arpa}
5
+\title{Convert a vector of IPv4 addresses to in-addr.arpa format}
6
+\usage{
7
+to_inaddr_arpa(ipv4)
8
+}
9
+\arguments{
10
+\item{ipv4}{vector of ipv4 addresses}
11
+}
12
+\description{
13
+Convert a vector of IPv4 addresses to in-addr.arpa format
14
+}

BIN
src/.vscode/ipch/fbe8796a0b446fa3/mmap_address.bin View File


BIN
src/.vscode/ipch/fbe8796a0b446fa3/resolver.ipch View File


+ 24
- 0
src/RcppExports.cpp View File

@@ -177,6 +177,28 @@ BEGIN_RCPP
177 177
     return rcpp_result_gen;
178 178
 END_RCPP
179 179
 }
180
+// int_gdns_get_root_servers
181
+CharacterVector int_gdns_get_root_servers(SEXP gctx);
182
+RcppExport SEXP _clandnstine_int_gdns_get_root_servers(SEXP gctxSEXP) {
183
+BEGIN_RCPP
184
+    Rcpp::RObject rcpp_result_gen;
185
+    Rcpp::RNGScope rcpp_rngScope_gen;
186
+    Rcpp::traits::input_parameter< SEXP >::type gctx(gctxSEXP);
187
+    rcpp_result_gen = Rcpp::wrap(int_gdns_get_root_servers(gctx));
188
+    return rcpp_result_gen;
189
+END_RCPP
190
+}
191
+// int_dns_wire_to_list
192
+CharacterVector int_dns_wire_to_list(SEXP buf);
193
+RcppExport SEXP _clandnstine_int_dns_wire_to_list(SEXP bufSEXP) {
194
+BEGIN_RCPP
195
+    Rcpp::RObject rcpp_result_gen;
196
+    Rcpp::RNGScope rcpp_rngScope_gen;
197
+    Rcpp::traits::input_parameter< SEXP >::type buf(bufSEXP);
198
+    rcpp_result_gen = Rcpp::wrap(int_dns_wire_to_list(buf));
199
+    return rcpp_result_gen;
200
+END_RCPP
201
+}
180 202
 // check_is_xptr
181 203
 void check_is_xptr(SEXP s);
182 204
 RcppExport SEXP _clandnstine_check_is_xptr(SEXP sSEXP) {
@@ -274,6 +296,8 @@ static const R_CallMethodDef CallEntries[] = {
274 296
     {"_clandnstine_gdns_get_tls_ca_file", (DL_FUNC) &_clandnstine_gdns_get_tls_ca_file, 1},
275 297
     {"_clandnstine_gdns_set_tls_ca_path", (DL_FUNC) &_clandnstine_gdns_set_tls_ca_path, 2},
276 298
     {"_clandnstine_gdns_set_tls_ca_file", (DL_FUNC) &_clandnstine_gdns_set_tls_ca_file, 2},
299
+    {"_clandnstine_int_gdns_get_root_servers", (DL_FUNC) &_clandnstine_int_gdns_get_root_servers, 1},
300
+    {"_clandnstine_int_dns_wire_to_list", (DL_FUNC) &_clandnstine_int_dns_wire_to_list, 1},
277 301
     {"_clandnstine_check_is_xptr", (DL_FUNC) &_clandnstine_check_is_xptr, 1},
278 302
     {"_clandnstine_is_null_xptr_", (DL_FUNC) &_clandnstine_is_null_xptr_, 1},
279 303
     {"_clandnstine_int_gdns_context", (DL_FUNC) &_clandnstine_int_gdns_context, 1},

+ 51
- 0
src/clandnstine-main.cpp View File

@@ -7,6 +7,7 @@ using namespace Rcpp;
7 7
 extern void check_is_xptr(SEXP s);
8 8
 //' Return gdns library version
9 9
 //'
10
+//' @family utlity functions
10 11
 //' @export
11 12
 // [[Rcpp::export]]
12 13
 std::string gdns_lib_version() {
@@ -48,6 +49,7 @@ SEXP int_gdns_update_resolvers(SEXP gctx, std::vector< std::string > resolvers)
48 49
 //'
49 50
 //' @param gctx gdns resolver context created with [gdns_resolver()]
50 51
 //' @param timeout number of milliseconds (integer; i.e. not-fractional)
52
+//' @family context functions
51 53
 //' @export
52 54
 // [[Rcpp::export]]
53 55
 SEXP gdns_set_timeout(SEXP gctx, long timeout) {
@@ -71,6 +73,7 @@ SEXP gdns_set_timeout(SEXP gctx, long timeout) {
71 73
 //' Retreive the number of milliseconds to wait for request to return
72 74
 //'
73 75
 //' @param gctx gdns resolver context created with [gdns_resolver()]
76
+//' @family context functions
74 77
 //' @export
75 78
 // [[Rcpp::export]]
76 79
 DoubleVector gdns_get_timeout(SEXP gctx) {
@@ -101,6 +104,7 @@ DoubleVector gdns_get_timeout(SEXP gctx) {
101 104
 //' @md
102 105
 //' @param gctx gdns resolver context created with [gdns_resolver()]
103 106
 //' @param flag if `TRUE` (the default) round robin queries when using more than one stub resolver,
107
+//' @family context functions
104 108
 //' @export
105 109
 // [[Rcpp::export]]
106 110
 SEXP gdns_set_round_robin_upstreams(SEXP gctx, bool flag=true) {
@@ -196,6 +200,7 @@ SEXP int_gdns_set_resolution_type(SEXP gctx, int res_type) {
196 200
 //' Retreive what transports are used for DNS lookups.
197 201
 //'
198 202
 //' @param gctx gdns resolver context created with [gdns_resolver()]
203
+//' @family context functions
199 204
 //' @export
200 205
 // [[Rcpp::export]]
201 206
 CharacterVector gdns_get_transports(SEXP gctx) {
@@ -233,6 +238,7 @@ CharacterVector gdns_get_transports(SEXP gctx) {
233 238
 //' Retreive the value of the localnames namespace
234 239
 //'
235 240
 //' @param gctx gdns resolver context created with [gdns_resolver()]
241
+//' @family context functions
236 242
 //' @export
237 243
 // [[Rcpp::export]]
238 244
 CharacterVector gdns_get_hosts(SEXP gctx) {
@@ -257,6 +263,7 @@ CharacterVector gdns_get_hosts(SEXP gctx) {
257 263
 //' Retreive the value with which the context's upstream recursive servers and suffixes were initialized
258 264
 //'
259 265
 //' @param gctx gdns resolver context created with [gdns_resolver()]
266
+//' @family context functions
260 267
 //' @export
261 268
 // [[Rcpp::export]]
262 269
 CharacterVector gdns_get_resolvconf(SEXP gctx) {
@@ -281,6 +288,7 @@ CharacterVector gdns_get_resolvconf(SEXP gctx) {
281 288
 //' Retreive the value with which the context's upstream recursive servers and suffixes were initialized
282 289
 //'
283 290
 //' @param gctx gdns resolver context created with [gdns_resolver()]
291
+//' @family context functions
284 292
 //' @export
285 293
 // [[Rcpp::export]]
286 294
 StringVector gdns_get_tls_ca_path(SEXP gctx) {
@@ -305,6 +313,7 @@ StringVector gdns_get_tls_ca_path(SEXP gctx) {
305 313
 //' Retreive the file location with CA certificates for verification purposes
306 314
 //'
307 315
 //' @param gctx gdns resolver context created with [gdns_resolver()]
316
+//' @family context functions
308 317
 //' @export
309 318
 // [[Rcpp::export]]
310 319
 StringVector gdns_get_tls_ca_file(SEXP gctx) {
@@ -330,6 +339,7 @@ StringVector gdns_get_tls_ca_file(SEXP gctx) {
330 339
 //'
331 340
 //' @param gctx gdns resolver context created with [gdns_resolver()]
332 341
 //' @param ca_path directory with Certificate Authority certificates
342
+//' @family context functions
333 343
 //' @export
334 344
 // [[Rcpp::export]]
335 345
 SEXP gdns_set_tls_ca_path(SEXP gctx, std::string ca_path) {
@@ -354,6 +364,7 @@ SEXP gdns_set_tls_ca_path(SEXP gctx, std::string ca_path) {
354 364
 //'
355 365
 //' @param gctx gdns resolver context created with [gdns_resolver()]
356 366
 //' @param ca_file file with Certificate Authority certificates
367
+//' @family context functions
357 368
 //' @export
358 369
 // [[Rcpp::export]]
359 370
 SEXP gdns_set_tls_ca_file(SEXP gctx, std::string ca_file) {
@@ -373,3 +384,43 @@ SEXP gdns_set_tls_ca_file(SEXP gctx, std::string ca_file) {
373 384
   return(gctx);
374 385
 
375 386
 }
387
+
388
+//' Retrieve the list of addresses in use for looking up top-level domains in use by the context.
389
+//'
390
+//' @param gctx gdns resolver context created with [gdns_resolver()]
391
+//' @keywords internal
392
+// [[Rcpp::export]]
393
+CharacterVector int_gdns_get_root_servers(SEXP gctx) {
394
+
395
+  check_is_xptr(gctx);
396
+
397
+  getdns_context *ctxt = (getdns_context *)R_ExternalPtrAddr(gctx);
398
+
399
+  if (gctx == NULL) return(R_NilValue);
400
+
401
+  getdns_return_t r;
402
+  getdns_list *addresses;
403
+
404
+  if ((r = getdns_context_get_dns_root_servers(ctxt, &addresses))) {
405
+    Rf_error(getdns_get_errorstr_by_id(r));
406
+  }
407
+
408
+  if (addresses) {
409
+    Rcout << "HERE" << std::endl;
410
+    char *lst = getdns_print_json_list(addresses, 0);
411
+    if (lst) {
412
+      Rcout << lst << std::endl;
413
+      std::string out = std::string(lst);
414
+      free(lst);
415
+      free(addresses);
416
+      return(wrap(out));
417
+    } else {
418
+      free(addresses);
419
+      return(CharacterVector());
420
+    }
421
+  } else {
422
+    return(CharacterVector());
423
+  }
424
+
425
+
426
+}

+ 45
- 0
src/from-wire.cpp View File

@@ -0,0 +1,45 @@
1
+#include <Rcpp.h>
2
+
3
+#include <getdns/getdns.h>
4
+#include <getdns/getdns_extra.h>
5
+
6
+#include <arpa/inet.h>
7
+
8
+using namespace Rcpp;
9
+
10
+// [[Rcpp::export]]
11
+CharacterVector int_dns_wire_to_list(SEXP buf) {
12
+
13
+  getdns_return_t r;
14
+  bool ok = true;
15
+
16
+  getdns_dict *resp;
17
+  std::string out;
18
+
19
+  r = getdns_wire2msg_dict(RAW(buf), LENGTH(buf), &resp);
20
+
21
+  if (r == GETDNS_RETURN_GOOD) {
22
+
23
+    char *charout = getdns_print_json_dict(resp, 0);
24
+
25
+    if (charout) {
26
+      out = std::string(charout);
27
+      free(charout);
28
+    } else {
29
+      ok = false;
30
+    }
31
+
32
+  } else {
33
+    ok = false;
34
+  }
35
+
36
+  if (resp) getdns_dict_destroy(resp);
37
+
38
+  if (ok) return(wrap(out)); else return(CharacterVector());
39
+
40
+}
41
+
42
+// getdns_wire2rr_dict 	(	const uint8_t * 	wire,
43
+//                        size_t 	wire_sz,
44
+//                        getdns_dict ** 	rr_dict
45
+// )

+ 2
- 0
src/resolver.cpp View File

@@ -77,6 +77,7 @@ SEXP int_gdns_context(std::vector< std::string > resolvers) {
77 77
 //'
78 78
 //' @param gctx gdns resolver context created with [gdns_resolver()]
79 79
 //' @param host to lookup
80
+//' @family query functions
80 81
 //' @export
81 82
 //' @examples
82 83
 //' x <- gdns_resolver()
@@ -251,6 +252,7 @@ CharacterVector int_gdns_query(SEXP gctx, std::string name, uint16_t rr,
251 252
 //'
252 253
 //' @param gctx gdns resolver context created with [gdns_resolver()]
253 254
 //' @export
255
+//' @family context functions
254 256
 //' @examples
255 257
 //' x <- gdns_context()
256 258
 //' gdns_get_resolution_type(x)

Loading…
Cancel
Save