~hrbrmstr/clandnstine

62e9a5317a47321f447f3f2eb55f4e2b8196cc2e — hrbrmstr 4 years ago 2b80cba master
wire format / 1.6.0
8 files changed, 271 insertions(+), 80 deletions(-)

M .travis.yml
M DESCRIPTION
M NAMESPACE
M NEWS.md
A R/from-wire.R
M README.Rmd
M README.md
A man/from_wireformat.Rd
M .travis.yml => .travis.yml +15 -1
@@ 4,10 4,24 @@ cache: packages
dist: xenial

apt_packages:
  - libgetdns-dev
  - cmake
  - libcurl4-openssl-dev
  - git
  - check
  - libidn2-0-dev
  - libunbound-dev

before_install:
  - git clone https://github.com/getdnsapi/getdns.git
  - cd getdns
  - git checkout develop
  - git submodule update --init
  - mkdir build
  - cd build
  - cmake -DENABLE_STATIC=true -DBUILD_GETDNS_QUERY=true -DBUILD_GETDNS_SERVER_MON=flse -DUSE_GNUTLS=false -DUSE_LIBIDN2=true -DUSE_LIBEV=false -DUSE_LIBEVENT2=false -DUSE_LIBUV=false -DBUILD_STUBBY=false -DENABLE_UNBOUND_EVENT_API=false -DBUILD_DOXYGEN=false ..
  - make
  - make install

addons:
  apt:
    update: true

M DESCRIPTION => DESCRIPTION +2 -2
@@ 1,8 1,8 @@
Package: clandnstine
Type: Package
Title: Perform Secure-by-default or Woefully Insecure 'DNS' Queries
Version: 0.3.0
Date: 2020-02-24
Version: 0.3.1
Date: 2020-03-11
Authors@R: c(
    person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"), 
           comment = c(ORCID = "0000-0001-5670-2640"))

M NAMESPACE => NAMESPACE +1 -0
@@ 6,6 6,7 @@ S3method(tidy,gdns_doh_response)
export("%>%")
export(doh_post)
export(doh_servers)
export(from_wireformat)
export(gdns_context)
export(gdns_get_address)
export(gdns_get_hosts)

M NEWS.md => NEWS.md +4 -0
@@ 1,2 1,6 @@
0.3.1
* support for all queries and responses
* conversion from wireformat q/a to R list

0.1.0 
* Initial release

A R/from-wire.R => R/from-wire.R +26 -0
@@ 0,0 1,26 @@
#' Convert a wireformat DNS records to an R list
#'
#' @param wf DNS wireformat record as an R raw vector
#' @return list
#' @export
#' @examples
#' from_wireformat(
#'   as.raw(c(
#'     0x00, 0x00, 0x81, 0x80, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00,
#'     0x00, 0x00, 0x03, 0x77, 0x77, 0x77, 0x07, 0x65, 0x78, 0x61,
#'     0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00,
#'     0x01, 0x00, 0x01, 0x03, 0x77, 0x77, 0x77, 0x07, 0x65, 0x78,
#'     0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00,
#'     0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x04,
#'     0xC0, 0x00, 0x02, 0x01
#'   ))
#' )
from_wireformat <- function(wf) {

  stopifnot(is.raw(wf))

  res <- int_dns_wire_to_list(wf)

  jsonlite::fromJSON(res)

}
\ No newline at end of file

M README.Rmd => README.Rmd +29 -0
@@ 164,6 164,35 @@ ptr <- doh_post(to_inaddr_arpa("104.244.13.104"), "PTR")
tidy(ptr)
```

### If you _happen_ to have a DNS wireformat record&hellip;

```{r wf}
str(
  from_wireformat(
    as.raw(c(
      0x00, 0x00, 0x81, 0x80, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00,
      0x00, 0x00, 0x03, 0x77, 0x77, 0x77, 0x07, 0x65, 0x78, 0x61,
      0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00,
      0x01, 0x00, 0x01, 0x03, 0x77, 0x77, 0x77, 0x07, 0x65, 0x78,
      0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00,
      0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x04,
      0xC0, 0x00, 0x02, 0x01
    ))
  )
)

