No Description
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.

resolver.R 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #' Create a gdns DNS over TLS context and populate it with a resolver
  2. #' for use in resolution functions
  3. #'
  4. #' @param resolver character vector of valid DNS over TLS resolvers;
  5. #' Defaults to Quad9 (`9.9.9.9`).
  6. #' @export
  7. #' @examples
  8. #' x <- gdns_resolver()
  9. #' x <- gdns_resolver("1.1.1.1")
  10. gdns_resolver <- function(resolvers = "9.9.9.9") {
  11. int_gdns_resolver(resolvers)
  12. }
  13. #' Arbitrary DNS queries
  14. #'
  15. #' Perform any valid resource record inquiry for a given name. See `Details`.
  16. #'
  17. #' This returns a fairly complex result object but that is the nature
  18. #' of DNS queries. You're likely going to want what is in `$replies_tree$answer`
  19. #' but the rest of the structure contains lovely metadata about the query and
  20. #' remote query environment. There will eventually be "as data frame"-ish helpers
  21. #' for this object.
  22. #'
  23. #' Valid values for `rr_type`:
  24. #' - `a`
  25. #' - `a6`
  26. #' - `aaaa`
  27. #' - `afsdb`
  28. #' - `any`
  29. #' - `apl`
  30. #' - `atma`
  31. #' - `avc`
  32. #' - `axfr`
  33. #' - `caa`
  34. #' - `cdnskey`
  35. #' - `cds`
  36. #' - `cert`
  37. #' - `cname`
  38. #' - `csync`
  39. #' - `dhcid`
  40. #' - `dlv`
  41. #' - `dname`
  42. #' - `dnskey`
  43. #' - `doa`
  44. #' - `ds`
  45. #' - `eid`
  46. #' - `eui48`
  47. #' - `eui64`
  48. #' - `gid`
  49. #' - `gpos`
  50. #' - `hinfo`
  51. #' - `hip`
  52. #' - `ipseckey`
  53. #' - `isdn`
  54. #' - `ixfr`
  55. #' - `key`
  56. #' - `kx`
  57. #' - `l32`
  58. #' - `l64`
  59. #' - `loc`
  60. #' - `lp`
  61. #' - `maila`
  62. #' - `mailb`
  63. #' - `mb`
  64. #' - `md`
  65. #' - `mf`
  66. #' - `mg`
  67. #' - `minfo`
  68. #' - `mr`
  69. #' - `mx`
  70. #' - `naptr`
  71. #' - `nid`
  72. #' - `nimloc`
  73. #' - `ninfo`
  74. #' - `ns`
  75. #' - `nsap`
  76. #' - `nsap_ptr`
  77. #' - `nsec`
  78. #' - `nsec3`
  79. #' - `nsec3param`
  80. #' - `null`
  81. #' - `nxt`
  82. #' - `openpgpkey`
  83. #' - `opt`
  84. #' - `ptr`
  85. #' - `px`
  86. #' - `rkey`
  87. #' - `rp`
  88. #' - `rrsig`
  89. #' - `rt`
  90. #' - `sig`
  91. #' - `sink`
  92. #' - `smimea`
  93. #' - `soa`
  94. #' - `spf`
  95. #' - `srv`
  96. #' - `sshfp`
  97. #' - `ta`
  98. #' - `talink`
  99. #' - `tkey`
  100. #' - `tlsa`
  101. #' - `tsig`
  102. #' - `txt`
  103. #' - `uid`
  104. #' - `uinfo`
  105. #' - `unspec`
  106. #' - `uri`
  107. #' - `wks`
  108. #' - `x25`
  109. #' - `zonemd`
  110. #'
  111. #' @references <https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml>
  112. #' @export
  113. #' @examples
  114. #' x <- gdns_resolver()
  115. #' gdns_query(x, "example.com")
  116. gdns_query <- function(gcx, name, rr_type = "txt") {
  117. rr_type <- match.arg(trimws(tolower(rr_type[1])), names(rr_types))
  118. res <- int_gdns_query(gcx, name, unname(as.integer(rr_types[rr_type])))
  119. if (length(res)) {
  120. out <- jsonlite::fromJSON(res)
  121. out
  122. } else {
  123. NULL
  124. }
  125. }