README.md

DOI

resolv

ldns DNS resolver wrapper libary for R

Needs ldns - http://www.nlnetlabs.nl/projects/ldns/ - which is apt-able and brew-able.

library(devtools)
install_github("hrbrmstr/resolv")

These folks seem to have done some work getting the ldns library to work under Windows, but this particular package only works (for now on Linux/Mac OS X.

Bug reports (esp from ppl with more C++/Rcpp experience), feature requests & pull requests welcome/encouraged. The code/package is documented pretty well (esp for me). Hopefully this library can replace system calls for folks who need to "do DNS stuff" from R.

News

Description

Provides functions to perform robust DNS lookups from R. Uses the ldns library which provides support for IPv4 & IPv6 addresses as well as DNSSEC. This library currently exposes the functions indicated below.

Details

Package: resolv
Type: Package
Title: Wrapper to ldns library for DNS calls from R
Version: 0.2.3
Date: 2014-08-30
Author: Bob Rudis (@hrbrmstr)
Maintainer: Bob Rudids <bob@rudis.net>
Description: Wrapper to ldns library for DNS calls from R. It provides
    vecorized & non-vectorized version of core DNS query functions and
    allows for vector or data frame return values in most functions
    (depending on the level of detail desired from the query). It's
    significantly faster than issuing a system() call but does not
    yet work under Windows.
URL: https://github.com/hrbrmstr/resolv
BugReports: https://github.com/hrbrmstr/resolv/issues
License: GPL-2
Imports:
    Rcpp (>= 0.11.1)
LinkingTo: Rcpp

Direct ldns wrappers:

and, their vectorized counterparts:

(TODO: to add "SOA" suppot)

Ancillary/"fun"ctions

These show off some of what you can do with DNS

Installation

devtools::install_github("hrbrmstr/resolv")

Don't forget the need to brew install ldns or your favorite linux pkg mgr equivalent, first.

Usage

require(resolv)
## Loading required package: resolv
library(plyr)

## google talk provides a good example for this
resolv_srv("_xmpp-server._tcp.gmail.com.")
##                           fqdn priority weight port                         target
## 1 _xmpp-server._tcp.gmail.com.        5      0 5269      xmpp-server.l.google.com.
## 2 _xmpp-server._tcp.gmail.com.       20      0 5269 alt1.xmpp-server.l.google.com.
## 3 _xmpp-server._tcp.gmail.com.       20      0 5269 alt2.xmpp-server.l.google.com.
## 4 _xmpp-server._tcp.gmail.com.       20      0 5269 alt3.xmpp-server.l.google.com.
## 5 _xmpp-server._tcp.gmail.com.       20      0 5269 alt4.xmpp-server.l.google.com.
## where www.nasa.gov hosts
resolv_a("www.nasa.gov")
## [1] "69.28.157.198"
## DNS seekrit TXT URLs
## uncomment and run it locally
# browseURL(gsub("\"", "", resolv_txt("google-public-dns-a.google.com")))

# vectorized + full return
TXT(c("stackoverflow.com", "microsoft.com", "apple.com", "google.com"), full=TRUE)
##                fqdn
## 1 stackoverflow.com
## 2     microsoft.com
## 3     microsoft.com
## 4         apple.com
## 5        google.com
##                                                                                                                                                                                                                                                          txt
## 1                                                                                                                                                      "v=spf1 a mx ip4:198.252.206.0/24 ip4:69.59.197.0/26 include:cmail1.com include:_spf.google.com ~all"
## 2                                                                                                                                                                 "FbUF6DbkE+Aw1/wi9xgDi8KVrIIZus5v8L6tbIQZkGrQ/rVQKJi8CjQbBtWtE64ey4NJJwj5J65PIggVYNabdQ=="
## 3 "v=spf1 include:_spf-a.microsoft.com include:_spf-b.microsoft.com include:_spf-c.microsoft.com include:_spf-ssg-a.microsoft.com include:spf-a.hotmail.com ip4:147.243.128.24 ip4:147.243.128.26 ip4:147.243.128.25 ip4:147.243.1.47 ip4:147.243.1.48 -all"
## 4                                                                                                                                                                                                                               "v=spf1 ip4:17.0.0.0/8 ~all"
## 5                                                                                                                                                                              "v=spf1 include:_spf.google.com ip4:216.73.93.70/31 ip4:216.73.93.72/31 ~all"
##                owner class  ttl
## 1 stackoverflow.com.     1  299
## 2     microsoft.com.     1  311
## 3     microsoft.com.     1  311
## 4         apple.com.     1 3177
## 5        google.com.     1 3030
## parallel queries
library(foreach)
library(doParallel)
## Loading required package: iterators
## Loading required package: parallel
library(data.table)

data(alexa) # http://s3.amazonaws.com/alexa-static/top-1m.csv.zip

n <- 100 # top 'n' to resolve (change it to 10000 on your own as that # makes the README builds churn too long)

registerDoParallel(cores=6) # set to what you can on your system
output <- foreach(i=1:n, .packages=c("Rcpp", "resolv")) %dopar% resolv_a(alexa[i,]$domain)
names(output) <- alexa[1:n,]$domain
head(output)
## $facebook.com
## [1] "173.252.110.27"
## 
## $youtube.com
##  [1] "74.125.226.0"  "74.125.226.1"  "74.125.226.2"  "74.125.226.3"  "74.125.226.4"  "74.125.226.5"  "74.125.226.6" 
##  [8] "74.125.226.7"  "74.125.226.8"  "74.125.226.9"  "74.125.226.14"
## 
## $yahoo.com
## [1] "98.138.253.109" "98.139.183.24"  "206.190.36.45" 
## 
## $baidu.com
## [1] "123.125.114.144" "220.181.111.85"  "220.181.111.86" 
## 
## $wikipedia.org
## [1] "208.80.154.224"
## 
## $twitter.com
## [1] "199.16.156.6"   "199.16.156.38"  "199.16.156.198" "199.16.156.230"

References

See Also

Test Results

library(resolv)
library(testthat)

date()
## [1] "Sat Aug 30 15:02:48 2014"
test_dir("tests/")
## resolv core : ......


hrbrmstr/resolv documentation built on May 17, 2019, 5:12 p.m.