str(
  from_wireformat(
    as.raw(c(
      0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x03, 0x77, 0x77, 0x77, 0x07, 0x65, 0x78, 0x61,
      0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00,
      0x01, 0x00, 0x01
    ))
  )
)
```

## clandnstine Metrics

```{r cloc, echo=FALSE}

M README.md => README.md +164 -77
@@ 124,6 124,7 @@ The following functions are implemented:
  - `check_is_xptr`: Test whether an object is an external pointer
  - `doh_post`: Make a DoH Request (POST/wireformat)
  - `doh_servers`: Built-in list of DoH Servers
  - `from_wireformat`: Convert a wireformat DNS records to an R list
  - `gdns_context`: Create a gdns DNS over TLS context and populate it
    with a resolver for use in resolution functions
  - `gdns_get_address`: Resolve a host to an addrss


@@ 202,40 203,40 @@ library(clandnstine)

# current version
packageVersion("clandnstine")
## [1] '0.3.0'
## [1] '0.3.1'
```

### Get an address(es) from a name:

``` r
gdns_lib_version()
## [1] "1.5.2"
## [1] "1.6.0"

(x <- gdns_context())
## <gdns v1.5.2 resolver context; resolvers: [9.9.9.9]; timeout: 5,000 ms; lookup transport(s): [tls]; resolution type: stub>
## <gdns v1.6.0 resolver context; resolvers: [9.9.9.9]; timeout: 5,000 ms; lookup transport(s): [tls]; resolution type: stub>

(x <- gdns_context("1.1.1.1"))
## <gdns v1.5.2 resolver context; resolvers: [1.1.1.1]; timeout: 5,000 ms; lookup transport(s): [tls]; resolution type: stub>
## <gdns v1.6.0 resolver context; resolvers: [1.1.1.1]; timeout: 5,000 ms; lookup transport(s): [tls]; resolution type: stub>

(x <- gdns_context(c("8.8.8.8", "1.1.1.1", "9.9.9.9")))
## <gdns v1.5.2 resolver context; resolvers: [8.8.8.8, 1.1.1.1, 9.9.9.9]; timeout: 5,000 ms; lookup transport(s): [tls]; resolution type: stub>
## <gdns v1.6.0 resolver context; resolvers: [8.8.8.8, 1.1.1.1, 9.9.9.9]; timeout: 5,000 ms; lookup transport(s): [tls]; resolution type: stub>

(gdns_set_timeout(x, 2000))
## <gdns v1.5.2 resolver context; resolvers: [8.8.8.8, 1.1.1.1, 9.9.9.9]; timeout: 2,000 ms; lookup transport(s): [tls]; resolution type: stub>
## <gdns v1.6.0 resolver context; resolvers: [8.8.8.8, 1.1.1.1, 9.9.9.9]; timeout: 2,000 ms; lookup transport(s): [tls]; resolution type: stub>

(gdns_update_resolvers(x, "1.1.1.1"))
## <gdns v1.5.2 resolver context; resolvers: [1.1.1.1]; timeout: 2,000 ms; lookup transport(s): [tls]; resolution type: stub>
## <gdns v1.6.0 resolver context; resolvers: [1.1.1.1]; timeout: 2,000 ms; lookup transport(s): [tls]; resolution type: stub>

(gdns_set_transports(x, c("udp", "tls", "tcp")))
## <gdns v1.5.2 resolver context; resolvers: [1.1.1.1]; timeout: 2,000 ms; lookup transport(s): [udp, tls, tcp]; resolution type: stub>
## <gdns v1.6.0 resolver context; resolvers: [1.1.1.1]; timeout: 2,000 ms; lookup transport(s): [udp, tls, tcp]; resolution type: stub>

(gdns_get_address(x, "rud.is"))
## [1] "2602:ff16:3::4dfb:9ac5" "172.93.49.183"

