Przeglądaj źródła

more rrs hnadled in printing; query context can be null

master
boB Rudis 5 lat temu
rodzic
commit
cd8519507d
Nie znaleziono w bazie danych klucza dla tego podpisu ID klucza GPG: 1D7529BE14E2BBA9
  1. 3
      DESCRIPTION
  2. 2
      NAMESPACE
  3. 2
      R/aaa.R
  4. 1
      R/clandnstine-package.R
  5. 7
      R/is.R
  6. 47
      R/resolver.R
  7. 6
      man/gdns_query.Rd
  8. 14
      man/is_gctx.Rd

3
DESCRIPTION

@ -23,7 +23,8 @@ Depends:
Imports:
jsonlite,
Rcpp,
magrittr
magrittr,
glue
Roxygen: list(markdown = TRUE)
RoxygenNote: 6.1.1
LinkingTo:

2
NAMESPACE

@ -23,7 +23,9 @@ export(gdns_set_tls_ca_file)
export(gdns_set_tls_ca_path)
export(gdns_set_transports)
export(gdns_update_resolvers)
export(is_gctx)
importFrom(Rcpp,sourceCpp)
importFrom(glue,glue_data)
importFrom(jsonlite,fromJSON)
importFrom(magrittr,"%>%")
useDynLib(clandnstine, .registration = TRUE)

2
R/aaa.R

@ -89,4 +89,4 @@ ta = 32768,
dlv = 32769
)
rr_types_rev <- set_names(names(rr_types), as.character(rr_types))
rr_types_rev <- set_names(names(rr_types), as.character(rr_types))

1
R/clandnstine-package.R

@ -11,6 +11,7 @@
#' @docType package
#' @author Bob Rudis (bob@@rud.is)
#' @keywords internal
#' @importFrom glue glue_data
#' @importFrom jsonlite fromJSON
#' @useDynLib clandnstine, .registration = TRUE
#' @importFrom Rcpp sourceCpp

7
R/is.R

@ -0,0 +1,7 @@
#' Test whether an object is a `gctx` context
#'
#' @param x object
#' @export
is_gctx <- function(x) {
inherits(x, "gctx")
}

47
R/resolver.R

@ -45,7 +45,6 @@ gdns_set_hosts<- function(gctx, hosts_file) {
int_gdns_set_hosts(gctx, hosts_file)
}
#' Retrieve the list of addresses in use for looking up top-level domains in use by the context.
#'
#' @param gctx gdns resolver context created with [gdns_resolver()]
@ -157,7 +156,9 @@ gdns_get_root_servers <- function(gctx) {
#' - `zonemd`
#'
#' @note Local hosts files are ignored when using this `getdns` API endpoint
#' @param gctx gdns resolver context created with [gdns_resolver()]
#' @param gctx gdns resolver context created with [gdns_resolver()]. If `NULL` a
#' temporary context will be created but is not ideal since there is overhead
#' associated with context creation and garbage collection.
#' @param name an entity to query for
#' @param rr_type what resource record type do you want to queyr for? See `Details`.
#' @param include_reporting if `TRUE` include debugging information for queries
@ -168,9 +169,13 @@ gdns_get_root_servers <- function(gctx) {
#' @examples
#' x <- gdns_resolver()
#' gdns_query(x, "example.com")
gdns_query <- function(gctx, name, rr_type = "txt", rr_class = 1L,
gdns_query <- function(gctx = NULL, name, rr_type = "txt", rr_class = 1L,
include_reporting = FALSE) {
if (is.null(gctx)) gctx <- gdns_context()
stopifnot(is_gctx(gctx))
rr_class <- rr_class[1]
if (!rr_class %in% c(1, 3, 4, 254, 255)) rr_class <- 1
@ -187,21 +192,6 @@ gdns_query <- function(gctx, name, rr_type = "txt", rr_class = 1L,
}
list(
`1` = "ipv4_address",
`2` = "nsdname",
`6` = c("expire", "minimum", "mname", "refresh", "retry", "rname", "serial"),
`16` = "txt_strings",
`28` = "ipv6_address",
`43` = c("algorithm", "digest", "digest_type", "key_tag"),
`46` = c(
"algorithm", "key_tag", "labels", "original_ttl", "signature",
"signature_expiration", "signature_inception", "signers_name", "type_covered"
),
`47` = c("next_domain_name", "type_bit_maps"),
`48` = c("algorithm", "flags", "protocol", "public_key")
) -> rr_fields
#' Printer for gdns_response objects
#'
#' @param x a `gdns_response` object
@ -230,6 +220,20 @@ print.gdns_response <- function(x, ...) {
"\n", sep=""
)
},
"2" ={
cat(
"Answer: ",
paste0(ans$rdata$nsdname, collapse=", "),
"\n", sep=""
)
},
"15" = {
cat(
"Answer: \n",
paste0(glue::glue_data(ans$rdata, "{preference} {exchange}"), collapse="\n"),
"\n", sep=""
)
},
"16" = {
rd <- ans$rdata
typs <- ans$type
@ -249,6 +253,13 @@ print.gdns_response <- function(x, ...) {
"\n", sep=""
)
},
"257" = {
cat(
"Answer: \n",
paste0(glue::glue_data(ans$rdata, "{flags} {tag} {value}"), collapse="\n"),
"\n", sep=""
)
},
{
print(str(ans$rdata, give.attr = FALSE))
}

6
man/gdns_query.Rd

@ -4,11 +4,13 @@
\alias{gdns_query}
\title{Arbitrary DNS queries}
\usage{
gdns_query(gctx, name, rr_type = "txt", rr_class = 1L,
gdns_query(gctx = NULL, name, rr_type = "txt", rr_class = 1L,
include_reporting = FALSE)
}
\arguments{
\item{gctx}{gdns resolver context created with \code{\link[=gdns_resolver]{gdns_resolver()}}}
\item{gctx}{gdns resolver context created with \code{\link[=gdns_resolver]{gdns_resolver()}}. If \code{NULL} a
temporary context will be created but is not ideal since there is overhead
associated with context creation and garbage collection.}
\item{name}{an entity to query for}

14
man/is_gctx.Rd

@ -0,0 +1,14 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/is.R
\name{is_gctx}
\alias{is_gctx}
\title{Test whether an object is a \code{gctx} context}
\usage{
is_gctx(x)
}
\arguments{
\item{x}{object}
}
\description{
Test whether an object is a \code{gctx} context
}
Ładowanie…
Anuluj
Zapisz