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

README.md 7.9KB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <!-- README.md is generated from README.Rmd. Please edit that file -->
  2. [![Travis-CI Build
  3. Status](https://travis-ci.org/hrbrmstr/gdns.svg?branch=master)](https://travis-ci.org/hrbrmstr/gdns)
  4. # gdns
  5. Tools to work with the Google DNS over HTTPS (DoH) API
  6. ## Description
  7. Traditional DNS queries and responses are sent over UDP or TCP without
  8. encryption. This is vulnerable to eavesdropping and spoofing (including
  9. DNS-based Internet filtering). Responses from recursive resolvers to
  10. clients are the most vulnerable to undesired or malicious changes, while
  11. communications between recursive resolvers and authoritative nameservers
  12. often incorporate additional protection.
  13. To address this problem, Google Public DNS offers DNS resolution over an
  14. encrypted HTTPS connection. DNS-over-HTTPS greatly enhances privacy and
  15. security between a client and a recursive resolver, and complements
  16. DNSSEC to provide end-to-end authenticated DNS lookups.
  17. More info at <https://developers.google.com/speed/public-dns/docs/doh/>.
  18. The following functions are implemented:
  19. Core:
  20. - `query` / `dig`: Perform DNS over HTTPS queries using Google
  21. - `bulk_query`: Vectorized query, returning only answers in a data
  22. frame
  23. - `as.data.frame`: Coerce a gdns query response answer to a data frame
  24. Helpers:
  25. - `has_spf`: Test for whether a DNS TXT record is an SPF record
  26. - `is_hard_fail`: SPF “all” type test
  27. - `is_soft_fail`: SPF “all” type test
  28. - `passes_all`: SPF “all” type test
  29. - `spf_exists`: SPF field extraction functions
  30. - `spf_includes`: SPF field extraction functions
  31. - `spf_ipv4s`: SPF field extraction functions
  32. - `spf_ipv6s`: SPF field extraction functions
  33. - `spf_ptrs`: SPF field extraction functions
  34. - `split_spf`: Split out all SPF records in a domain’s TXT record
  35. IANA Datasets:
  36. - `dns_classes`: DNS CLASSes (dataset)
  37. - `dns_glob_names`: Underscored and Globally Scoped DNS Node Names
  38. (dataset)
  39. - `dns_opcodes`: DNS OpCodes (dataset)
  40. - `dns_rcodes`: DNS RCODEs (dataset)
  41. - `edns0_option_codes`: DNS EDNS0 Option Codes (OPT) (dataset)
  42. - `rrtypes`: Resource Record (RR) TYPEs (dataset)
  43. ### Installation
  44. Any of the following:
  45. ``` r
  46. install("gdns", repos = "https://cinc.rud.is")
  47. devtools::install_git("https://git.rud.is/hrbrmstr/gdns")
  48. devtools::install_bitbucket("hrbrmstr/gdns")
  49. devtools::install_gitlab("hrbrmstr/gdns")
  50. devtools::install_github("hrbrmstr/gdns")
  51. ```
  52. ### Usage
  53. ``` r
  54. library(gdns)
  55. library(tibble) # for printing
  56. # current verison
  57. packageVersion("gdns")
  58. ```
  59. ## [1] '0.4.0'
  60. ``` r
  61. str(query("rud.is"))
  62. ```
  63. ## List of 11
  64. ## $ Status : int 0
  65. ## $ TC : logi FALSE
  66. ## $ RD : logi TRUE
  67. ## $ RA : logi TRUE
  68. ## $ AD : logi FALSE
  69. ## $ CD : logi FALSE
  70. ## $ Question :'data.frame': 1 obs. of 2 variables:
  71. ## ..$ name: chr "rud.is."
  72. ## ..$ type: int 1
  73. ## $ Answer :'data.frame': 1 obs. of 4 variables:
  74. ## ..$ name: chr "rud.is."
  75. ## ..$ type: int 1
  76. ## ..$ TTL : int 3599
  77. ## ..$ data: chr "172.93.49.183"
  78. ## $ Additional : list()
  79. ## $ edns_client_subnet: chr "0.0.0.0/0"
  80. ## $ Comment : chr "Response from 84.246.124.75."
  81. ## - attr(*, "class")= chr [1:2] "gdns_response" "list"
  82. ``` r
  83. query("rud.is") %>%
  84. as.data.frame()
  85. ```
  86. ## # A tibble: 1 x 6
  87. ## query qtype name type ttl data
  88. ## * <chr> <int> <chr> <int> <int> <chr>
  89. ## 1 rud.is. 1 rud.is. 1 3599 172.93.49.183
  90. ``` r
  91. str(dig("example.com", "255")) # "ANY" query
  92. ```
  93. ## List of 10
  94. ## $ Status : int 0
  95. ## $ TC : logi FALSE
  96. ## $ RD : logi TRUE
  97. ## $ RA : logi TRUE
  98. ## $ AD : logi TRUE
  99. ## $ CD : logi FALSE
  100. ## $ Question :'data.frame': 1 obs. of 2 variables:
  101. ## ..$ name: chr "example.com."
  102. ## ..$ type: int 255
  103. ## $ Answer :'data.frame': 18 obs. of 4 variables:
  104. ## ..$ name: chr [1:18] "example.com." "example.com." "example.com." "example.com." ...
  105. ## ..$ type: int [1:18] 6 46 46 46 46 46 46 46 46 47 ...
  106. ## ..$ TTL : int [1:18] 1533 19533 19533 1533 19533 19533 1533 1533 1533 1533 ...
  107. ## ..$ data: chr [1:18] "sns.dns.icann.org. noc.dns.icann.org. 2019041044 7200 3600 1209600 3600" "a 8 2 86400 1562528621 1560723663 23689 example.com. fdyvf2c+HYL8Qt9UXB+KLdnvuWyeE9U2i7pR9vnb59L6E7eBCxeGGZAVBf"| __truncated__ "ns 8 2 86400 1562498297 1560694863 23689 example.com. c2wn0Bz2Yb6T545v7f3O7XH8/gwRqPDlho6jtVNC9f7qL8lidsfTTpOPl"| __truncated__ "soa 8 2 3600 1562561021 1560759663 23689 example.com. icHLconr6/MiDdoLcVEFXErYXJ6XgZK+r/Q25Xu4sKKaKQhIgkDzeX+Fn"| __truncated__ ...
  108. ## $ Additional : list()
  109. ## $ edns_client_subnet: chr "0.0.0.0/0"
  110. ## - attr(*, "class")= chr [1:2] "gdns_response" "list"
  111. ``` r
  112. query("microsoft.com", "MX") %>%
  113. as.data.frame()
  114. ```
  115. ## # A tibble: 1 x 6
  116. ## query qtype name type ttl data
  117. ## * <chr> <int> <chr> <int> <int> <chr>
  118. ## 1 microsoft.com. 15 microsoft.com. 15 2904 10 microsoft-com.mail.protection.outlook.com.
  119. ``` r
  120. as.data.frame(query("apple.com"))
  121. ```
  122. ## # A tibble: 3 x 6
  123. ## query qtype name type ttl data
  124. ## * <chr> <int> <chr> <int> <int> <chr>
  125. ## 1 apple.com. 1 apple.com. 1 3274 17.172.224.47
  126. ## 2 apple.com. 1 apple.com. 1 3274 17.178.96.59
  127. ## 3 apple.com. 1 apple.com. 1 3274 17.142.160.59
  128. ``` r
  129. as.data.frame(dig("17.142.160.59", "PTR"))
  130. ```
  131. ## # A tibble: 5 x 6
  132. ## query qtype name type ttl data
  133. ## * <chr> <int> <chr> <int> <int> <chr>
  134. ## 1 59.160.142.17.in-addr.arpa. 12 59.160.142.17.in-addr.arpa. 12 102 appleid.org.
  135. ## 2 59.160.142.17.in-addr.arpa. 12 59.160.142.17.in-addr.arpa. 12 102 apple.by.
  136. ## 3 59.160.142.17.in-addr.arpa. 12 59.160.142.17.in-addr.arpa. 12 102 apple.com.
  137. ## 4 59.160.142.17.in-addr.arpa. 12 59.160.142.17.in-addr.arpa. 12 102 ipad.host.
  138. ## 5 59.160.142.17.in-addr.arpa. 12 59.160.142.17.in-addr.arpa. 12 102 pv-apple-com.apple.com.
  139. ``` r
  140. hosts <- c("rud.is", "dds.ec", "r-project.org", "rstudio.com", "apple.com")
  141. gdns::bulk_query(hosts)
  142. ```
  143. ## # A tibble: 7 x 7
  144. ## query qtype name type ttl data entity
  145. ## <chr> <int> <chr> <int> <int> <chr> <chr>
  146. ## 1 rud.is. 1 rud.is. 1 3598 172.93.49.183 rud.is
  147. ## 2 dds.ec. 1 dds.ec. 1 599 185.53.178.9 dds.ec
  148. ## 3 r-project.org. 1 r-project.org. 1 4469 137.208.57.37 r-project.org
  149. ## 4 rstudio.com. 1 rstudio.com. 1 3599 104.196.200.5 rstudio.com
  150. ## 5 apple.com. 1 apple.com. 1 2137 17.172.224.47 apple.com
  151. ## 6 apple.com. 1 apple.com. 1 2137 17.178.96.59 apple.com
  152. ## 7 apple.com. 1 apple.com. 1 2137 17.142.160.59 apple.com
  153. ## gdns Metrics
  154. | Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) |
  155. | :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | ---: |
  156. | R | 14 | 0.93 | 384 | 0.94 | 118 | 0.77 | 314 | 0.85 |
  157. | Rmd | 1 | 0.07 | 26 | 0.06 | 35 | 0.23 | 54 | 0.15 |
  158. ## Code of Conduct
  159. Please note that this project is released with a [Contributor Code of
  160. Conduct](CONDUCT.md). By participating in this project you agree to
  161. abide by its terms.