(gdns_get_address(x, "yahoo.com"))
##  [1] "2001:4998:c:1023::5"   "2001:4998:44:41d::3"   "2001:4998:44:41d::4"   "2001:4998:58:1836::10"
##  [5] "2001:4998:58:1836::11" "2001:4998:c:1023::4"   "72.30.35.10"           "98.137.246.7"         
##  [9] "98.137.246.8"          "98.138.219.231"        "98.138.219.232"        "72.30.35.9"
##  [1] "2001:4998:58:1836::11" "2001:4998:58:1836::10" "2001:4998:44:41d::3"   "2001:4998:c:1023::4"  
##  [5] "2001:4998:44:41d::4"   "2001:4998:c:1023::5"   "98.137.246.8"          "98.138.219.232"       
##  [9] "72.30.35.9"            "98.138.219.231"        "98.137.246.7"          "72.30.35.10"

(gdns_get_address(x, "yahoo.commmm"))
## character(0)


@@ 245,12 246,13 @@ gdns_lib_version()

``` r
str(leno <- gdns_query(x, "lenovo.com", "txt"), 1)
## List of 5
##  $ answer_type   : int 800
##  $ canonical_name: chr "lenovo.com."
##  $ replies_full  : int [1, 1:1029] 87 136 129 128 0 1 0 13 0 0 ...
##  $ replies_tree  :'data.frame':  1 obs. of  7 variables:
##  $ status        : int 900
## List of 6
##  $ answer_ipv4_address: chr "1.1.1.1"
##  $ answer_type        : int 800
##  $ canonical_name     : chr "lenovo.com."
##  $ replies_full       : int [1, 1:1039] 0 73 129 128 0 1 0 13 0 0 ...
##  $ replies_tree       :'data.frame': 1 obs. of  8 variables:
##  $ status             : int 900
##  - attr(*, "class")= chr [1:2] "gdns_response" "list"

sort(unlist(leno$replies_tree$answer[[1]]$rdata$txt_strings))


@@ 282,99 284,99 @@ str(doh_post("rud.is")$answer)
##   ..$ ipv4_address: chr "172.93.49.183"
##   ..$ rdata_raw   :List of 1
##   .. ..$ : int  172 93 49 183
##  $ ttl  : int 3600
##  $ ttl  : int 463
##  $ type : int 1
```

