Browse Source

initial commit

Bob Rudis 3 years ago
parent
commit
4b5d163492
14 changed files with 346 additions and 6 deletions
  1. 5
    0
      .Rbuildignore
  2. 5
    0
      .travis.yml
  3. 25
    0
      CONDUCT.md
  4. 14
    4
      DESCRIPTION
  5. 6
    2
      NAMESPACE
  6. 21
    0
      R/gdns-package.r
  7. 50
    0
      R/gdns.r
  8. 67
    0
      README.Rmd
  9. 63
    0
      README.md
  10. 9
    0
      gdns.Rproj
  11. 24
    0
      man/gdns.Rd
  12. 47
    0
      man/query.Rd
  13. 4
    0
      tests/testthat.R
  14. 6
    0
      tests/testthat/test-gdns.R

+ 5
- 0
.Rbuildignore View File

@@ -1,2 +1,7 @@
1 1
 ^.*\.Rproj$
2 2
 ^\.Rproj\.user$
3
+^README\.Rmd$
4
+^README-.*\.png$
5
+^\.travis\.yml$
6
+^CONDUCT\.md$
7
+^README\.md$

+ 5
- 0
.travis.yml View File

@@ -0,0 +1,5 @@
1
+# Sample .travis.yml for R projects
2
+
3
+language: r
4
+warnings_are_errors: true
5
+sudo: required

+ 25
- 0
CONDUCT.md View File

@@ -0,0 +1,25 @@
1
+# Contributor Code of Conduct
2
+
3
+As contributors and maintainers of this project, we pledge to respect all people who 
4
+contribute through reporting issues, posting feature requests, updating documentation,
5
+submitting pull requests or patches, and other activities.
6
+
7
+We are committed to making participation in this project a harassment-free experience for
8
+everyone, regardless of level of experience, gender, gender identity and expression,
9
+sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
10
+
11
+Examples of unacceptable behavior by participants include the use of sexual language or
12
+imagery, derogatory comments or personal attacks, trolling, public or private harassment,
13
+insults, or other unprofessional conduct.
14
+
15
+Project maintainers have the right and responsibility to remove, edit, or reject comments,
16
+commits, code, wiki edits, issues, and other contributions that are not aligned to this 
17
+Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed 
18
+from the project team.
19
+
20
+Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by 
21
+opening an issue or contacting one or more of the project maintainers.
22
+
23
+This Code of Conduct is adapted from the Contributor Covenant 
24
+(http:contributor-covenant.org), version 1.0.0, available at 
25
+http://contributor-covenant.org/version/1/0/0/

+ 14
- 4
DESCRIPTION View File

@@ -1,8 +1,18 @@
1 1
 Package: gdns
2
-Title: What the Package Does (one line, title case)
3
-Version: 0.0.0.9000
2
+Title: Tools to Work with Google DNS Over https API
3
+Version: 0.1.0.9000
4 4
 Authors@R: c(person("Bob", "Rudis", email = "bob@rudis.net", role = c("aut", "cre")))
5
-Description: What the package does (one paragraph).
6
-Depends: R (>= 3.2.4)
5
+Maintainer: Bob Rudis <bob@rudis.net>
6
+Description: Tools to Work with Google DNS Over https API
7 7
 License: AGPL + file LICENSE
8 8
 LazyData: true
9
+Encoding: UTF-8
10
+Depends:
11
+    R (>= 3.0.0)
12
+Suggests:
13
+    testthat
14
+Imports:
15
+    httr,
16
+    jsonlite,
17
+    purrr
18
+RoxygenNote: 5.0.1

+ 6
- 2
NAMESPACE View File

@@ -1,2 +1,6 @@
1
-# Generated by roxygen2: fake comment so roxygen2 overwrites silently.
2
-exportPattern("^[^\\.]")
1
+# Generated by roxygen2: do not edit by hand
2
+
3
+export(query)
4
+import(httr)
5
+importFrom(jsonlite,fromJSON)
6
+importFrom(purrr,safely)

+ 21
- 0
R/gdns-package.r View File

