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.

dkim.r 1.2KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #' #' Split out all SPF records in a domain's TXT record
  2. #' #'
  3. #' #' Given a vector of TXT records, this function will return a list of vectors
  4. #' #' of all the SPF records for each. If the given TXT record is not an SPF
  5. #' #' record, \code{NA} is returned (which makes it easy to skip with \code{purrr}
  6. #' #' functions).
  7. #' #'
  8. #' #' @param dkim_rec a character vector of DNS TXT records
  9. #' #' @export
  10. #' parse_dkim <- function(dkim_rec) {
  11. #' purrr::map_df(dkim_rec, .parse_dkim)
  12. #' }
  13. #'
  14. #' .parse_dkim <- function(dkim_rec) {
  15. #'
  16. #' if (has_dkim(dkim_rec)) {
  17. #' spf_rec <- stringi::stri_trim(stringi::stri_replace_all_regex(dkim_rec, '"', ""))
  18. #' recs <- stri_trim(unlist(stringi::stri_split_regex(dkim_rec, ";")))
  19. #' recs <- grep("v=DKIM1", recs, invert=TRUE, value=TRUE)
  20. #' purrr::keep(recs, stringi::stri_detect_fixed, "=") %>%
  21. #' purrr::map_df(~{
  22. #' x <- stringi::stri_match_all_regex(.x, "(.*)=(.*)")[[1]]
  23. #' data_frame(key=x[,2], value=x[,3])
  24. #' })
  25. #' } else {
  26. #' NULL
  27. #' }
  28. #'
  29. #' }
  30. #'
  31. #' #' Test for whether a DNS TXT record is a DKIM record
  32. #' #'
  33. #' #' @param spf_rec a character vector of DNS TXT records
  34. #' #' @export
  35. #' has_dkim <- function(dkim_rec) {
  36. #' grepl("v=DKIM1", dkim_rec)
  37. #' }