``` r
a <- doh_post("apple.com", "A")
tidy(a)
##         name class type  ttl  ipv4_address      rdata_raw
## 1 apple.com.     1    1 1515  17.178.96.59 11, b2, 60, 3b
## 2 apple.com.     1    1 1515 17.142.160.59 11, 8e, a0, 3b
## 3 apple.com.     1    1 1515 17.172.224.47 11, ac, e0, 2f
##         name class type ttl  ipv4_address      rdata_raw
## 1 apple.com.     1    1 884 17.142.160.59 11, 8e, a0, 3b
## 2 apple.com.     1    1 884 17.172.224.47 11, ac, e0, 2f
## 3 apple.com.     1    1 884  17.178.96.59 11, b2, 60, 3b

aaaa <- doh_post("rud.is", "AAAA")
tidy(aaaa)
##      name class type   ttl           ipv6_address                                                      rdata_raw
## 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
## 1 rud.is.     1   28 40063 2602:ff16:3::4dfb:9ac5 26, 02, ff, 16, 00, 03, 00, 00, 00, 00, 00, 00, 4d, fb, 9a, c5

mx <- doh_post("rud.is", "MX")
tidy(mx)
##      name class type   ttl                 exchange preference
## 1 rud.is.     1   15 43200      aspmx.l.google.com.         10
## 2 rud.is.     1   15 43200   aspmx2.googlemail.com.         40
## 3 rud.is.     1   15 43200 alt2.aspmx.l.google.com.         30
## 4 rud.is.     1   15 43200 alt1.aspmx.l.google.com.         20
##                                                                                rdata_raw
## 1 00, 0a, 05, 61, 73, 70, 6d, 78, 01, 6c, 06, 67, 6f, 6f, 67, 6c, 65, 03, 63, 6f, 6d, 00
## 2 00, 28, 06, 61, 73, 70, 6d, 78, 32, 0a, 67, 6f, 6f, 67, 6c, 65, 6d, 61, 69, 6c, c0, 35
## 3                                                     00, 1e, 04, 61, 6c, 74, 32, c0, 26
## 4                                                     00, 14, 04, 61, 6c, 74, 31, c0, 26
## 1 rud.is.     1   15 40063 alt1.aspmx.l.google.com.         20
## 2 rud.is.     1   15 40063 alt2.aspmx.l.google.com.         30
## 3 rud.is.     1   15 40063      aspmx.l.google.com.         10
## 4 rud.is.     1   15 40063   aspmx2.googlemail.com.         40
##                                                                                                    rdata_raw
## 1 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
## 2                                                                         00, 1e, 04, 61, 6c, 74, 32, c0, 2b
## 3                                                                                             00, 0a, c0, 2b
## 4                     00, 28, 06, 61, 73, 70, 6d, 78, 32, 0a, 67, 6f, 6f, 67, 6c, 65, 6d, 61, 69, 6c, c0, 3a

txt <- doh_post("lenovo.com", "TXT")
tidy(txt)
##           name class type  ttl
## 1  lenovo.com.     1   16 7200
## 2  lenovo.com.     1   16 7200
## 3  lenovo.com.     1   16 7200
## 4  lenovo.com.     1   16 7200
## 5  lenovo.com.     1   16 7200
## 6  lenovo.com.     1   16 7200
## 7  lenovo.com.     1   16 7200
## 8  lenovo.com.     1   16 7200
## 9  lenovo.com.     1   16 7200
## 10 lenovo.com.     1   16 7200
## 11 lenovo.com.     1   16 7200
## 12 lenovo.com.     1   16 7200
## 13 lenovo.com.     1   16 7200
## 1  lenovo.com.     1   16 4063
## 2  lenovo.com.     1   16 4063
## 3  lenovo.com.     1   16 4063
## 4  lenovo.com.     1   16 4063
## 5  lenovo.com.     1   16 4063
## 6  lenovo.com.     1   16 4063
## 7  lenovo.com.     1   16 4063
## 8  lenovo.com.     1   16 4063
## 9  lenovo.com.     1   16 4063
## 10 lenovo.com.     1   16 4063
## 11 lenovo.com.     1   16 4063
## 12 lenovo.com.     1   16 4063
## 13 lenovo.com.     1   16 4063
##                                                                                                                                                                                                                                                                                                                                                                             rdata_raw
## 1                                                                                                                                                                                                                                                  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
## 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
## 3                                                              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
## 4                                                                                                                                                                                                                                                  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
## 5                                                                                                  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, 68, 78, 4e, 53, 6f, 46, 34, 36, 61, 6e, 7a, 6a, 55, 74, 79, 46, 67, 70, 52, 56, 70, 7a, 73, 68, 54, 6b, 59, 43, 6c, 46, 42, 4a, 37, 4f, 41, 54, 33, 44, 7a, 36, 34, 34, 30
## 6                                                                                                  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, 76, 79, 50, 73, 46, 75, 73, 67, 44, 4c, 65, 57, 7a, 76, 6e, 61, 70, 52, 79, 42, 62, 69, 76, 61, 35, 64, 58, 4a, 31, 4a, 49, 4a, 6a, 63, 4e, 62, 47, 75, 4f, 35, 32, 2d, 6b
## 7                                                                                                                                      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
## 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, 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
## 2  5c, 61, 64, 6f, 62, 65, 2d, 69, 64, 70, 2d, 73, 69, 74, 65, 2d, 76, 65, 72, 69, 66, 69, 63, 61, 74, 69, 6f, 6e, 3d, 35, 35, 34, 30, 63, 39, 36, 32, 30, 36, 66, 35, 66, 65, 32, 64, 66, 39, 32, 31, 61, 36, 63, 35, 39, 36, 65, 61, 39, 66, 62, 33, 64, 37, 65, 34, 31, 38, 64, 33, 65, 64, 64, 62, 35, 39, 38, 63, 32, 39, 39, 33, 35, 63, 63, 30, 33, 31, 36, 33, 38, 30, 35, 62
## 3                                                                                                  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, 76, 79, 50, 73, 46, 75, 73, 67, 44, 4c, 65, 57, 7a, 76, 6e, 61, 70, 52, 79, 42, 62, 69, 76, 61, 35, 64, 58, 4a, 31, 4a, 49, 4a, 6a, 63, 4e, 62, 47, 75, 4f, 35, 32, 2d, 6b
## 4                                                                                                  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
## 5                                                                                                                                      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
## 6                                                                                                  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
## 7                                                                                                                                                                                                                                                  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
## 8                                                                                              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
## 9                  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
## 10 5c, 61, 64, 6f, 62, 65, 2d, 69, 64, 70, 2d, 73, 69, 74, 65, 2d, 76, 65, 72, 69, 66, 69, 63, 61, 74, 69, 6f, 6e, 3d, 35, 35, 34, 30, 63, 39, 36, 32, 30, 36, 66, 35, 66, 65, 32, 64, 66, 39, 32, 31, 61, 36, 63, 35, 39, 36, 65, 61, 39, 66, 62, 33, 64, 37, 65, 34, 31, 38, 64, 33, 65, 64, 64, 62, 35, 39, 38, 63, 32, 39, 39, 33, 35, 63, 63, 30, 33, 31, 36, 33, 38, 30, 35, 62
## 11                                                                                                 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
## 12                                                                                                 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
## 9                                                                                                                                                                                                                                                  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
## 10                                                             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
## 11                                                                                                 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, 68, 78, 4e, 53, 6f, 46, 34, 36, 61, 6e, 7a, 6a, 55, 74, 79, 46, 67, 70, 52, 56, 70, 7a, 73, 68, 54, 6b, 59, 43, 6c, 46, 42, 4a, 37, 4f, 41, 54, 33, 44, 7a, 36, 34, 34, 30
## 12                 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
## 13                                                                                                                                                                                                                                                 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
##                                                                                     txt_strings
## 1                                                              qh7hdmqm4lzs85p704d6wsybgrpsly0j
## 2                          google-site-verification=VxW_e6r_Ka7A518qfX2MmIMHGnkpGbnACsjSxKFCBw0
## 3                 Visit www.lenovo.com/think for information about Lenovo products and services
## 4                                                              a82c74b37aa84e7c8580f0e32f4d795d
## 5                          google-site-verification=hxNSoF46anzjUtyFgpRVpzshTkYClFBJ7OAT3Dz6440
## 6                          google-site-verification=vyPsFusgDLeWzvnapRyBbiva5dXJ1JIJjcNbGuO52-k
## 7                                   facebook-domain-verification=1r2am7c2bhzrxpqyt0mda0djoquqsi
## 1                          google-site-verification=nGgukcp60rC-gFxMOJw1NHH0B4VnSchRrlfWV-He_tE
## 2  adobe-idp-site-verification=5540c96206f5fe2df921a6c596ea9fb3d7e418d3eddb598c29935cc03163805b
## 3                          google-site-verification=vyPsFusgDLeWzvnapRyBbiva5dXJ1JIJjcNbGuO52-k
## 4                          google-site-verification=sHIlSlj0U6UnCDkfHp1AolWgVEvDjWvc0TR4KaysD2c
## 5                                   facebook-domain-verification=1r2am7c2bhzrxpqyt0mda0djoquqsi
## 6                          google-site-verification=VxW_e6r_Ka7A518qfX2MmIMHGnkpGbnACsjSxKFCBw0
## 7                                                              a82c74b37aa84e7c8580f0e32f4d795d
## 8                         v=spf1 include:spf.messagelabs.com include:_netblocks.eloqua.com ~all
## 9      iHzQJvsKnyGP2Nm2qBgL3fyBJ0CC9z4GkY/flfk4EzLP8lPxWHDDPKqZWm1TkeF5kEIL+NotYOF1wo7JtUDXXw==
## 10 adobe-idp-site-verification=5540c96206f5fe2df921a6c596ea9fb3d7e418d3eddb598c29935cc03163805b
## 11                         google-site-verification=sHIlSlj0U6UnCDkfHp1AolWgVEvDjWvc0TR4KaysD2c
## 12                         google-site-verification=nGgukcp60rC-gFxMOJw1NHH0B4VnSchRrlfWV-He_tE
## 9                                                              qh7hdmqm4lzs85p704d6wsybgrpsly0j
## 10                Visit www.lenovo.com/think for information about Lenovo products and services
## 11                         google-site-verification=hxNSoF46anzjUtyFgpRVpzshTkYClFBJ7OAT3Dz6440
## 12     iHzQJvsKnyGP2Nm2qBgL3fyBJ0CC9z4GkY/flfk4EzLP8lPxWHDDPKqZWm1TkeF5kEIL+NotYOF1wo7JtUDXXw==
## 13                                                             ece42d7743c84d6889abda7011fe6f53

cname <- doh_post("dataassurance.pwc.com", "CNAME")
tidy(cname)
##                     name class type  ttl                   cname
## 1 dataassurance.pwc.com.     1    5 3600 f6759d2.x.incapdns.net.
##                     name class type ttl                   cname
## 1 dataassurance.pwc.com.     1    5 463 f6759d2.x.incapdns.net.
##                                                                                    rdata_raw
## 1 66, 36, 37, 35, 39, 64, 32, 2e, 78, 2e, 69, 6e, 63, 61, 70, 64, 6e, 73, 2e, 6e, 65, 74, 2e

ns <- doh_post("rud.is", "NS")
tidy(ns)
##      name class type   ttl          nsdname                                                      rdata_raw
## 1 rud.is.     1    2 43200 dns.mwebdns.net. 64, 6e, 73, 2e, 6d, 77, 65, 62, 64, 6e, 73, 2e, 6e, 65, 74, 2e
## 2 rud.is.     1    2 43200  dns.mwebdns.de.     64, 6e, 73, 2e, 6d, 77, 65, 62, 64, 6e, 73, 2e, 64, 65, 2e
## 3 rud.is.     1    2 43200  dns.mwebdns.eu.     64, 6e, 73, 2e, 6d, 77, 65, 62, 64, 6e, 73, 2e, 65, 75, 2e
## 1 rud.is.     1    2 40062 dns.mwebdns.net. 64, 6e, 73, 2e, 6d, 77, 65, 62, 64, 6e, 73, 2e, 6e, 65, 74, 2e
## 2 rud.is.     1    2 40062  dns.mwebdns.eu.     64, 6e, 73, 2e, 6d, 77, 65, 62, 64, 6e, 73, 2e, 65, 75, 2e
## 3 rud.is.     1    2 40062  dns.mwebdns.de.     64, 6e, 73, 2e, 6d, 77, 65, 62, 64, 6e, 73, 2e, 64, 65, 2e

soa <- doh_post("rud.is", "SOA")
tidy(soa)
##      name class type   ttl expire minimum           mname
## 1 rud.is.     1    6 43200 604800   86400 dns.mwebdns.de.
## 1 rud.is.     1    6 40063 604800   86400 dns.mwebdns.de.
##                                                                                                                                                                                                                                        rdata_raw
## 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, c0, 30, 77, ce, 5b, f3, 00, 00, 2a, 30, 00, 00, 0e, 10, 00, 09, 3a, 80, 00, 01, 51, 80
##   refresh retry                     rname     serial


@@ 383,18 385,103 @@ tidy(soa)
ptr <- doh_post(to_inaddr_arpa("104.244.13.104"), "PTR")
tidy(ptr)
##                           name class type   ttl                      ptrdname
## 1 104.13.244.104.in-addr.arpa.     1   12 43200 archive.farsightsecurity.com.
## 1 104.13.244.104.in-addr.arpa.     1   12 40063 archive.farsightsecurity.com.
##                                                                                                            rdata_raw
## 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
```

