Browse Source

golang

master
boB Rudis 3 years ago
parent
commit
be0f78e56d
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 4
      DESCRIPTION
  2. 3
      NAMESPACE
  3. 12
      R/go-whois.R
  4. 2
      R/pwhois-package.R
  5. 14
      README.Rmd
  6. 326
      README.md
  7. 16
      man/whois_query.Rd
  8. 12
      src/Makevars
  9. BIN
      src/go/pkg/darwin_amd64/github.com/likexian/gokit/xjson.a
  10. BIN
      src/go/pkg/darwin_amd64/github.com/likexian/whois-parser.a
  11. BIN
      src/go/pkg/darwin_amd64/github.com/likexian/whois.a
  12. 1
      src/go/src/github.com/likexian/gokit
  13. 1
      src/go/src/github.com/likexian/whois
  14. 1
      src/go/src/github.com/likexian/whois-parser
  15. 1
      src/go/src/golang.org/x/net
  16. 1
      src/go/src/golang.org/x/text
  17. 54
      src/go/src/main/main.c
  18. 33
      src/go/src/main/main.go
  19. 0
      src/init.c
  20. 85
      src/pwhois.h

4
DESCRIPTION

@ -2,7 +2,7 @@ Package: pwhois
Type: Package
Title: Issue 'WHOIS' Queries and Process Various 'WHOIS' Resoponses
Version: 0.1.0
Date: 2021-02-13
Date: 2021-04-24
Authors@R: c(
person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5670-2640"))
@ -20,6 +20,7 @@ URL: https://git.rud.is/hrbrmstr/pwhois
BugReports: https://git.rud.is/hrbrmstr/pwhois/issues
Encoding: UTF-8
License: MIT + file LICENSE
SystemRequirements: Golang
Suggests:
covr, tinytest
Depends:
@ -28,4 +29,5 @@ Imports:
stringi,
jsonlite
Roxygen: list(markdown = TRUE)
RequiresCompilation: yes
RoxygenNote: 7.1.1

3
NAMESPACE

@ -3,4 +3,7 @@
export(tidy_cymru)
export(tidy_pwhois)
export(whois)
export(whois_query)
import(stringi)
importFrom(jsonlite,fromJSON)
useDynLib(pwhois, .registration = TRUE)

12
R/go-whois.R

@ -0,0 +1,12 @@
#' Go WHOIS
#'
#' @param query WHOIS query
#' @param server leave `""` for the default
#' @export
whois_query <- function(query, server = "") {
out <- .Call("R_whois_query", query, server, PACKAGE = "pwhois")
jsonlite::fromJSON(out)
}

2
R/pwhois-package.R

@ -14,4 +14,6 @@
#' @keywords internal
#' @author Bob Rudis (bob@@rud.is)
#' @import stringi
#' @importFrom jsonlite fromJSON
#' @useDynLib pwhois, .registration = TRUE
"_PACKAGE"

14
README.Rmd

@ -25,10 +25,14 @@ hrbrpkghelpr::describe_ingredients()
## Installation
```{r install-ex, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::install_block()
There is now a Golang dependency, which means you're better off doing:
```
git clone --recurse-submodules -j8 git@github.com:hrbrmstr/pwhois.git
```
and building from RStudio or the command line.
## Usage
```{r lib-ex}
@ -78,6 +82,12 @@ The Prefix WhoIs project can also return responses in Routing Policy Specificati
whois('type=rpsl 17.253.144.10')
```
Old-school WHOIS
```{r ex-05}
str(pwhois::whois_query("r-project.org"), 2)
```
## pwhois Metrics
```{r cloc, echo=FALSE}

326
README.md

@ -1,59 +1,57 @@
---
output: rmarkdown::github_document
editor_options:
chunk_output_type: console
---
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Signed by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keybase.io/hrbrmstr)
![Signed commit %](https://img.shields.io/badge/Signed_Commits-100%25-lightgrey.svg)
[![Linux build Status](https://travis-ci.org/hrbrmstr/pwhois.svg?branch=master)](https://travis-ci.org/hrbrmstr/pwhois)
![Minimal R Version](https://img.shields.io/badge/R%3E%3D-3.5.0-blue.svg)
![License](https://img.shields.io/badge/License-MIT-blue.svg)
[![Project Status: Active – The project has reached a stable, usable
state and is being actively
developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Signed
by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keybase.io/hrbrmstr)
![Signed commit
%](https://img.shields.io/badge/Signed_Commits-100%25-lightgrey.svg)
[![Linux build
Status](https://travis-ci.org/hrbrmstr/pwhois.svg?branch=master)](https://travis-ci.org/hrbrmstr/pwhois)
![Minimal R
Version](https://img.shields.io/badge/R%3E%3D-3.5.0-blue.svg)
![License](https://img.shields.io/badge/License-MIT-blue.svg)
# pwhois
Issue ‘WHOIS’ Queries and Process Various ‘WHOIS’ Resoponses
Issue 'WHOIS' Queries and Process Various 'WHOIS' Resoponses
## Description
WHOIS (pronounced as the phrase “who is”) is a query and response
protocol that is widely used for querying databases that store the
registered users or assignees of an Internet resource, such as a domain
name, an IP address block or an autonomous system, but is also used for
a wider range of other information. The protocol stores and delivers
database content in a human- readable format. The current iteration of
the WHOIS protocol was drafted by the Internet Society, and is
documented in RFC 3912. Tools are provided to issue query requests and
process query responses.
WHOIS (pronounced as the phrase "who is") is a query and response protocol
that is widely used for querying databases that store the registered users
or assignees of an Internet resource, such as a domain name, an IP address
block or an autonomous system, but is also used for a wider range of other
information. The protocol stores and delivers database content in a human-
readable format. The current iteration of the WHOIS protocol was drafted
by the Internet Society, and is documented in RFC 3912. Tools are provided
to issue query requests and process query responses.
## Whats Inside The Tin
## What's Inside The Tin
The following functions are implemented:
- `tidy_cymru`: Turn a Team Cymru server response into a data frame
- `tidy_pwhois`: Turn a Prefix WhoIs server response into a data frame
- `whois`: Issue a ‘WHOIS’ query and retrieve the response
- `tidy_cymru`: Turn a Team Cymru server response into a data frame
- `tidy_pwhois`: Turn a Prefix WhoIs server response into a data frame
- `whois_query`: Go WHOIS
- `whois`: Issue a 'WHOIS' query and retrieve the response
## Installation
``` r
remotes::install_git("https://git.rud.is/hrbrmstr/pwhois.git")
# or
remotes::install_gitlab("hrbrmstr/pwhois")
# or
remotes::install_bitbucket("hrbrmstr/pwhois")
# or
remotes::install_github("hrbrmstr/pwhois")
There is now a Golang dependency, which means you're better off doing:
```
git clone --recurse-submodules -j8 git@github.com:hrbrmstr/pwhois.git
```
NOTE: To use the ‘remotes’ install options you will need to have the
[{remotes} package](https://github.com/r-lib/remotes) installed.
and building from RStudio or the command line.
## Usage
``` r
```r
library(pwhois)
# current version
@ -63,16 +61,16 @@ packageVersion("pwhois")
A basic query:
``` {ex-01}
```{ex-01}
(res <- whois("17.253.144.10"))
str(tidy_pwhois(res), 1)
```
The Prefix WhoIs project supports some advanced queries including the
ability to search on any of their WHOIS registry fields:
The Prefix WhoIs project supports some advanced queries including the ability to search on any of their WHOIS registry fields:
``` r
```r
(res <- whois("registry org-name=apple, inc"))
## [1] "Org-Record: 0" "Org-ID: GRNA"
## [3] "Org-Name: Green Apple, Inc." "Can-Allocate: 0"
@ -80,81 +78,85 @@ ability to search on any of their WHOIS registry fields:
## [7] "State: MI" "Postal-Code: 49512-2070"
## [9] "Country: US" "Register-Date: 1997-12-19"
## [11] "Update-Date: 2011-09-24" "Create-Date: Nov 23 2005 02:48:10"
## [13] "Modify-Date: Feb 13 2021 01:35:47" "Admin-0-Handle: INE-ARIN"
## [13] "Modify-Date: Apr 24 2021 02:02:02" "Admin-0-Handle: INE-ARIN"
## [15] "NOC-0-Handle: INE-ARIN" "Abuse-0-Handle: INE-ARIN"
## [17] "Tech-0-Handle: INE-ARIN" "Referral-Server: rwhois://rwhois.iserv.net:4321"
## [19] "Comment: http://www.greenapple.com" "Org-Record: 1"
## [21] "Org-ID: Network of Apple, Inc." "Org-Name: Network of Apple, Inc."
## [23] "Can-Allocate: 1" "Register-Date: 2011-03-02"
## [25] "Update-Date: 2011-03-02" "Create-Date: Mar 01 2011 13:07:13"
## [27] "Modify-Date: Mar 01 2011 13:07:13" "Org-Record: 2"
## [29] "Org-ID: C03342993" "Org-Name: APPLE, INC - CORP PROJECT"
## [31] "Can-Allocate: 0" "Street-1: 1 INFINITE LOOP # MS60"
## [33] "City: CUPERTINO" "State: CA"
## [35] "Postal-Code: 95014-2083" "Country: US"
## [37] "Register-Date: 2013-03-14" "Update-Date: 2013-03-14"
## [39] "Create-Date: May 30 2013 16:03:51" "Modify-Date: Feb 13 2021 01:35:47"
## [41] "Org-Record: 3" "Org-ID: C03342938"
## [43] "Org-Name: APPLE, INC - CORP PROJECT" "Can-Allocate: 0"
## [45] "Street-1: 1 INFINITE LOOP # MS60" "City: CUPERTINO"
## [47] "State: CA" "Postal-Code: 95014-2083"
## [49] "Country: US" "Register-Date: 2013-03-14"
## [51] "Update-Date: 2013-03-14" "Create-Date: May 30 2013 16:03:51"
## [53] "Modify-Date: Feb 13 2021 01:35:47" "Org-Record: 4"
## [55] "Org-ID: C03342954" "Org-Name: APPLE, INC - CORP PROJECT"
## [57] "Can-Allocate: 0" "Street-1: 1 INFINITE LOOP # MS60"
## [59] "City: CUPERTINO" "State: CA"
## [61] "Postal-Code: 95014-2083" "Country: US"
## [63] "Register-Date: 2013-03-14" "Update-Date: 2013-03-14"
## [65] "Create-Date: May 30 2013 16:03:51" "Modify-Date: Feb 13 2021 01:35:47"
## [67] "Org-Record: 5" "Org-ID: Network of Apple, Inc."
## [69] "Org-Name: Network of Apple, Inc." "Can-Allocate: 1"
## [71] "Register-Date: 2013-05-31" "Update-Date: 2013-05-31"
## [73] "Create-Date: May 30 2013 18:55:56" "Modify-Date: May 30 2013 18:55:56"
## [75] "Org-Record: 6" "Org-ID: C04676970"
## [77] "Org-Name: APPLE, INC - CORP PROJECT" "Can-Allocate: 0"
## [79] "Street-1: 1 INFINITE LOOP # MS60" "City: CUPERTINO"
## [81] "State: CA" "Postal-Code: 95014-2083"
## [83] "Country: US" "Register-Date: 2013-08-21"
## [85] "Update-Date: 2013-08-21" "Create-Date: Aug 23 2013 02:32:19"
## [87] "Modify-Date: Feb 13 2021 01:35:47" "Org-Record: 7"
## [89] "Org-ID: C04716251" "Org-Name: APPLE, INC - RETAIL PROJECT"
## [91] "Can-Allocate: 0" "Street-1: 1500 POLARIS PKWY"
## [93] "City: COLUMBUS" "State: OH"
## [95] "Postal-Code: 43240" "Country: US"
## [97] "Register-Date: 2013-09-30" "Update-Date: 2013-09-30"
## [99] "Create-Date: Oct 02 2013 01:52:33" "Modify-Date: Mar 23 2015 08:01:17"
## [101] "Org-Record: 8" "Org-ID: Apple, Inc."
## [103] "Org-Name: Apple, Inc." "Can-Allocate: 1"
## [105] "Register-Date: 2014-10-19" "Update-Date: 2014-10-19"
## [107] "Create-Date: Oct 18 2014 05:49:09" "Modify-Date: Oct 18 2014 05:49:09"
## [109] "Org-Record: 9" "Org-ID: C06092907"
## [111] "Org-Name: Apple, Inc IP - MRC" "Can-Allocate: 0"
## [113] "Street-1: 21625 Gresham Dr" "City: Ashburn"
## [115] "State: VA" "Postal-Code: 20147"
## [117] "Country: US" "Register-Date: 2016-04-14"
## [119] "Update-Date: 2016-06-21" "Create-Date: Dec 13 2016 10:45:20"
## [121] "Modify-Date: Feb 13 2021 01:35:47" "Org-Record: 10"
## [123] "Org-ID: C07098191" "Org-Name: APPLE, INC.-COLOCATION - APPLE, INC."
## [125] "Can-Allocate: 0" "Street-1: 340 CUMBERLAND AVE"
## [127] "City: PORTLAND" "State: ME"
## [129] "Postal-Code: 04101" "Country: US"
## [131] "Register-Date: 2018-10-24" "Update-Date: 2018-10-24"
## [133] "Create-Date: Oct 26 2018 02:13:03" "Modify-Date: Feb 13 2021 01:35:47"
## [23] "Can-Allocate: 1" "Country: IT"
## [25] "Register-Date: 2014-11-19" "Update-Date: 2015-05-26"
## [27] "Create-Date: Mar 01 2011 13:07:13" "Modify-Date: Apr 24 2021 00:01:35"
## [29] "NOC-0-Handle: EU-IBM-NIC-MNT" "Abuse-0-Handle: DUMY-RIPE"
## [31] "Tech-0-Handle: DUMY-RIPE" "Org-Record: 2"
## [33] "Org-ID: C03342993" "Org-Name: APPLE, INC - CORP PROJECT"
## [35] "Can-Allocate: 0" "Street-1: 1 INFINITE LOOP # MS60"
## [37] "City: CUPERTINO" "State: CA"
## [39] "Postal-Code: 95014-2083" "Country: US"
## [41] "Register-Date: 2013-03-14" "Update-Date: 2013-03-14"
## [43] "Create-Date: May 30 2013 16:03:51" "Modify-Date: Apr 24 2021 02:02:02"
## [45] "Org-Record: 3" "Org-ID: C03342938"
## [47] "Org-Name: APPLE, INC - CORP PROJECT" "Can-Allocate: 0"
## [49] "Street-1: 1 INFINITE LOOP # MS60" "City: CUPERTINO"
## [51] "State: CA" "Postal-Code: 95014-2083"
## [53] "Country: US" "Register-Date: 2013-03-14"
## [55] "Update-Date: 2013-03-14" "Create-Date: May 30 2013 16:03:51"
## [57] "Modify-Date: Apr 24 2021 02:02:02" "Org-Record: 4"
## [59] "Org-ID: C03342954" "Org-Name: APPLE, INC - CORP PROJECT"
## [61] "Can-Allocate: 0" "Street-1: 1 INFINITE LOOP # MS60"
## [63] "City: CUPERTINO" "State: CA"
## [65] "Postal-Code: 95014-2083" "Country: US"
## [67] "Register-Date: 2013-03-14" "Update-Date: 2013-03-14"
## [69] "Create-Date: May 30 2013 16:03:51" "Modify-Date: Apr 24 2021 02:02:02"
## [71] "Org-Record: 5" "Org-ID: Network of Apple, Inc."
## [73] "Org-Name: Network of Apple, Inc." "Can-Allocate: 1"
## [75] "Register-Date: 2013-05-31" "Update-Date: 2013-05-31"
## [77] "Create-Date: May 30 2013 18:55:56" "Modify-Date: May 30 2013 18:55:56"
## [79] "Org-Record: 6" "Org-ID: C04676970"
## [81] "Org-Name: APPLE, INC - CORP PROJECT" "Can-Allocate: 0"
## [83] "Street-1: 1 INFINITE LOOP # MS60" "City: CUPERTINO"
## [85] "State: CA" "Postal-Code: 95014-2083"
## [87] "Country: US" "Register-Date: 2013-08-21"
## [89] "Update-Date: 2013-08-21" "Create-Date: Aug 23 2013 02:32:19"
## [91] "Modify-Date: Apr 24 2021 02:02:02" "Org-Record: 7"
## [93] "Org-ID: C04716251" "Org-Name: APPLE, INC - RETAIL PROJECT"
## [95] "Can-Allocate: 0" "Street-1: 1500 POLARIS PKWY"
## [97] "City: COLUMBUS" "State: OH"
## [99] "Postal-Code: 43240" "Country: US"
## [101] "Register-Date: 2013-09-30" "Update-Date: 2013-09-30"
## [103] "Create-Date: Oct 02 2013 01:52:33" "Modify-Date: Mar 23 2015 08:01:17"
## [105] "Org-Record: 8" "Org-ID: Apple, Inc."
## [107] "Org-Name: Apple, Inc." "Can-Allocate: 1"
## [109] "Country: US" "Register-Date: 2016-05-19"
## [111] "Update-Date: 2016-05-19" "Create-Date: Oct 18 2014 05:49:09"
## [113] "Modify-Date: Apr 24 2021 00:01:35" "NOC-0-Handle: HRW-NOC"
## [115] "Abuse-0-Handle: DUMY-RIPE" "Tech-0-Handle: DUMY-RIPE"
## [117] "Org-Record: 9" "Org-ID: C06092907"
## [119] "Org-Name: Apple, Inc IP - MRC" "Can-Allocate: 0"
## [121] "Street-1: 21625 Gresham Dr" "City: Ashburn"
## [123] "State: VA" "Postal-Code: 20147"
## [125] "Country: US" "Register-Date: 2016-04-14"
## [127] "Update-Date: 2016-06-21" "Create-Date: Dec 13 2016 10:45:20"
## [129] "Modify-Date: Apr 24 2021 02:02:02" "Org-Record: 10"
## [131] "Org-ID: C07098191" "Org-Name: APPLE, INC.-COLOCATION - APPLE, INC."
## [133] "Can-Allocate: 0" "Street-1: 340 CUMBERLAND AVE"
## [135] "City: PORTLAND" "State: ME"
## [137] "Postal-Code: 04101" "Country: US"
## [139] "Register-Date: 2018-10-24" "Update-Date: 2018-10-24"
## [141] "Create-Date: Oct 26 2018 02:13:03" "Modify-Date: Apr 24 2021 02:02:02"
tibble::as_tibble(tidy_pwhois(res))
## # A tibble: 11 x 19
## org_record org_id org_name can_allocate street_1 city state postal_code country register_date update_date
## <chr> <chr> <chr> <lgl> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 0 GRNA Green A… FALSE 5222 33… Gran… MI 49512-2070 US 1997-12-19 2011-09-24
## 2 1 Netwo… Network… TRUE <NA> <NA> <NA> <NA> <NA> 2011-03-02 2011-03-02
## 2 1 Netwo… Network… TRUE <NA> <NA> <NA> <NA> IT 2014-11-19 2015-05-26
## 3 2 C0334… APPLE, … FALSE 1 INFIN… CUPE… CA 95014-2083 US 2013-03-14 2013-03-14
## 4 3 C0334… APPLE, … FALSE 1 INFIN… CUPE… CA 95014-2083 US 2013-03-14 2013-03-14
## 5 4 C0334… APPLE, … FALSE 1 INFIN… CUPE… CA 95014-2083 US 2013-03-14 2013-03-14
## 6 5 Netwo… Network… TRUE <NA> <NA> <NA> <NA> <NA> 2013-05-31 2013-05-31
## 7 6 C0467… APPLE, … FALSE 1 INFIN… CUPE… CA 95014-2083 US 2013-08-21 2013-08-21
## 8 7 C0471… APPLE, … FALSE 1500 PO… COLU… OH 43240 US 2013-09-30 2013-09-30
## 9 8 Apple… Apple, … TRUE <NA> <NA> <NA> <NA> <NA> 2014-10-19 2014-10-19
## 9 8 Apple… Apple, … TRUE <NA> <NA> <NA> <NA> US 2016-05-19 2016-05-19
## 10 9 C0609… Apple, … FALSE 21625 G… Ashb… VA 20147 US 2016-04-14 2016-06-21
## 11 10 C0709… APPLE, … FALSE 340 CUM… PORT… ME 04101 US 2018-10-24 2018-10-24
## # … with 8 more variables: create_date <dttm>, modify_date <dttm>, admin_0_handle <chr>, noc_0_handle <chr>,
@ -163,13 +165,14 @@ tibble::as_tibble(tidy_pwhois(res))
and can return results in different formats including Team Cymru tables:
``` r
```r
(res <- whois('type=cymru 17.253.144.10'))
## [1] "AS | IP | ORG NAME | CC | NET NAME | AS ORG NAME"
## [2] "714 | 17.253.144.10 | Apple Inc. | US | APPLE-WWNET | Apple Inc."
str(tidy_cymru(res), 1)
## 'data.frame': 1 obs. of 6 variables:
## 'data.frame': 1 obs. of 6 variables:
## $ as : chr "714"
## $ ip : chr "17.253.144.10"
## $ org name : chr "Apple Inc."
@ -178,15 +181,16 @@ str(tidy_cymru(res), 1)
## $ as org name: chr "Apple Inc."
```
That `tidy_cymru()` function can be used on responses from the Team
Cymru WHOIS service as well:
That `tidy_cymru()` function can be used on responses from the Team Cymru
WHOIS service as well:
``` r
```r
(res <- whois('-v AS23028', "whois.cymru.com"))
## [1] "AS | CC | Registry | Allocated | AS Name" "23028 | US | arin | 2002-01-04 | TEAM-CYMRU, US"
str(tidy_cymru(res))
## 'data.frame': 1 obs. of 5 variables:
## 'data.frame': 1 obs. of 5 variables:
## $ as : chr "23028"
## $ cc : chr "US"
## $ registry : chr "arin"
@ -194,30 +198,110 @@ str(tidy_cymru(res))
## $ as name : chr "TEAM-CYMRU, US"
```
The Prefix WhoIs project can also return responses in Routing Policy
Specification Language (RPSL), but there is no ‘tidy’ function for this
format yet:
The Prefix WhoIs project can also return responses in Routing Policy Specification Language (RPSL), but there is no 'tidy' function for this format yet:
``` r
```r
whois('type=rpsl 17.253.144.10')
## [1] "Origin: AS714" "Route: 17.253.144.0/21"
## [3] "Date: 20210213" "AS-Org-Name: Apple Inc."
## [3] "Date: 20210424" "AS-Org-Name: Apple Inc."
## [5] "Org-Name: Apple Inc." "Net-Name: APPLE-WWNET"
## [7] "Source: PWHOIS Server 208.74.248.120:43 at 20210213"
## [7] "Source: PWHOIS Server 208.74.248.120:43 at 20210424"
```
Old-school WHOIS
```r
str(pwhois::whois_query("r-project.org"), 2)
## List of 5
## $ domain :List of 11
## ..$ id : chr "D11753086-LROR"
## ..$ domain : chr "r-project.org"
## ..$ punycode : chr "r-project.org"
## ..$ name : chr "r-project"
## ..$ extension : chr "org"
## ..$ whois_server : chr "whois.gandi.net"
## ..$ status : chr "clienttransferprohibited"
## ..$ name_servers : chr [1:4] "ns1.wu-wien.ac.at" "ns2.wu-wien.ac.at" "ns1.urbanek.info" "ns2.urbanek.info"
## ..$ created_date : chr "1999-10-27T14:39:07Z"
## ..$ updated_date : chr "2019-07-03T14:01:15Z"
## ..$ expiration_date: chr "2023-10-27T15:39:07Z"
## $ registrar :List of 5
## ..$ id : chr "81"
## ..$ name : chr "GANDI SAS"
## ..$ phone : chr "+33.170377661"
## ..$ email : chr "abuse@support.gandi.net"
## ..$ referral_url: chr "http://www.gandi.net"
## $ registrant :List of 10
## ..$ id : chr "REDACTED FOR PRIVACY"
## ..$ name : chr "REDACTED FOR PRIVACY"
## ..$ organization: chr "R Foundation for Statistical Computing"
## ..$ street : chr "REDACTED FOR PRIVACY"
## ..$ city : chr "REDACTED FOR PRIVACY"
## ..$ postal_code : chr "REDACTED FOR PRIVACY"
## ..$ country : chr "AT"
## ..$ phone : chr "REDACTED FOR PRIVACY"
## ..$ fax : chr "REDACTED FOR PRIVACY"
## ..$ email : chr "add47e049106e1f37ddc6277e9d401d8-1071757@contact.gandi.net"
## $ administrative:List of 10
## ..$ id : chr "REDACTED FOR PRIVACY"
## ..$ name : chr "REDACTED FOR PRIVACY"
## ..$ street : chr "63-65 boulevard Massena"
## ..$ city : chr "Paris"
## ..$ province : chr "Paris"
## ..$ postal_code: chr "75013"
## ..$ country : chr "FR"
## ..$ phone : chr "+33.170377666"
## ..$ fax : chr "+33.143730576"
## ..$ email : chr "be8b14b26f4e2a7daecefa6c20056f57-838661@contact.gandi.net"
## $ technical :List of 10
## ..$ id : chr "REDACTED FOR PRIVACY"
## ..$ name : chr "REDACTED FOR PRIVACY"
## ..$ street : chr "63-65 boulevard Massena"
## ..$ city : chr "Paris"
## ..$ province : chr "Paris"
## ..$ postal_code: chr "75013"
## ..$ country : chr "FR"
## ..$ phone : chr "+33.170377666"
## ..$ fax : chr "+33.143730576"
## ..$ email : chr "be8b14b26f4e2a7daecefa6c20056f57-838661@contact.gandi.net"
```
## pwhois Metrics
| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) |
|:-----|---------:|-----:|----:|-----:|------------:|----:|---------:|-----:|
| R | 7 | 0.44 | 303 | 0.47 | 110 | 0.4 | 196 | 0.41 |
| Rmd | 1 | 0.06 | 17 | 0.03 | 29 | 0.1 | 44 | 0.09 |
| SUM | 8 | 0.50 | 320 | 0.50 | 139 | 0.5 | 240 | 0.50 |
clock Package Metrics for pwhois
Table: cloc Package Metrics for pwhois
|Lang | # Files| (%)| LoC| (%)| Blank lines| (%)| # Lines| (%)|
|:------------|-------:|----:|------:|----:|-----------:|----:|-------:|---:|
|Go | 1031| 0.40| 787752| 0.49| 21936| 0.48| 80696| 0.5|
|JSON | 183| 0.07| 9131| 0.01| 0| 0.00| 0| 0.0|
|XML | 6| 0.00| 5802| 0.00| 228| 0.00| 20| 0.0|
|HTML | 10| 0.00| 2214| 0.00| 441| 0.01| 16| 0.0|
|R | 8| 0.00| 307| 0.00| 113| 0.00| 203| 0.0|
|Forth | 3| 0.00| 303| 0.00| 24| 0.00| 0| 0.0|
|ReasonML | 2| 0.00| 201| 0.00| 16| 0.00| 0| 0.0|
|HCL | 2| 0.00| 192| 0.00| 16| 0.00| 0| 0.0|
|Perl | 2| 0.00| 191| 0.00| 16| 0.00| 0| 0.0|
|C++ | 2| 0.00| 134| 0.00| 19| 0.00| 0| 0.0|
|Prolog | 2| 0.00| 134| 0.00| 24| 0.00| 0| 0.0|
|m4 | 2| 0.00| 132| 0.00| 17| 0.00| 0| 0.0|
|Bourne Shell | 3| 0.00| 109| 0.00| 20| 0.00| 0| 0.0|
|Tcl/Tk | 2| 0.00| 86| 0.00| 18| 0.00| 0| 0.0|
|Rust | 2| 0.00| 65| 0.00| 18| 0.00| 0| 0.0|
|Dockerfile | 2| 0.00| 52| 0.00| 20| 0.00| 15| 0.0|
|C/C++ Header | 1| 0.00| 48| 0.00| 27| 0.00| 10| 0.0|
|YAML | 2| 0.00| 45| 0.00| 0| 0.00| 0| 0.0|
|xBase Header | 2| 0.00| 40| 0.00| 12| 0.00| 0| 0.0|
|Ruby | 2| 0.00| 34| 0.00| 8| 0.00| 0| 0.0|
|C | 1| 0.00| 30| 0.00| 20| 0.00| 4| 0.0|
|make | 2| 0.00| 25| 0.00| 7| 0.00| 4| 0.0|
|Assembly | 6| 0.00| 18| 0.00| 16| 0.00| 25| 0.0|
|Rmd | 1| 0.00| 17| 0.00| 33| 0.00| 50| 0.0|
|SUM | 1279| 0.50| 807062| 0.50| 23049| 0.50| 81043| 0.5|
## Code of Conduct
Please note that this project is released with a Contributor Code of
Conduct. By participating in this project you agree to abide by its
terms.
Please note that this project is released with a Contributor Code of Conduct.
By participating in this project you agree to abide by its terms.

16
man/whois_query.Rd

@ -0,0 +1,16 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/go-whois.R
\name{whois_query}
\alias{whois_query}
\title{Go WHOIS}
\usage{
whois_query(query, server = "")
}
\arguments{
\item{query}{WHOIS query}
\item{server}{leave \code{""} for the default}
}
\description{
Go WHOIS
}

12
src/Makevars

@ -0,0 +1,12 @@
.PHONY: go
CC = clang -Qunused-arguments
CXX = clang++ -Qunused-arguments
CGO_CFLAGS = "$(ALL_CPPFLAGS)"
CGO_LDFLAGS = "$(PKG_LIBS) $(SHLIB_LIBADD) $(LIBR)"
GOPATH = $(CURDIR)/go
go:
rm -f *.h
CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) GOPATH=$(GOPATH) go build -o $(SHLIB) -x -work -buildmode=c-shared main

BIN
src/go/pkg/darwin_amd64/github.com/likexian/gokit/xjson.a

Binary file not shown.

BIN
src/go/pkg/darwin_amd64/github.com/likexian/whois-parser.a

Binary file not shown.

BIN
src/go/pkg/darwin_amd64/github.com/likexian/whois.a

Binary file not shown.

1
src/go/src/github.com/likexian/gokit

@ -0,0 +1 @@
Subproject commit b61fbc29e3def2ab2a67f1342bd1707ffcc4ec4d

1
src/go/src/github.com/likexian/whois

@ -0,0 +1 @@
Subproject commit ac91df9d4a9d8b26dc72e22add8abdf8bef48978

1
src/go/src/github.com/likexian/whois-parser

@ -0,0 +1 @@
Subproject commit 1b0c1f6a479bd8c1eb39158a6300b2030a83e238

1
src/go/src/golang.org/x/net

@ -0,0 +1 @@
Subproject commit 5f58ad60dda6b6eba34c424201d17c9fdc37953d

1
src/go/src/golang.org/x/text

@ -0,0 +1 @@
Subproject commit c2d28a6ddf6cb833e996ccb00cbb4206394958d2

54
src/go/src/main/main.c

@ -0,0 +1,54 @@
#include "_cgo_export.h"
#include <R_ext/Rdynload.h>
#include <stdlib.h>
#include <string.h>
// This gets called from Go and returns a character vector
SEXP MakeChar(char *json) {
if (json != NULL) {
SEXP value_vec = PROTECT(allocVector(STRSXP, 1));
SET_STRING_ELT(value_vec, 0, mkChar(json));
UNPROTECT(1);
return(value_vec);
} else {
return(R_NilValue);
}
}
// The thing we're going to call from a .R file
// It calls the Go `whois_query()` function which, in turn, calls MakeChar() above
SEXP R_whois_query(SEXP query, SEXP server) {
SEXP squery = STRING_ELT(query, 0);
SEXP sserver = STRING_ELT(server, 0);
GoString hquery = { (char*) CHAR(squery), Rf_xlength(squery) };
GoString hserver = { (char*) CHAR(sserver), Rf_xlength(sserver) };
SEXP out = whois_query(hquery, hserver);
return(out);
}
// Required "registration" code by CRAN
static const R_CallMethodDef CallEntries[] = {
{"R_whois_query", (DL_FUNC) &R_whois_query, 2},
{NULL, NULL, 0}
};
void R_init_pwhois(DllInfo *dll) {
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
}

33
src/go/src/main/main.go

@ -0,0 +1,33 @@
package main
/*
#define USE_RINTERNALS
#include <R.h>
#include <Rinternals.h>
SEXP MakeChar(char *json);
*/
import "C"
import "github.com/likexian/gokit/xjson"
import "github.com/likexian/whois"
import whoisparser "github.com/likexian/whois-parser"
//export whois_query
func whois_query(input string, server string) C.SEXP {
text, err := whois.Whois(input, server)
if err != nil { return(C.R_NilValue) }
info, err := whoisparser.Parse(text)
if err != nil { return(C.R_NilValue) }
data, err := xjson.PrettyDumps(info)
if err != nil { return(C.R_NilValue) }
//return(C.R_NilValue)
return(C.MakeChar(C.CString(data)))
}
func main() {}

0
src/init.c

85
src/pwhois.h

@ -0,0 +1,85 @@
/* Code generated by cmd/cgo; DO NOT EDIT. */
/* package main */
#line 1 "cgo-builtin-export-prolog"
#include <stddef.h> /* for ptrdiff_t below */
#ifndef GO_CGO_EXPORT_PROLOGUE_H
#define GO_CGO_EXPORT_PROLOGUE_H
#ifndef GO_CGO_GOSTRING_TYPEDEF
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
#endif
#endif
/* Start of preamble from import "C" comments. */
#line 3 "main.go"
#define USE_RINTERNALS
#include <R.h>
#include <Rinternals.h>
SEXP MakeChar(char *json);
#line 1 "cgo-generated-wrapper"
/* End of preamble from import "C" comments. */
/* Start of boilerplate cgo prologue. */
#line 1 "cgo-gcc-export-header-prolog"
#ifndef GO_CGO_PROLOGUE_H
#define GO_CGO_PROLOGUE_H
typedef signed char GoInt8;
typedef unsigned char GoUint8;
typedef short GoInt16;
typedef unsigned short GoUint16;
typedef int GoInt32;
typedef unsigned int GoUint32;
typedef long long GoInt64;
typedef unsigned long long GoUint64;
typedef GoInt64 GoInt;
typedef GoUint64 GoUint;
typedef __SIZE_TYPE__ GoUintptr;
typedef float GoFloat32;
typedef double GoFloat64;
typedef float _Complex GoComplex64;
typedef double _Complex GoComplex128;
/*
static assertion to make sure the file is being used on architecture
at least with matching size of GoInt.
*/
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
#ifndef GO_CGO_GOSTRING_TYPEDEF
typedef _GoString_ GoString;
#endif
typedef void *GoMap;
typedef void *GoChan;
typedef struct { void *t; void *v; } GoInterface;
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
#endif
/* End of boilerplate cgo prologue. */
#ifdef __cplusplus
extern "C" {
#endif
extern SEXP whois_query(GoString input, GoString server);
#ifdef __cplusplus
}
#endif
Loading…
Cancel
Save