14 changed files with 346 additions and 6 deletions
@ -1,2 +1,7 @@ |
|||
^.*\.Rproj$ |
|||
^\.Rproj\.user$ |
|||
^README\.Rmd$ |
|||
^README-.*\.png$ |
|||
^\.travis\.yml$ |
|||
^CONDUCT\.md$ |
|||
^README\.md$ |
|||
|
@ -0,0 +1,5 @@ |
|||
# Sample .travis.yml for R projects |
|||
|
|||
language: r |
|||
warnings_are_errors: true |
|||
sudo: required |
@ -0,0 +1,25 @@ |
|||
# Contributor Code of Conduct |
|||
|
|||
As contributors and maintainers of this project, we pledge to respect all people who |
|||
contribute through reporting issues, posting feature requests, updating documentation, |
|||
submitting pull requests or patches, and other activities. |
|||
|
|||
We are committed to making participation in this project a harassment-free experience for |
|||
everyone, regardless of level of experience, gender, gender identity and expression, |
|||
sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. |
|||
|
|||
Examples of unacceptable behavior by participants include the use of sexual language or |
|||
imagery, derogatory comments or personal attacks, trolling, public or private harassment, |
|||
insults, or other unprofessional conduct. |
|||
|
|||
Project maintainers have the right and responsibility to remove, edit, or reject comments, |
|||
commits, code, wiki edits, issues, and other contributions that are not aligned to this |
|||
Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed |
|||
from the project team. |
|||
|
|||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by |
|||
opening an issue or contacting one or more of the project maintainers. |
|||
|
|||
This Code of Conduct is adapted from the Contributor Covenant |
|||
(http:contributor-covenant.org), version 1.0.0, available at |
|||
http://contributor-covenant.org/version/1/0/0/ |
@ -1,8 +1,18 @@ |
|||
Package: gdns |
|||
Title: What the Package Does (one line, title case) |
|||
Version: 0.0.0.9000 |
|||
Title: Tools to Work with Google DNS Over https API |
|||
Version: 0.1.0.9000 |
|||
Authors@R: c(person("Bob", "Rudis", email = "bob@rudis.net", role = c("aut", "cre"))) |
|||
Description: What the package does (one paragraph). |
|||
Depends: R (>= 3.2.4) |
|||
Maintainer: Bob Rudis <bob@rudis.net> |
|||
Description: Tools to Work with Google DNS Over https API |
|||
License: AGPL + file LICENSE |
|||
LazyData: true |
|||
Encoding: UTF-8 |
|||
Depends: |
|||
R (>= 3.0.0) |
|||
Suggests: |
|||
testthat |
|||
Imports: |
|||
httr, |
|||
jsonlite, |
|||
purrr |
|||
RoxygenNote: 5.0.1 |
|||
|
@ -1,2 +1,6 @@ |
|||
# Generated by roxygen2: fake comment so roxygen2 overwrites silently. |
|||
exportPattern("^[^\\.]") |
|||
# Generated by roxygen2: do not edit by hand |
|||
|
|||
export(query) |
|||
import(httr) |
|||
importFrom(jsonlite,fromJSON) |
|||
importFrom(purrr,safely) |
|||
|
@ -0,0 +1,21 @@ |
|||
#' Tools to Work with Google DNS Over https API |
|||
#' |
|||
#' Traditional DNS queries and responses are sent over UDP or TCP without |
|||
#' encryption. This is vulnerable to eavesdropping and spoofing (including |
|||
#' DNS-based Internet filtering). Responses from recursive resolvers to clients |
|||
#' are the most vulnerable to undesired or malicious changes, while |
|||
#' communications between recursive resolvers and authoritative nameservers |
|||
#' often incorporate additional protection.\cr |
|||
#' \cr |
|||
#' To address this problem, Google Public DNS offers DNS resolution over an |
|||
#' encrypted HTTPS connection. DNS-over-HTTPS greatly enhances privacy and |
|||
#' security between a client and a recursive resolver, and complements DNSSEC |
|||
#' to provide end-to-end authenticated DNS lookups.#' |
|||
#' |
|||
#' @name gdns |
|||
#' @docType package |
|||
#' @author Bob Rudis (@@hrbrmstr) |
|||
#' @import httr |
|||
#' @importFrom jsonlite fromJSON |
|||
#' @importFrom purrr safely |
|||
NULL |
@ -0,0 +1,50 @@ |
|||
S_GET <- purrr::safely(GET) |
|||
|
|||
#' Perform DNS over HTTPS queries using Google |
|||
#' |
|||
#' Traditional DNS queries and responses are sent over UDP or TCP without |
|||
#' encryption. This is vulnerable to eavesdropping and spoofing (including |
|||
#' DNS-based Internet filtering). Responses from recursive resolvers to clients |
|||
#' are the most vulnerable to undesired or malicious changes, while |
|||
#' communications between recursive resolvers and authoritative nameservers |
|||
#' often incorporate additional protection.\cr |
|||
#' \cr |
|||
#' To address this problem, Google Public DNS offers DNS resolution over an |
|||
#' encrypted HTTPS connection. DNS-over-HTTPS greatly enhances privacy and |
|||
#' security between a client and a recursive resolver, and complements DNSSEC |
|||
#' to provide end-to-end authenticated DNS lookups. |
|||
#' |
|||
#' @param name item to lookup. Valid characters are numbers, letters, hyphen, and dot. Length |
|||
#' must be between 1 and 255. Names with escaped or non-ASCII characters |
|||
#' are not supported. Internationalized domain names must use the |
|||
#' punycode format (e.g. "\code{xn--qxam}" rather than "\code{ελ}") |
|||
#' @param type RR type can be represented as a number in [1, 65535] or canonical |
|||
#' string (A, aaaa, etc.) |
|||
#' @param edns_client_subnet The edns0-client-subnet option. Format is an IP |
|||
#' address with a subnet mask. Examples: \code{1.2.3.4/24}, |
|||
#' \code{2001:700:300::/48}.\cr |
|||
#' If you are using DNS-over-HTTPS because of privacy concerns, and do |
|||
#' not want any part of your IP address to be sent to authoritative |
|||
#' nameservers for geographic location accuracy, use |
|||
#' \code{edns_client_subnet=0.0.0.0/0}. Google Public DNS normally sends |
|||
#' approximate network information (usually replacing the last part of |
|||
#' your IPv4 address with zeroes). |
|||
#' @return a \code{list} with the query result or \code{NULL} if an error occurred |
|||
#' @export |
|||
#' @examples |
|||
#' query("rud.is") |
|||
query <- function(name, type="1", cd=FALSE, edns_client_subnet=NULL) { |
|||
|
|||
res <- S_GET("https://dns.google.com/resolve", |
|||
query=list(name=name, |
|||
type=type, |
|||
edns_client_subnet=edns_client_subnet)) |
|||
|
|||
if (!is.null(res$result)) { |
|||
stop_for_status(res$result) |
|||
jsonlite::fromJSON(httr::content(res$result, as="text")) |
|||
} else { |
|||
NULL |
|||
} |
|||
|
|||
} |
@ -0,0 +1,67 @@ |
|||
--- |
|||
output: |
|||
md_document: |
|||
variant: markdown_github |
|||
--- |
|||
|
|||
<!-- README.md is generated from README.Rmd. Please edit that file --> |
|||
|
|||
```{r, echo = FALSE} |
|||
knitr::opts_chunk$set( |
|||
collapse = TRUE, |
|||
comment = "#>", |
|||
fig.path = "README-" |
|||
) |
|||
``` |
|||
|
|||
`gdns` : Tools to work with the Google DNS over HTTPS API |
|||
|
|||
The following functions are implemented: |
|||
|
|||
- `query` : perform the DNS query |
|||
|
|||
### News |
|||
|
|||
- Version 0.1.0.9000 released |
|||
|
|||
### Installation |
|||
|
|||
```{r eval=FALSE} |
|||
devtools::install_github("hrbrmstr/gdns") |
|||
``` |
|||
|
|||
```{r echo=FALSE, message=FALSE, warning=FALSE, error=FALSE} |
|||
options(width=120) |
|||
``` |
|||
|
|||
### Usage |
|||
|
|||
```{r} |
|||
library(gdns) |
|||
|
|||
# current verison |
|||
packageVersion("gdns") |
|||
|
|||
``` |
|||
|
|||
### Test Results |
|||
|
|||
```{r} |
|||
library(gdns) |
|||
library(testthat) |
|||
|
|||
date() |
|||
|
|||
test_dir("tests/") |
|||
|
|||
library(purrr) |
|||
|
|||
hosts <- c("rud.is", "dds.ec", "r-project.org", "rstudio.com") |
|||
results <- map(hosts, gdns::query) |
|||
map_df(results, "Answer") |
|||
``` |
|||
|
|||
### Code of Conduct |
|||
|
|||
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). |
|||
By participating in this project you agree to abide by its terms. |
@ -0,0 +1,63 @@ |
|||
<!-- README.md is generated from README.Rmd. Please edit that file --> |
|||
`gdns` : Tools to work with the Google DNS over HTTPS API |
|||
|
|||
The following functions are implemented: |
|||
|
|||
- `query` : perform the DNS query |
|||
|
|||
### News |
|||
|
|||
- Version 0.1.0.9000 released |
|||
|
|||
### Installation |
|||
|
|||
``` r |
|||
devtools::install_github("hrbrmstr/gdns") |
|||
``` |
|||
|
|||
### Usage |
|||
|
|||
``` r |
|||
library(gdns) |
|||
|
|||
# current verison |
|||
packageVersion("gdns") |
|||
#> [1] '0.1.0.9000' |
|||
``` |
|||
|
|||
### Test Results |
|||
|
|||
``` r |
|||
library(gdns) |
|||
library(testthat) |
|||
|
|||
date() |
|||
#> [1] "Sat Apr 9 17:14:38 2016" |
|||
|
|||
test_dir("tests/") |
|||
#> testthat results ======================================================================================================== |
|||
#> OK: 0 SKIPPED: 0 FAILED: 0 |
|||
|
|||
library(purrr) |
|||
#> |
|||
#> Attaching package: 'purrr' |
|||
#> The following object is masked from 'package:testthat': |
|||
#> |
|||
#> is_null |
|||
|
|||
hosts <- c("rud.is", "dds.ec", "r-project.org", "rstudio.com") |
|||
results <- map(hosts, gdns::query) |
|||
map_df(results, "Answer") |
|||
#> Source: local data frame [4 x 4] |
|||
#> |
|||
#> name type TTL data |
|||
#> (chr) (int) (int) (chr) |
|||
#> 1 rud.is. 1 3147 104.236.112.222 |
|||
#> 2 dds.ec. 1 299 162.243.111.4 |
|||
#> 3 r-project.org. 1 1801 137.208.57.37 |
|||
#> 4 rstudio.com. 1 3482 45.79.156.36 |
|||
``` |
|||
|
|||
### Code of Conduct |
|||
|
|||
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms. |
@ -0,0 +1,24 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/gdns-package.r |
|||
\docType{package} |
|||
\name{gdns} |
|||
\alias{gdns} |
|||
\alias{gdns-package} |
|||
\title{Tools to Work with Google DNS Over https API} |
|||
\description{ |
|||
Traditional DNS queries and responses are sent over UDP or TCP without |
|||
encryption. This is vulnerable to eavesdropping and spoofing (including |
|||
DNS-based Internet filtering). Responses from recursive resolvers to clients |
|||
are the most vulnerable to undesired or malicious changes, while |
|||
communications between recursive resolvers and authoritative nameservers |
|||
often incorporate additional protection.\cr |
|||
\cr |
|||
To address this problem, Google Public DNS offers DNS resolution over an |
|||
encrypted HTTPS connection. DNS-over-HTTPS greatly enhances privacy and |
|||
security between a client and a recursive resolver, and complements DNSSEC |
|||
to provide end-to-end authenticated DNS lookups.#' |
|||
} |
|||
\author{ |
|||
Bob Rudis (@hrbrmstr) |
|||
} |
|||
|
@ -0,0 +1,47 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/gdns.r |
|||
\name{query} |
|||
\alias{query} |
|||
\title{Perform DNS over HTTPS queries using Google} |
|||
\usage{ |
|||
query(name, type = "1", cd = FALSE, edns_client_subnet = NULL) |
|||
} |
|||
\arguments{ |
|||
\item{name}{item to lookup. Valid characters are numbers, letters, hyphen, and dot. Length |
|||
must be between 1 and 255. Names with escaped or non-ASCII characters |
|||
are not supported. Internationalized domain names must use the |
|||
punycode format (e.g. "\code{xn--qxam}" rather than "\code{ελ}")} |
|||
|
|||
\item{type}{RR type can be represented as a number in [1, 65535] or canonical |
|||
string (A, aaaa, etc.)} |
|||
|
|||
\item{edns_client_subnet}{The edns0-client-subnet option. Format is an IP |
|||
address with a subnet mask. Examples: \code{1.2.3.4/24}, |
|||
\code{2001:700:300::/48}.\cr |
|||
If you are using DNS-over-HTTPS because of privacy concerns, and do |
|||
not want any part of your IP address to be sent to authoritative |
|||
nameservers for geographic location accuracy, use |
|||
\code{edns_client_subnet=0.0.0.0/0}. Google Public DNS normally sends |
|||
approximate network information (usually replacing the last part of |
|||
your IPv4 address with zeroes).} |
|||
} |
|||
\value{ |
|||
a \code{list} with the query result or \code{NULL} if an error occurred |
|||
} |
|||
\description{ |
|||
Traditional DNS queries and responses are sent over UDP or TCP without |
|||
encryption. This is vulnerable to eavesdropping and spoofing (including |
|||
DNS-based Internet filtering). Responses from recursive resolvers to clients |
|||
are the most vulnerable to undesired or malicious changes, while |
|||
communications between recursive resolvers and authoritative nameservers |
|||
often incorporate additional protection.\cr |
|||
\cr |
|||
To address this problem, Google Public DNS offers DNS resolution over an |
|||
encrypted HTTPS connection. DNS-over-HTTPS greatly enhances privacy and |
|||
security between a client and a recursive resolver, and complements DNSSEC |
|||
to provide end-to-end authenticated DNS lookups. |
|||
} |
|||
\examples{ |
|||
query("rud.is") |
|||
} |
|||
|
@ -0,0 +1,4 @@ |
|||
library(testthat) |
|||
library(gdns) |
|||
|
|||
test_check("gdns") |
@ -0,0 +1,6 @@ |
|||
context("basic functionality") |
|||
test_that("we can do something", { |
|||
|
|||
#expect_that(some_function(), is_a("data.frame")) |
|||
|
|||
}) |
Loading…
Reference in new issue