@ -0,0 +1,88 @@ | |||
rr_types <- c( | |||
a = 1, | |||
ns = 2, | |||
md = 3, | |||
mf = 4, | |||
cname = 5, | |||
soa = 6, | |||
mb = 7, | |||
mg = 8, | |||
mr = 9, | |||
null = 10, | |||
wks = 11, | |||
ptr = 12, | |||
hinfo = 13, | |||
minfo = 14, | |||
mx = 15, | |||
txt = 16, | |||
rp = 17, | |||
afsdb = 18, | |||
x25 = 19, | |||
isdn = 20, | |||
rt = 21, | |||
nsap = 22, | |||
nsap_ptr = 23, | |||
sig = 24, | |||
key = 25, | |||
px = 26, | |||
gpos = 27, | |||
aaaa = 28, | |||
loc = 29, | |||
nxt = 30, | |||
eid = 31, | |||
nimloc = 32, | |||
srv = 33, | |||
atma = 34, | |||
naptr = 35, | |||
kx = 36, | |||
cert = 37, | |||
a6 = 38, | |||
dname = 39, | |||
sink = 40, | |||
opt = 41, | |||
apl = 42, | |||
ds = 43, | |||
sshfp = 44, | |||
ipseckey = 45, | |||
rrsig = 46, | |||
nsec = 47, | |||
dnskey = 48, | |||
dhcid = 49, | |||
nsec3 = 50, | |||
nsec3param = 51, | |||
tlsa = 52, | |||
smimea = 53, | |||
hip = 55, | |||
ninfo = 56, | |||
rkey = 57, | |||
talink = 58, | |||
cds = 59, | |||
cdnskey = 60, | |||
openpgpkey = 61, | |||
csync = 62, | |||
zonemd = 63, | |||
spf = 99, | |||
uinfo = 100, | |||
uid = 101, | |||
gid = 102, | |||
unspec = 103, | |||
nid = 104, | |||
l32 = 105, | |||
l64 = 106, | |||
lp = 107, | |||
eui48 = 108, | |||
eui64 = 109, | |||
tkey = 249, | |||
tsig = 250, | |||
ixfr = 251, | |||
axfr = 252, | |||
mailb = 253, | |||
maila = 254, | |||
any = 255, | |||
uri = 256, | |||
caa = 257, | |||
avc = 258, | |||
doa = 259, | |||
ta = 32768, | |||
dlv = 32769 | |||
) |
@ -0,0 +1,128 @@ | |||
#' Create a gdns DNS over TLS context and populate it with a resolver | |||
#' for use in resolution functions | |||
#' | |||
#' @param resolver character vector of valid DNS over TLS resolvers; | |||
#' Defaults to Quad9 (`9.9.9.9`). | |||
#' @export | |||
#' @examples | |||
#' x <- gdns_resolver() | |||
#' x <- gdns_resolver("1.1.1.1") | |||
gdns_resolver <- function(resolvers = "9.9.9.9") { | |||
int_gdns_resolver(resolvers) | |||
} | |||
#' Arbitrary DNS queries | |||
#' | |||
#' Perform any valid resource record inquiry for a given name. See `Details`. | |||
#' | |||
#' This returns a fairly complex result object but that is the nature | |||
#' of DNS queries. You're likely going to want what is in `$replies_tree$answer` | |||
#' but the rest of the structure contains lovely metadata about the query and | |||
#' remote query environment. There will eventually be "as data frame"-ish helpers | |||
#' for this object. | |||
#' | |||
#' Valid values for `rr_type`: | |||
#' - `a` | |||
#' - `a6` | |||
#' - `aaaa` | |||
#' - `afsdb` | |||
#' - `any` | |||
#' - `apl` | |||
#' - `atma` | |||
#' - `avc` | |||
#' - `axfr` | |||
#' - `caa` | |||
#' - `cdnskey` | |||
#' - `cds` | |||
#' - `cert` | |||
#' - `cname` | |||
#' - `csync` | |||
#' - `dhcid` | |||
#' - `dlv` | |||
#' - `dname` | |||
#' - `dnskey` | |||
#' - `doa` | |||
#' - `ds` | |||
#' - `eid` | |||
#' - `eui48` | |||
#' - `eui64` | |||
#' - `gid` | |||
#' - `gpos` | |||
#' - `hinfo` | |||
#' - `hip` | |||
#' - `ipseckey` | |||
#' - `isdn` | |||
#' - `ixfr` | |||
#' - `key` | |||
#' - `kx` | |||
#' - `l32` | |||
#' - `l64` | |||
#' - `loc` | |||
#' - `lp` | |||
#' - `maila` | |||
#' - `mailb` | |||
#' - `mb` | |||
#' - `md` | |||
#' - `mf` | |||
#' - `mg` | |||
#' - `minfo` | |||
#' - `mr` | |||
#' - `mx` | |||
#' - `naptr` | |||
#' - `nid` | |||
#' - `nimloc` | |||
#' - `ninfo` | |||
#' - `ns` | |||
#' - `nsap` | |||
#' - `nsap_ptr` | |||
#' - `nsec` | |||
#' - `nsec3` | |||
#' - `nsec3param` | |||
#' - `null` | |||
#' - `nxt` | |||
#' - `openpgpkey` | |||
#' - `opt` | |||
#' - `ptr` | |||
#' - `px` | |||
#' - `rkey` | |||
#' - `rp` | |||
#' - `rrsig` | |||
#' - `rt` | |||
#' - `sig` | |||
#' - `sink` | |||
#' - `smimea` | |||
#' - `soa` | |||
#' - `spf` | |||
#' - `srv` | |||
#' - `sshfp` | |||
#' - `ta` | |||
#' - `talink` | |||
#' - `tkey` | |||
#' - `tlsa` | |||
#' - `tsig` | |||
#' - `txt` | |||
#' - `uid` | |||
#' - `uinfo` | |||
#' - `unspec` | |||
#' - `uri` | |||
#' - `wks` | |||
#' - `x25` | |||
#' - `zonemd` | |||
#' | |||
#' @references <https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml> | |||
#' @export | |||
#' @examples | |||
#' x <- gdns_resolver() | |||
#' gdns_query(x, "example.com") | |||
gdns_query <- function(gcx, name, rr_type = "txt") { | |||
rr_type <- match.arg(trimws(tolower(rr_type[1])), names(rr_types)) | |||
res <- int_gdns_query(gcx, name, unname(as.integer(rr_types[rr_type]))) | |||
if (length(res)) { | |||
out <- jsonlite::fromJSON(res) | |||
out | |||
} else { | |||
NULL | |||
} | |||
} |
@ -0,0 +1,11 @@ | |||
% Generated by roxygen2: do not edit by hand | |||
% Please edit documentation in R/RcppExports.R | |||
\name{gdns_lib_version} | |||
\alias{gdns_lib_version} | |||
\title{Return gdns library version} | |||
\usage{ | |||
gdns_lib_version() | |||
} | |||
\description{ | |||
Return gdns library version | |||
} |
@ -0,0 +1,115 @@ | |||
% Generated by roxygen2: do not edit by hand | |||
% Please edit documentation in R/resolver.R | |||
\name{gdns_query} | |||
\alias{gdns_query} | |||
\title{Arbitrary DNS queries} | |||
\usage{ | |||
gdns_query(gcx, name, rr_type = "txt") | |||
} | |||
\description{ | |||
Perform any valid resource record inquiry for a given name. See \code{Details}. | |||
} | |||
\details{ | |||
This returns a fairly complex result object but that is the nature | |||
of DNS queries. You're likely going to want what is in \code{$replies_tree$answer} | |||
but the rest of the structure contains lovely metadata about the query and | |||
remote query environment. There will eventually be "as data frame"-ish helpers | |||
for this object. | |||
Valid values for \code{rr_type}: | |||
\itemize{ | |||
\item \code{a} | |||
\item \code{a6} | |||
\item \code{aaaa} | |||
\item \code{afsdb} | |||
\item \code{any} | |||
\item \code{apl} | |||
\item \code{atma} | |||
\item \code{avc} | |||
\item \code{axfr} | |||
\item \code{caa} | |||
\item \code{cdnskey} | |||
\item \code{cds} | |||
\item \code{cert} | |||
\item \code{cname} | |||
\item \code{csync} | |||
\item \code{dhcid} | |||
\item \code{dlv} | |||
\item \code{dname} | |||
\item \code{dnskey} | |||
\item \code{doa} | |||
\item \code{ds} | |||
\item \code{eid} | |||
\item \code{eui48} | |||
\item \code{eui64} | |||
\item \code{gid} | |||
\item \code{gpos} | |||
\item \code{hinfo} | |||
\item \code{hip} | |||
\item \code{ipseckey} | |||
\item \code{isdn} | |||
\item \code{ixfr} | |||
\item \code{key} | |||
\item \code{kx} | |||
\item \code{l32} | |||
\item \code{l64} | |||
\item \code{loc} | |||
\item \code{lp} | |||
\item \code{maila} | |||
\item \code{mailb} | |||
\item \code{mb} | |||
\item \code{md} | |||
\item \code{mf} | |||
\item \code{mg} | |||
\item \code{minfo} | |||
\item \code{mr} | |||
\item \code{mx} | |||
\item \code{naptr} | |||
\item \code{nid} | |||
\item \code{nimloc} | |||
\item \code{ninfo} | |||
\item \code{ns} | |||
\item \code{nsap} | |||
\item \code{nsap_ptr} | |||
\item \code{nsec} | |||
\item \code{nsec3} | |||
\item \code{nsec3param} | |||
\item \code{null} | |||
\item \code{nxt} | |||
\item \code{openpgpkey} | |||
\item \code{opt} | |||
\item \code{ptr} | |||
\item \code{px} | |||
\item \code{rkey} | |||
\item \code{rp} | |||
\item \code{rrsig} | |||
\item \code{rt} | |||
\item \code{sig} | |||
\item \code{sink} | |||
\item \code{smimea} | |||
\item \code{soa} | |||
\item \code{spf} | |||
\item \code{srv} | |||
\item \code{sshfp} | |||
\item \code{ta} | |||
\item \code{talink} | |||
\item \code{tkey} | |||
\item \code{tlsa} | |||
\item \code{tsig} | |||
\item \code{txt} | |||
\item \code{uid} | |||
\item \code{uinfo} | |||
\item \code{unspec} | |||
\item \code{uri} | |||
\item \code{wks} | |||
\item \code{x25} | |||
\item \code{zonemd} | |||
} | |||
} | |||
\examples{ | |||
x <- gdns_resolver() | |||
gdns_query(x, "example.com") | |||
} | |||
\references{ | |||
\url{https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml} | |||
} |
@ -1,21 +0,0 @@ | |||
% Generated by roxygen2: do not edit by hand | |||
% Please edit documentation in R/RcppExports.R | |||
\name{get_address} | |||
\alias{get_address} | |||
\title{Lookup IP Address(es) for a Given Host} | |||
\usage{ | |||
get_address(host, resolver = "9.9.9.9") | |||
} | |||
\arguments{ | |||
\item{host}{host (length 1 <chr>)} | |||
\item{resolver}{resolver address. defaults to Quad9; (length 1 <chr>)} | |||
} | |||
\description{ | |||
Lookup IP Address(es) for a Given Host | |||
} | |||
\examples{ | |||
get_address("r-project.org") | |||
get_address("yahoo.com", "1.1.1.1") | |||
get_address("microsoft.com", "8.8.8.8") | |||
} |
@ -0,0 +1,12 @@ | |||
% Generated by roxygen2: do not edit by hand | |||
% Please edit documentation in R/RcppExports.R | |||
\name{int_gdns_resolver} | |||
\alias{int_gdns_resolver} | |||
\title{Internal version of gdns_resolver} | |||
\usage{ | |||
int_gdns_resolver(resolvers) | |||
} | |||
\description{ | |||
Internal version of gdns_resolver | |||
} | |||
\keyword{internal} |
@ -1,7 +1,25 @@ | |||
context("basic wrapper works") | |||
test_that("we can do something", { | |||
test_that("basic wrapper works", { | |||
x <- get_address("example.com") | |||
expect_is(gdns_lib_version(), "character") | |||
r <- gdns_resolver() | |||
x <- gdns_get_address(r, "example.com") | |||
expect_true(all(c("2606:2800:220:1:248:1893:25c8:1946", "93.184.216.34") %in% x)) | |||
r <- gdns_resolver(c("8.8.8.8", "1.1.1.1", "9.9.9.9")) | |||
x <- gdns_get_address(r, "example.com") | |||
expect_true(all(c("2606:2800:220:1:248:1893:25c8:1946", "93.184.216.34") %in% x)) | |||
x <- gdns_get_address(r, "example.commm") | |||
expect_length(x, 0) | |||
x <- gdns_query(r, "example.com", "txt") | |||
expect_equal(x$answer_type, 800) | |||
expect_equal(x$canonical_name, "example.com.") | |||
expect_true(grepl("spf", unlist(x$replies_tree$answer[[1]]$rdata$txt_strings))) | |||
}) |