### If you *happen* to have a DNS wireformat record…

``` r
str(
  from_wireformat(
    as.raw(c(
      0x00, 0x00, 0x81, 0x80, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00,
      0x00, 0x00, 0x03, 0x77, 0x77, 0x77, 0x07, 0x65, 0x78, 0x61,
      0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00,
      0x01, 0x00, 0x01, 0x03, 0x77, 0x77, 0x77, 0x07, 0x65, 0x78,
      0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00,
      0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x04,
      0xC0, 0x00, 0x02, 0x01
    ))
  )
)
## List of 5
##  $ additional: list()
##  $ answer    :'data.frame':  1 obs. of  5 variables:
##   ..$ class: int 1
##   ..$ name : chr "www.example.com."
##   ..$ rdata:'data.frame':    1 obs. of  2 variables:
##   .. ..$ ipv4_address: chr "192.0.2.1"
##   .. ..$ rdata_raw   :List of 1
##   .. .. ..$ : int [1:4] 192 0 2 1
##   ..$ ttl  : int 128
##   ..$ type : int 1
##  $ authority : list()
##  $ header    :List of 15
##   ..$ aa     : int 0
##   ..$ ad     : int 0
##   ..$ ancount: int 1
##   ..$ arcount: int 0
##   ..$ cd     : int 0
##   ..$ id     : int 0
##   ..$ nscount: int 0
##   ..$ opcode : int 0
##   ..$ qdcount: int 1
##   ..$ qr     : int 1
##   ..$ ra     : int 1
##   ..$ rcode  : int 0
##   ..$ rd     : int 1
##   ..$ tc     : int 0
##   ..$ z      : int 0
##  $ question  :List of 3
##   ..$ qclass: int 1
##   ..$ qname : chr "www.example.com."
##   ..$ qtype : int 1

str(
  from_wireformat(
    as.raw(c(
      0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x03, 0x77, 0x77, 0x77, 0x07, 0x65, 0x78, 0x61,
      0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00,
      0x01, 0x00, 0x01
    ))
  )
)
## List of 5
##  $ additional: list()
##  $ answer    : list()
##  $ authority : list()
##  $ header    :List of 15
##   ..$ aa     : int 0
##   ..$ ad     : int 0
##   ..$ ancount: int 0
##   ..$ arcount: int 0
##   ..$ cd     : int 0
##   ..$ id     : int 0
##   ..$ nscount: int 0
##   ..$ opcode : int 0
##   ..$ qdcount: int 1
##   ..$ qr     : int 0
##   ..$ ra     : int 0
##   ..$ rcode  : int 0
##   ..$ rd     : int 1
##   ..$ tc     : int 0
##   ..$ z      : int 0
##  $ question  :List of 3
##   ..$ qclass: int 1
##   ..$ qname : chr "www.example.com."
##   ..$ qtype : int 1
```

