Browse Source

tibble return and more examples in README

boB Rudis 5 months ago
parent
commit
be6148eec4
No known key found for this signature in database
8 changed files with 130 additions and 35 deletions
  1. 1
    1
      DESCRIPTION
  2. 1
    0
      NAMESPACE
  3. 6
    0
      R/doh-get.R
  4. 24
    0
      R/to-inaddr-arpa.R
  5. 15
    3
      README.Rmd
  6. 67
    31
      README.md
  7. 2
    0
      man/doh_get.Rd
  8. 14
    0
      man/to_inaddr_arpa.Rd

+ 1
- 1
DESCRIPTION View File

@@ -1,7 +1,7 @@
1 1
 Package: playdoh
2 2
 Type: Package
3 3
 Title: Make 'DNS over HTTPS' Queries
4
-Version: 0.1.0
4
+Version: 0.1.1
5 5
 Date: 2019-05-25
6 6
 Authors@R: c(
7 7
     person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"), 

+ 1
- 0
NAMESPACE View File

@@ -2,5 +2,6 @@
2 2
 
3 3
 export(doh_get)
4 4
 export(doh_servers)
5
+export(to_inaddr_arpa)
5 6
 import(httr)
6 7
 importFrom(jsonlite,fromJSON)

+ 6
- 0
R/doh-get.R View File

@@ -13,6 +13,8 @@
13 13
 #' @export
14 14
 #' @examples
15 15
 #' doh_get("rud.is", "A")
16
+#' doh_get("lenovo.com", "TXT")
17
+#' doh_get(to_inaddr_arpa("104.244.13.104"), "PTR")
16 18
 doh_get <- function(name, type = "a", extra_params = list(), service_path = "https://9.9.9.9/dns-query") {
17 19
 
18 20
   stopifnot(is.list(extra_params))
@@ -44,6 +46,10 @@ doh_get <- function(name, type = "a", extra_params = list(), service_path = "htt
44 46
     attr(ret, "edns_client_subnet") <- out[["edns_client_subnet"]]
45 47
     attr(ret, "comment") <- out[["comment"]]
46 48
 
49
+    class(ret) <- c("tbl_df", "tbl", "data.frame")
50
+
51
+    ret
52
+
47 53
   }
48 54
 
49 55
   ret

+ 24
- 0
R/to-inaddr-arpa.R View File

@@ -0,0 +1,24 @@
1
+ipv4_regex <-
2
+  "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
3
+
4
+#' Convert a vector of IPv4 addresses to in-addr.arpa format
5
+#'
6
+#' @md
7
+#' @param ipv4 vector of ipv4 addresses
8
+#' @export
9
+to_inaddr_arpa <- function(ipv4) {
10
+
11
+  ifelse(
12
+    test = grepl(ipv4_regex, ipv4),
13
+    yes =  paste0(
14
+      c(
15
+        rev(unlist(strsplit(ipv4, ".", 4), use.names = FALSE)),
16
+        "in-addr.arpa."
17
+      ),
18
+      sep = "",
19
+      collapse = "."
20
+    ),
21
+    no = ipv4
22
+  )
23
+
24
+}

+ 15
- 3
README.Rmd View File

@@ -51,10 +51,22 @@ packageVersion("playdoh")
51 51
 
52 52
 ### Basic functionality
53 53
 
54
-```{r}
55
-doh_get("rud.is")
54
+```{r doh2}
55
+doh_get("apple.com", "A")
56 56
 
57
-doh_get("lenovo.com", "txt")
57
+doh_get("rud.is", "AAAA")
58
+
59
+doh_get("rud.is", "MX")
60
+
61
+doh_get("lenovo.com", "TXT")
62
+
63
+doh_get("dataassurance.pwc.com", "CNAME")
64
+
65
+doh_get("rud.is", "NS")
66
+
67
+doh_get("rud.is", "SOA")
68
+
69
+doh_get(to_inaddr_arpa("104.244.13.104"), "PTR")
58 70
 ```
59 71
 
60 72
 ## playdoh Metrics

+ 67
- 31
README.md View File

@@ -46,41 +46,77 @@ packageVersion("playdoh")
46 46
 ### Basic functionality
47 47
 
48 48
 ``` r
49
-doh_get("rud.is")
50
-##      name type  ttl                       expires          data
51
-## 1 rud.is.    1 2300 Sun, 26 May 2019 18:08:58 UTC 172.93.49.183
52
-
53
-doh_get("lenovo.com", "txt")
54
-##           name type  ttl                       expires
55
-## 1  lenovo.com.   16 7200 Sun, 26 May 2019 19:30:38 UTC
56
-## 2  lenovo.com.   16 7200 Sun, 26 May 2019 19:30:38 UTC
57
-## 3  lenovo.com.   16 7200 Sun, 26 May 2019 19:30:38 UTC
58
-## 4  lenovo.com.   16 7200 Sun, 26 May 2019 19:30:38 UTC
59
-## 5  lenovo.com.   16 7200 Sun, 26 May 2019 19:30:38 UTC
60
-## 6  lenovo.com.   16 7200 Sun, 26 May 2019 19:30:38 UTC
61
-## 7  lenovo.com.   16 7200 Sun, 26 May 2019 19:30:38 UTC
62
-## 8  lenovo.com.   16 7200 Sun, 26 May 2019 19:30:38 UTC
63
-## 9  lenovo.com.   16 7200 Sun, 26 May 2019 19:30:38 UTC
64
-## 10 lenovo.com.   16 7200 Sun, 26 May 2019 19:30:38 UTC
65
-##                                                                                          data
66
-## 1                               "facebook-domain-verification=1r2am7c2bhzrxpqyt0mda0djoquqsi"
67
-## 2                      "google-site-verification=sHIlSlj0U6UnCDkfHp1AolWgVEvDjWvc0TR4KaysD2c"
68
-## 3                      "google-site-verification=nGgukcp60rC-gFxMOJw1NHH0B4VnSchRrlfWV-He_tE"
69
-## 4                                                          "a82c74b37aa84e7c8580f0e32f4d795d"
70
-## 5             "Visit www.lenovo.com/think for information about Lenovo products and services"
71
-## 6                                                          "qh7hdmqm4lzs85p704d6wsybgrpsly0j"
72
-## 7                      "google-site-verification=VxW_e6r_Ka7A518qfX2MmIMHGnkpGbnACsjSxKFCBw0"
73
-## 8                                                          "ece42d7743c84d6889abda7011fe6f53"
74
-## 9  "iHzQJvsKnyGP2Nm2qBgL3fyBJ0CC9z4GkY/flfk4EzLP8lPxWHDDPKqZWm1TkeF5kEIL+NotYOF1wo7JtUDXXw=="
75
-## 10                    "v=spf1 include:spf.messagelabs.com include:_netblocks.eloqua.com ~all"
49
+doh_get("apple.com", "A")
50
+## # A tibble: 3 x 5
51
+##   name        type   ttl expires                       data         
52
+## * <chr>      <int> <int> <chr>                         <chr>        
53
+## 1 apple.com.     1  1521 Mon, 27 May 2019 16:26:57 UTC 17.142.160.59
54
+## 2 apple.com.     1  1521 Mon, 27 May 2019 16:26:57 UTC 17.178.96.59 
55
+## 3 apple.com.     1  1521 Mon, 27 May 2019 16:26:57 UTC 17.172.224.47
56
+
57
+doh_get("rud.is", "AAAA")
58
+## # A tibble: 1 x 5
59
+##   name     type   ttl expires                       data                  
60
+## * <chr>   <int> <int> <chr>                         <chr>                 
61
+## 1 rud.is.    28 43200 Tue, 28 May 2019 04:01:37 UTC 2602:ff16:3::4dfb:9ac5
62
+
63
+doh_get("rud.is", "MX")
64
+## # A tibble: 4 x 5
65
+##   name     type   ttl expires                       data                       
66
+## * <chr>   <int> <int> <chr>                         <chr>                      
67
+## 1 rud.is.    15 43200 Tue, 28 May 2019 04:01:37 UTC 40 aspmx2.googlemail.com.  
68
+## 2 rud.is.    15 43200 Tue, 28 May 2019 04:01:37 UTC 20 alt1.aspmx.l.google.com.
69
+## 3 rud.is.    15 43200 Tue, 28 May 2019 04:01:37 UTC 10 aspmx.l.google.com.     
70
+## 4 rud.is.    15 43200 Tue, 28 May 2019 04:01:37 UTC 30 alt2.aspmx.l.google.com.
71
+
72
+doh_get("lenovo.com", "TXT")
73
+## # A tibble: 10 x 5
74
+##    name        type   ttl expires                 data                                                                  
75
+##  * <chr>      <int> <int> <chr>                   <chr>                                                                 
76
+##  1 lenovo.co…    16  7200 Mon, 27 May 2019 18:01… "\"qh7hdmqm4lzs85p704d6wsybgrpsly0j\""                                
77
+##  2 lenovo.co…    16  7200 Mon, 27 May 2019 18:01… "\"Visit www.lenovo.com/think for information about Lenovo products a…
78
+##  3 lenovo.co…    16  7200 Mon, 27 May 2019 18:01… "\"a82c74b37aa84e7c8580f0e32f4d795d\""                                
79
+##  4 lenovo.co…    16  7200 Mon, 27 May 2019 18:01… "\"iHzQJvsKnyGP2Nm2qBgL3fyBJ0CC9z4GkY/flfk4EzLP8lPxWHDDPKqZWm1TkeF5kE…
80
+##  5 lenovo.co…    16  7200 Mon, 27 May 2019 18:01… "\"facebook-domain-verification=1r2am7c2bhzrxpqyt0mda0djoquqsi\""     
81
+##  6 lenovo.co…    16  7200 Mon, 27 May 2019 18:01… "\"ece42d7743c84d6889abda7011fe6f53\""                                
82
+##  7 lenovo.co…    16  7200 Mon, 27 May 2019 18:01… "\"google-site-verification=sHIlSlj0U6UnCDkfHp1AolWgVEvDjWvc0TR4KaysD…
83
+##  8 lenovo.co…    16  7200 Mon, 27 May 2019 18:01… "\"google-site-verification=VxW_e6r_Ka7A518qfX2MmIMHGnkpGbnACsjSxKFCB…
84
+##  9 lenovo.co…    16  7200 Mon, 27 May 2019 18:01… "\"google-site-verification=nGgukcp60rC-gFxMOJw1NHH0B4VnSchRrlfWV-He_…
85
+## 10 lenovo.co…    16  7200 Mon, 27 May 2019 18:01… "\"v=spf1 include:spf.messagelabs.com include:_netblocks.eloqua.com ~…
86
+
87
+doh_get("dataassurance.pwc.com", "CNAME")
88
+## # A tibble: 1 x 5
89
+##   name                    type   ttl expires                       data                   
90
+## * <chr>                  <int> <int> <chr>                         <chr>                  
91
+## 1 dataassurance.pwc.com.     5  3600 Mon, 27 May 2019 17:01:38 UTC f6759d2.x.incapdns.net.
92
+
93
+doh_get("rud.is", "NS")
94
+## # A tibble: 3 x 5
95
+##   name     type   ttl expires                       data            
96
+## * <chr>   <int> <int> <chr>                         <chr>           
97
+## 1 rud.is.     2 43200 Tue, 28 May 2019 04:01:38 UTC dns.mwebdns.net.
98
+## 2 rud.is.     2 43200 Tue, 28 May 2019 04:01:38 UTC dns.mwebdns.eu. 
99
+## 3 rud.is.     2 43200 Tue, 28 May 2019 04:01:38 UTC dns.mwebdns.de.
100
+
101
+doh_get("rud.is", "SOA")
102
+## # A tibble: 1 x 5
103
+##   name     type   ttl expires                     data                                                                  
104
+## * <chr>   <int> <int> <chr>                       <chr>                                                                 
105
+## 1 rud.is.     6 43200 Tue, 28 May 2019 04:01:38 … dns.mwebdns.de. hostmaster.mandoraweb.de. 2010012659 10800 3600 60480…
106
+
107
+doh_get(to_inaddr_arpa("104.244.13.104"), "PTR")
108
+## # A tibble: 1 x 5
109
+##   name                          type   ttl expires                       data                         
110
+## * <chr>                        <int> <int> <chr>                         <chr>                        
111
+## 1 104.13.244.104.in-addr.arpa.    12 43200 Tue, 28 May 2019 04:01:38 UTC archive.farsightsecurity.com.
76 112
 ```
77 113
 
78 114
 ## playdoh Metrics
79 115
 
80
-| Lang | \# Files |  (%) | LoC |  (%) | Blank lines |  (%) | \# Lines |  (%) |
81
-| :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | ---: |
82
-| R    |        6 | 0.86 | 107 | 0.91 |          20 | 0.48 |       47 | 0.57 |
83
-| Rmd  |        1 | 0.14 |  11 | 0.09 |          22 | 0.52 |       36 | 0.43 |
116
+| Lang | \# Files |  (%) | LoC |  (%) | Blank lines |  (%) | \# Lines | (%) |
117
+| :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | --: |
118
+| R    |        7 | 0.88 | 125 | 0.88 |          25 | 0.47 |       54 | 0.6 |
119
+| Rmd  |        1 | 0.12 |  17 | 0.12 |          28 | 0.53 |       36 | 0.4 |
84 120
 
85 121
 ## Code of Conduct
86 122
 

+ 2
- 0
man/doh_get.Rd View File

@@ -26,6 +26,8 @@ DoH endpoint specified at \code{server_path}.
26 26
 }
27 27
 \examples{
28 28
 doh_get("rud.is", "A")
29
+doh_get("lenovo.com", "TXT")
30
+doh_get(to_inaddr_arpa("104.244.13.104"), "PTR")
29 31
 }
30 32
 \references{
31 33
 \url{https://tools.ietf.org/id/draft-ietf-doh-dns-over-https-05.html}

+ 14
- 0
man/to_inaddr_arpa.Rd View File

@@ -0,0 +1,14 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/to-inaddr-arpa.R
3
+\name{to_inaddr_arpa}
4
+\alias{to_inaddr_arpa}
5
+\title{Convert a vector of IPv4 addresses to in-addr.arpa format}
6
+\usage{
7
+to_inaddr_arpa(ipv4)
8
+}
9
+\arguments{
10
+\item{ipv4}{vector of ipv4 addresses}
11
+}
12
+\description{
13
+Convert a vector of IPv4 addresses to in-addr.arpa format
14
+}

Loading…
Cancel
Save