@@ -0,0 +1,21 @@
1
+#' Tools to Work with Google DNS Over https API
2
+#'
3
+#' Traditional DNS queries and responses are sent over UDP or TCP without
4
+#' encryption. This is vulnerable to eavesdropping and spoofing (including
5
+#' DNS-based Internet filtering). Responses from recursive resolvers to clients
6
+#' are the most vulnerable to undesired or malicious changes, while
7
+#' communications between recursive resolvers and authoritative nameservers
8
+#' often incorporate additional protection.\cr
9
+#' \cr
10
+#' To address this problem, Google Public DNS offers DNS resolution over an
11
+#' encrypted HTTPS connection. DNS-over-HTTPS greatly enhances privacy and
12
+#' security between a client and a recursive resolver, and complements DNSSEC
13
+#' to provide end-to-end authenticated DNS lookups.#'
14
+#'
15
+#' @name gdns
16
+#' @docType package
17
+#' @author Bob Rudis (@@hrbrmstr)
18
+#' @import httr
19
+#' @importFrom jsonlite fromJSON
20
+#' @importFrom purrr safely
21
+NULL

+ 50
- 0
R/gdns.r View File

@@ -0,0 +1,50 @@
1
+S_GET <- purrr::safely(GET)
2
+
3
+#' Perform DNS over HTTPS queries using Google
4
+#'
5
+#' Traditional DNS queries and responses are sent over UDP or TCP without
6
+#' encryption. This is vulnerable to eavesdropping and spoofing (including
7
+#' DNS-based Internet filtering). Responses from recursive resolvers to clients
8
+#' are the most vulnerable to undesired or malicious changes, while
9
+#' communications between recursive resolvers and authoritative nameservers
10
+#' often incorporate additional protection.\cr
11
+#' \cr
12
+#' To address this problem, Google Public DNS offers DNS resolution over an
13
+#' encrypted HTTPS connection. DNS-over-HTTPS greatly enhances privacy and
14
+#' security between a client and a recursive resolver, and complements DNSSEC
15
+#' to provide end-to-end authenticated DNS lookups.
16
+#'
17
+#' @param name item to lookup. Valid characters are numbers, letters, hyphen, and dot. Length
18
+#'        must be between 1 and 255. Names with escaped or non-ASCII characters
19
+#'        are not supported. Internationalized domain names must use the
20
+#'        punycode format (e.g. "\code{xn--qxam}" rather than "\code{ελ}")
21
+#' @param type RR type can be represented as a number in [1, 65535] or canonical
22
+#'        string (A, aaaa, etc.)
23
+#' @param edns_client_subnet The edns0-client-subnet option. Format is an IP
24
+#'        address with a subnet mask. Examples: \code{1.2.3.4/24},
25
+#'        \code{2001:700:300::/48}.\cr
26
+#'        If you are using DNS-over-HTTPS because of privacy concerns, and do
27
+#'        not want any part of your IP address to be sent to authoritative
28
+#'        nameservers for geographic location accuracy, use
29
+#'        \code{edns_client_subnet=0.0.0.0/0}. Google Public DNS normally sends
30
+#'        approximate network information (usually replacing the last part of
31
+#'        your IPv4 address with zeroes).
32
+#' @return a \code{list} with the query result or \code{NULL} if an error occurred
33
+#' @export
34
+#' @examples
35
+#' query("rud.is")
36
+query <- function(name, type="1", cd=FALSE, edns_client_subnet=NULL) {
37
+
38
+  res <- S_GET("https://dns.google.com/resolve",
39
+               query=list(name=name,
40
+                          type=type,
41
+                          edns_client_subnet=edns_client_subnet))
42
+
43
+  if (!is.null(res$result)) {
44
+    stop_for_status(res$result)
45
+    jsonlite::fromJSON(httr::content(res$result, as="text"))
46
+  } else {
47
+    NULL
48
+  }
49
+
50
+}

+ 67
- 0
README.Rmd View File

