Browse Source

initial commit

master
boB Rudis 4 years ago
parent
commit
764b847719
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 21
      .Rbuildignore
  2. 1
      .codecov.yml
  3. 9
      .gitignore
  4. 15
      .gitmodules
  5. 6
      .travis.yml
  6. 25
      CONDUCT.md
  7. 22
      DESCRIPTION
  8. 4
      NAMESPACE
  9. 2
      NEWS.md
  10. 55
      README.Rmd
  11. 75
      README.md
  12. 21
      caa.Rproj
  13. 4
      inst/tinytest/test_caa.R
  14. 22
      man/caa.Rd
  15. 17
      man/caa_dig.Rd
  16. 12
      src/Makevars
  17. 76
      src/caa.h
  18. BIN
      src/go/pkg/darwin_amd64/github.com/weppos/dnscaa.a
  19. 1
      src/go/src/github.com/miekg/dns
  20. 1
      src/go/src/github.com/weppos/dnscaa
  21. 1
      src/go/src/golang.org/x/crypto
  22. 1
      src/go/src/golang.org/x/net
  23. 1
      src/go/src/golang.org/x/sys
  24. 33
      src/go/src/main/main.c
  25. 18
      src/go/src/main/main.go
  26. 5
      tests/tinytest.R

21
.Rbuildignore

@ -0,0 +1,21 @@
^.vscode$
^.*\.Rproj$
^\.Rproj\.user$
^\.travis\.yml$
^README\.*Rmd$
^README\.*html$
^NOTES\.*Rmd$
^NOTES\.*html$
^\.codecov\.yml$
^README_files$
^doc$
^docs$
^tmp$
^notes$
^CONDUCT.*$
^CODE.*$
^\.gitlab-ci\.yml$
^\.vscode$
^CRAN-RELEASE$
^appveyor\.yml$
^tools$

1
.codecov.yml

@ -0,0 +1 @@
comment: false

9
.gitignore