## clandnstine Metrics

| Lang | \# Files |  (%) | LoC |  (%) | Blank lines |  (%) | \# Lines |  (%) |
| :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | ---: |
| R    |       20 | 0.80 | 686 | 0.49 |         188 | 0.40 |      373 | 0.60 |
| C++  |        4 | 0.16 | 681 | 0.49 |         220 | 0.47 |      163 | 0.26 |
| Rmd  |        1 | 0.04 |  37 | 0.03 |          58 | 0.12 |       81 | 0.13 |
| R    |       21 | 0.81 | 691 | 0.48 |         192 | 0.41 |      390 | 0.61 |
| C++  |        4 | 0.15 | 681 | 0.48 |         220 | 0.47 |      163 | 0.26 |
| Rmd  |        1 | 0.04 |  60 | 0.04 |          61 | 0.13 |       84 | 0.13 |

## Code of Conduct


A man/from_wireformat.Rd => man/from_wireformat.Rd +30 -0
@@ 0,0 1,30 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/from-wire.R
\name{from_wireformat}
\alias{from_wireformat}
\title{Convert a wireformat DNS records to an R list}
\usage{
from_wireformat(wf)
}
\arguments{
\item{wf}{DNS wireformat record as an R raw vector}
}
\value{
list
}
\description{
Convert a wireformat DNS records to an R list
}
\examples{
from_wireformat(
  as.raw(c(
    0x00, 0x00, 0x81, 0x80, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00,
    0x00, 0x00, 0x03, 0x77, 0x77, 0x77, 0x07, 0x65, 0x78, 0x61,
    0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00,
    0x01, 0x00, 0x01, 0x03, 0x77, 0x77, 0x77, 0x07, 0x65, 0x78,
    0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00,
    0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x04,
    0xC0, 0x00, 0x02, 0x01
  ))
)
}