@@ -0,0 +1,67 @@
1
+---
2
+output:
3
+  md_document:
4
+    variant: markdown_github
5
+---
6
+
7
+<!-- README.md is generated from README.Rmd. Please edit that file -->
8
+
9
+```{r, echo = FALSE}
10
+knitr::opts_chunk$set(
11
+  collapse = TRUE,
12
+  comment = "#>",
13
+  fig.path = "README-"
14
+)
15
+```
16
+
17
+`gdns` : Tools to work with the Google DNS over HTTPS API
18
+
19
+The following functions are implemented:
20
+
21
+- `query` : perform the DNS query
22
+
23
+### News
24
+
25
+- Version 0.1.0.9000 released
26
+
27
+### Installation
28
+
29
+```{r eval=FALSE}
30
+devtools::install_github("hrbrmstr/gdns")
31
+```
32
+
33
+```{r echo=FALSE, message=FALSE, warning=FALSE, error=FALSE}
34
+options(width=120)
35
+```
36
+
37
+### Usage
38
+
39
+```{r}
40
+library(gdns)
41
+
42
+# current verison
43
+packageVersion("gdns")
44
+
45
+```
46
+
47
+### Test Results
48
+
49
+```{r}
50
+library(gdns)
51
+library(testthat)
52
+
53
+date()
54
+
55
+test_dir("tests/")
56
+
57
+library(purrr)
58
+
59
+hosts <- c("rud.is", "dds.ec", "r-project.org", "rstudio.com")
60
+results <- map(hosts, gdns::query)
61
+map_df(results, "Answer")
62
+```
63
+
64
+### Code of Conduct
65
+
66
+Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). 
67
+By participating in this project you agree to abide by its terms.

+ 63
- 0
README.md View File

@@ -0,0 +1,63 @@
1
+<!-- README.md is generated from README.Rmd. Please edit that file -->
2
+`gdns` : Tools to work with the Google DNS over HTTPS API
3
+
4
+The following functions are implemented:
5
+
6
+-   `query` : perform the DNS query
7
+
8
+### News
9
+
10
+-   Version 0.1.0.9000 released
11
+
12
+### Installation
13
+
14
+``` r
15
+devtools::install_github("hrbrmstr/gdns")
16
+```
17
+
18
+### Usage
19
+
20
+``` r
21
+library(gdns)
22
+
23
+# current verison
24
+packageVersion("gdns")
25
+#> [1] '0.1.0.9000'
26
+```
27
+
28
+### Test Results
29
+
30
+``` r
31
+library(gdns)
32
+library(testthat)
33
+
34
+date()
35
+#> [1] "Sat Apr  9 17:14:38 2016"
36
+
37
+test_dir("tests/")
38
+#> testthat results ========================================================================================================
39
+#> OK: 0 SKIPPED: 0 FAILED: 0
40
+
41
+library(purrr)
42
+#> 
43
+#> Attaching package: 'purrr'
44
+#> The following object is masked from 'package:testthat':
45
+#> 
46
+#>     is_null
47
+
48
+hosts <- c("rud.is", "dds.ec", "r-project.org", "rstudio.com")
49
+results <- map(hosts, gdns::query)
50
+map_df(results, "Answer")
51
+#> Source: local data frame [4 x 4]
52
+#> 
53
+#>             name  type   TTL            data
54
+#>            (chr) (int) (int)           (chr)
55
+#> 1        rud.is.     1  3147 104.236.112.222
56
+#> 2        dds.ec.     1   299   162.243.111.4
57
+#> 3 r-project.org.     1  1801   137.208.57.37
58
+#> 4   rstudio.com.     1  3482    45.79.156.36
59
+```
60
+
61
+### Code of Conduct
62
+
63
+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.

+ 9
- 0
gdns.Rproj View File

@@ -14,3 +14,12 @@ BuildType: Package
14 14
 PackageUseDevtools: Yes
15 15
 PackageInstallArgs: --no-multiarch --with-keep.source
16 16
 PackageRoxygenize: rd,collate,namespace