@ -0,0 +1,9 @@
.DS_Store
.Rproj.user
.Rhistory
.RData
.Rproj
README_cache
src/*.o
src/*.so
src/*.dll

15
.gitmodules

@ -0,0 +1,15 @@
[submodule "src/go/src/golang.org/x/crypto"]
path = src/go/src/golang.org/x/crypto
url = https://go.googlesource.com/crypto
[submodule "src/go/src/golang.org/x/net"]
path = src/go/src/golang.org/x/net
url = https://go.googlesource.com/net
[submodule "src/go/src/golang.org/x/sys"]
path = src/go/src/golang.org/x/sys
url = https://go.googlesource.com/sys
[submodule "src/go/src/github.com/miekg/dns"]
path = src/go/src/github.com/miekg/dns
url = https://github.com/miekg/dns
[submodule "src/go/src/github.com/weppos/dnscaa"]
path = src/go/src/github.com/weppos/dnscaa
url = https://github.com/weppos/dnscaa

6
.travis.yml

@ -0,0 +1,6 @@
language: R
sudo: false
cache: packages
after_success:
- Rscript -e 'covr::codecov()'

25
CONDUCT.md

@ -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/

22
DESCRIPTION

@ -0,0 +1,22 @@
Package: caa
Type: Package
Title: R Wrapper for the Go dnscaa Library
Version: 0.1.0
Date: 2020-03-06
Authors@R: c(
person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5670-2640"))
)
Maintainer: Bob Rudis <bob@rud.is>
Description: Experimental R wrapper for the Go dnscall library.
URL: https://gitlab.com/hrbrmstr/caa
BugReports: https://gitlab.com/hrbrmstr/caa/issues
Encoding: UTF-8
License: AGPL
SystemRequirements: go, GNU make
Suggests:
covr, tinytest
Depends:
R (>= 3.2.0)
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.0.2

4
NAMESPACE

@ -0,0 +1,4 @@
# Generated by roxygen2: do not edit by hand
export(caa_dig)
useDynLib(caa)

2
NEWS.md

@ -0,0 +1,2 @@
0.1.0
* Initial release

55
README.Rmd

@ -0,0 +1,55 @@
---
output: rmarkdown::github_document
editor_options:
chunk_output_type: console
---
```{r pkg-knitr-opts, include=FALSE}
hrbrpkghelpr::global_opts()
```
```{r badges, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::stinking_badges()
```
```{r description, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::yank_title_and_description()
```
## What's Inside The Tin
The following functions are implemented:
```{r ingredients, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::describe_ingredients()
```
## Installation
```{r install-ex, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::install_block()
```
## Usage
```{r lib-ex}
library(caa)
# current version
packageVersion("caa")
```
```{r ex-1}
caa_dig("google.com")
```
## caa Metrics
```{r cloc, echo=FALSE}
cloc::cloc_pkg_md()
```
## 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.

75
README.md

@ -0,0 +1,75 @@
[![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/caa.svg?branch=master)](https://travis-ci.org/hrbrmstr/caa)
![Minimal R
Version](https://img.shields.io/badge/R%3E%3D-3.2.0-blue.svg)
![License](https://img.shields.io/badge/License-AGPL-blue.svg)
# caa
R Wrapper for the Go dnscaa Library
## Description
Experimental R wrapper for the Go dnscall library.
## What’s Inside The Tin
The following functions are implemented:
- `caa_dig`: Retrieve the first CAA issuer value for a domain (if any)
## Installation
``` r
remotes::install_gitlab("hrbrmstr/caa")
```
NOTE: To use the ‘remotes’ install options you will need to have the
[{remotes} package](https://github.com/r-lib/remotes) installed.
## Usage
``` r
library(caa)
# current version
packageVersion("caa")
## [1] '0.1.0'
```
``` r
caa_dig("google.com")
## [1] "pki.goog"
```
## caa Metrics
| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) |
| :----------------- | -------: | ---: | -----: | ---: | ----------: | ---: | -------: | ---: |
| Go | 1293 | 0.92 | 374699 | 0.95 | 40503 | 0.95 | 39876 | 0.95 |
| Assembly | 69 | 0.05 | 10426 | 0.03 | 1258 | 0.03 | 1424 | 0.03 |
| XML | 1 | 0.00 | 4780 | 0.01 | 228 | 0.01 | 13 | 0.00 |
| HTML | 10 | 0.01 | 2214 | 0.01 | 441 | 0.01 | 16 | 0.00 |
| Bourne Shell | 5 | 0.00 | 798 | 0.00 | 113 | 0.00 | 429 | 0.01 |
| C | 6 | 0.00 | 332 | 0.00 | 100 | 0.00 | 77 | 0.00 |
| Dockerfile | 3 | 0.00 | 91 | 0.00 | 27 | 0.00 | 23 | 0.00 |
| Bourne Again Shell | 2 | 0.00 | 72 | 0.00 | 12 | 0.00 | 6 | 0.00 |
| YAML | 2 | 0.00 | 45 | 0.00 | 0 | 0.00 | 0 | 0.00 |
| C/C++ Header | 1 | 0.00 | 42 | 0.00 | 24 | 0.00 | 10 | 0.00 |
| make | 2 | 0.00 | 25 | 0.00 | 7 | 0.00 | 4 | 0.00 |
| Rmd | 1 | 0.00 | 9 | 0.00 | 16 | 0.00 | 30 | 0.00 |
| R | 3 | 0.00 | 7 | 0.00 | 2 | 0.00 | 15 | 0.00 |
## 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.

21
caa.Rproj

@ -0,0 +1,21 @@
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX
StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageBuildArgs: --resave-data
PackageRoxygenize: rd,collate,namespace

4
inst/tinytest/test_caa.R

@ -0,0 +1,4 @@
# Placeholder with simple test
expect_equal(caa_dig("google.com"), "pki.goog")

22
man/caa.Rd

@ -0,0 +1,22 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/caa-package.R
\docType{package}
\name{caa}
\alias{caa}
\alias{caa-package}
\title{R Wrapper for the Go dnscaa Library}
\description{
Experimental R wrapper for the Go dnscaa library.
}
\seealso{
Useful links:
\itemize{
\item \url{https://gitlab.com/hrbrmstr/caa}
\item Report bugs at \url{https://gitlab.com/hrbrmstr/caa/issues}
}
}
\author{
Bob Rudis (bob@rud.is)
}
\keyword{internal}

17
man/caa_dig.Rd

@ -0,0 +1,17 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/caa-dig.R
\name{caa_dig}
\alias{caa_dig}
\title{Retrieve the first CAA issuer value for a domain (if any)}
\usage{
caa_dig(x)
}
\arguments{
\item{x}{domain name}
}
\description{
Retrieve the first CAA issuer value for a domain (if any)
}
\examples{
caa_dig("google.com")
}

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 caa.h
CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) GOPATH=$(GOPATH) go build -o $(SHLIB) -x -buildmode=c-shared main

76
src/caa.h

@ -0,0 +1,76 @@
/* 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. */
/* 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 char* caa_dig(GoString p0);
#ifdef __cplusplus
}
#endif

BIN
src/go/pkg/darwin_amd64/github.com/weppos/dnscaa.a

Binary file not shown.

1
src/go/src/github.com/miekg/dns

@ -0,0 +1 @@
Subproject commit 418631f446c1e9f995f3a9a462a85f4c3cd9d811

1
src/go/src/github.com/weppos/dnscaa

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

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

@ -0,0 +1 @@
Subproject commit 78000ba7a073cafc0278790f6bce552a0f25850e

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

@ -0,0 +1 @@
Subproject commit 244492dfa37ae2ce87222fd06250a03160745faa

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

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

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

@ -0,0 +1,33 @@
#define USE_RINTERNALS
#include <R.h>
#include <Rinternals.h>
#include <stdlib.h>
#include <string.h>
#include "_cgo_export.h"
// define R bridge functions here
#define SHORT_VEC_LENGTH(x) (((VECSEXP) (x))->vecsxp.length)
SEXP R_caa_dig(SEXP x) {
SEXP sx = STRING_ELT(x, 0);
GoString h = { (char*) CHAR(sx), SHORT_VEC_LENGTH(sx) };
char *res = caa_dig(h);
if (res != NULL) {
SEXP out = PROTECT(allocVector(STRSXP, 1));
SET_STRING_ELT(out, 0, mkChar(res));
UNPROTECT(1);
free(res);
return(out);
} else {
return(R_NilValue);
}
}

18
src/go/src/main/main.go

@ -0,0 +1,18 @@
package main
import "C"
import "github.com/weppos/dnscaa"
//export caa_dig
func caa_dig(hostname string) *C.char {
records, err := dnscaa.Lookup(hostname)
if err != nil {
return C.CString("")
} else {
out := records[0].Value
return(C.CString(out))
}
}
func main() {}

5
tests/tinytest.R

@ -0,0 +1,5 @@
if ( requireNamespace("tinytest", quietly=TRUE) ){
tinytest::test_package("caa")
}
Loading…
Cancel
Save