17
+
18
+UseSpacesForTab: Yes
19
+NumSpacesForTab: 2
20
+
21
+RnwWeave: Sweave
22
+LaTeX: pdfLaTeX
23
+
24
+PackageBuildArgs: --resave-data
25
+PackageCheckArgs: --as-cran

+ 24
- 0
man/gdns.Rd View File

@@ -0,0 +1,24 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/gdns-package.r
3
+\docType{package}
4
+\name{gdns}
5
+\alias{gdns}
6
+\alias{gdns-package}
7
+\title{Tools to Work with Google DNS Over https API}
8
+\description{
9
+Traditional DNS queries and responses are sent over UDP or TCP without
10
+encryption. This is vulnerable to eavesdropping and spoofing (including
11
+DNS-based Internet filtering). Responses from recursive resolvers to clients
12
+are the most vulnerable to undesired or malicious changes, while
13
+communications between recursive resolvers and authoritative nameservers
14
+often incorporate additional protection.\cr
15
+\cr
16
+To address this problem, Google Public DNS offers DNS resolution over an
17
+encrypted HTTPS connection. DNS-over-HTTPS greatly enhances privacy and
18
+security between a client and a recursive resolver, and complements DNSSEC
19
+to provide end-to-end authenticated DNS lookups.#'
20
+}
21
+\author{
22
+Bob Rudis (@hrbrmstr)
23
+}
24
+

+ 47
- 0
man/query.Rd View File

@@ -0,0 +1,47 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/gdns.r
3
+\name{query}
4
+\alias{query}
5
+\title{Perform DNS over HTTPS queries using Google}
6
+\usage{
7
+query(name, type = "1", cd = FALSE, edns_client_subnet = NULL)
8
+}
9
+\arguments{
10
+\item{name}{item to lookup. Valid characters are numbers, letters, hyphen, and dot. Length
11
+must be between 1 and 255. Names with escaped or non-ASCII characters
12
+are not supported. Internationalized domain names must use the
13
+punycode format (e.g. "\code{xn--qxam}" rather than "\code{ελ}")}
14
+
15
+\item{type}{RR type can be represented as a number in [1, 65535] or canonical
16
+string (A, aaaa, etc.)}
17
+
18
+\item{edns_client_subnet}{The edns0-client-subnet option. Format is an IP
19
+address with a subnet mask. Examples: \code{1.2.3.4/24},
20
+\code{2001:700:300::/48}.\cr
21
+If you are using DNS-over-HTTPS because of privacy concerns, and do
22
+not want any part of your IP address to be sent to authoritative
23
+nameservers for geographic location accuracy, use
24
+\code{edns_client_subnet=0.0.0.0/0}. Google Public DNS normally sends
25
+approximate network information (usually replacing the last part of
26
+your IPv4 address with zeroes).}
27
+}
28
+\value{
29
+a \code{list} with the query result or \code{NULL} if an error occurred
30
+}
31
+\description{
32
+Traditional DNS queries and responses are sent over UDP or TCP without
33
+encryption. This is vulnerable to eavesdropping and spoofing (including
34
+DNS-based Internet filtering). Responses from recursive resolvers to clients
35
+are the most vulnerable to undesired or malicious changes, while
36
+communications between recursive resolvers and authoritative nameservers
37
+often incorporate additional protection.\cr
38
+\cr
39
+To address this problem, Google Public DNS offers DNS resolution over an
40
+encrypted HTTPS connection. DNS-over-HTTPS greatly enhances privacy and
41
+security between a client and a recursive resolver, and complements DNSSEC
42
+to provide end-to-end authenticated DNS lookups.
43
+}
44
+\examples{
45
+query("rud.is")
46
+}
47
+

+ 4
- 0
tests/testthat.R View File

@@ -0,0 +1,4 @@
1
+library(testthat)
2
+library(gdns)
3
+
4
+test_check("gdns")

+ 6
- 0
tests/testthat/test-gdns.R View File

@@ -0,0 +1,6 @@
1
+context("basic functionality")
2
+test_that("we can do something", {
3
+
4
+  #expect_that(some_function(), is_a("data.frame"))
5
+
6
+})

Loading…
Cancel
Save