diff options
| -rw-r--r-- | Makefile | 24 | ||||
| -rw-r--r-- | README.md | 19 | ||||
| -rw-r--r-- | go.mod | 6 | ||||
| -rw-r--r-- | go.sum | 7 | ||||
| -rw-r--r-- | wrappers/java-android/README.md | 11 | ||||
| -rw-r--r-- | wrappers/php/Makefile | 4 | ||||
| -rw-r--r-- | wrappers/swift/README.md | 5 |
7 files changed, 49 insertions, 27 deletions
@@ -1,31 +1,29 @@ .PHONY: build test test-go test-wrappers clean build: - $(MAKE) -C exports build + $(MAKE) -C exports test: test-go test-wrappers test-go: go test -wrappers = $(wildcard wrappers/*/) +WRAPPERS ?= $(notdir $(patsubst %/,%,$(wildcard wrappers/*/))) -# Enable parallelism if -j is specified +# Enable parallelism if -j is specified, but first execute build test-wrappers: build - $(MAKE) $(foreach wrapper,$(wrappers),.test_$(wrapper)) + $(MAKE) $(foreach wrapper,$(WRAPPERS),.test-$(wrapper)) -# Enable parallelism if -j is specified -clean: - $(MAKE) .clean_libs $(foreach wrapper,$(wrappers),.clean_$(wrapper)) +clean: .clean_libs $(foreach wrapper,$(WRAPPERS),.clean-$(wrapper)) -.clean_libs: +.clean-libs: $(MAKE) -C exports clean # Define test & clean for each wrapper define wrapper_targets -.test_$(1): - $(MAKE) -C "$(1)" test -.clean_$(1): - $(MAKE) -C "$(1)" clean +.test-$(1): + $(MAKE) -C wrappers/$(1) test +.clean-$(1): + $(MAKE) -C wrappers/$(1) clean endef -$(foreach wrapper,$(wrappers),$(eval $(call wrapper_targets,$(wrapper)))) +$(foreach wrapper,$(WRAPPERS),$(eval $(call wrapper_targets,$(wrapper)))) @@ -3,14 +3,18 @@ This repository contains a Go library with functions that all EduVPN clients can use. The goal is to let EduVPN clients link against this library and gradually merge more common logic between EduVPN clients into this repository. -cgo is used to build the Go library into a shared dynamic library. Wrappers will be written using some FFI framework for -each language used in EduVPN clients to easily interface with the library. +[cgo](https://pkg.go.dev/cmd/cgo) is used to build the Go library into a shared dynamic library. Wrappers will be +written using some FFI framework for each language used in EduVPN clients to easily interface with the library. ## Functionality Currently, only verification of signatures on files from `disco.eduvpn.org` is supported. For now, these files have to be downloaded by the caller. +⚠️ The caller has to extract the timestamp from the file (JSON `"v"` tag), save it, and pass it to the Verify function +the next time that they call it. This prevents a rollback of a previous file. This functionality may be integrated into +the library in the future. + ## Requirements To run the Go tests, you will need [Go](https://go.dev/doc/install) 1.15 or later (add it to your `PATH`). To build the @@ -52,6 +56,8 @@ Build shared library for specified OS & architecture (example): make GOOS=windows GOARCH=386 ``` +To list all platforms supported by cgo, run `go tool dist list`. + Results will be output in `exports/lib/`. Usually you will need to specify the compiler when cross compiling, for example: @@ -74,7 +80,8 @@ Test wrappers (you will need compilers for all wrappers if you do this): make test-wrappers ``` -Specify `-j` to execute tests in parallel. +Specify `-j` to execute tests in parallel. You can specify specific wrappers to test by appending +e.g. `WRAPPERS="csharp php"`. Test both: @@ -89,7 +96,8 @@ make -j clean ``` Usually you won't need to do this, as changes in the library should automatically be incorporated in wrappers. -Specify `CLEAN_ALL=1` to also remove downloaded dependencies for some wrappers. +Specify `CLEAN_ALL=1` to also remove downloaded dependencies for some wrappers. You can clean individual wrappers by +executing clean in their directories, or specify `WRAPPERS=...`. Take a look at `wrappers/<lang>/README.md` for descriptions per wrapper. @@ -98,4 +106,5 @@ Take a look at `wrappers/<lang>/README.md` for descriptions per wrapper. - `verify.go`: main API - `verify_test.go` and `test_data/`: tests for API - `exports/`: C API interface -- `wrappers/`: Wrappers per language +- `exports/lib/`: built libraries per architecture per OS +- `wrappers/`: wrappers per language @@ -2,4 +2,8 @@ module eduvpn-common go 1.15 -require github.com/jedisct1/go-minisign v0.0.0-20211028175153-1c139d1cc84b +require ( + github.com/jedisct1/go-minisign v0.0.0-20211028175153-1c139d1cc84b + golang.org/x/crypto v0.0.0-20220208233918-bba287dce954 // indirect + golang.org/x/sys v0.0.0-20220207234003-57398862261d // indirect +) @@ -2,10 +2,17 @@ github.com/jedisct1/go-minisign v0.0.0-20211028175153-1c139d1cc84b h1:ZGiXF8sz7P github.com/jedisct1/go-minisign v0.0.0-20211028175153-1c139d1cc84b/go.mod h1:hQmNrgofl+IY/8L+n20H6E6PWBBTokdsv+q49j0QhsU= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220208233918-bba287dce954 h1:BkypuErRT9A9I/iljuaG3/zdMjd/J6m8tKKJQtGfSdA= +golang.org/x/crypto v0.0.0-20220208233918-bba287dce954/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220207234003-57398862261d h1:Bm7BNOQt2Qv7ZqysjeLjgCBanX+88Z/OtdvsrEv1Djc= +golang.org/x/sys v0.0.0-20220207234003-57398862261d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/wrappers/java-android/README.md b/wrappers/java-android/README.md index fe2660e..763c8d6 100644 --- a/wrappers/java-android/README.md +++ b/wrappers/java-android/README.md @@ -18,9 +18,10 @@ See the [list of Gradle releases](https://github.com/gradle/gradle/releases) and [list of Android Gradle plugin releases](https://maven.google.com/web/?q=com.android.tools.build#com.android.tools.build:gradle) . -Versions are managed per project by the Gradle wrapper (see `gradle*` files). Run `./gradlew --version` to get the -project Gradle version. Look at the dependencies in `/build.gradle` for the current Android Gradle plugin version. This -means that you do not need to install Gradle separately yourself. +Versions are managed per project by +the [Gradle wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html) (see `gradle*` files). +Run `./gradlew --version` to get the project Gradle version. Look at the dependencies in `/build.gradle` for the current +Android Gradle plugin version. This means that you do not need to install Gradle separately yourself. Currently, versions are Gradle 7.0.2 and Android Gradle plugin 7.0.4, which means you have to install a **JDK with a version between 11 and 16**. If desired, these can be upgraded to e.g. 7.4 and 7.1.1 respectively without problems, but @@ -55,8 +56,8 @@ Run Android instrumented tests on a new emulator: make android-test ``` -This uses [Gradle managed virtual devices](https://developer.android.com/studio/preview/features#gmd). This feature is -enabled in `gradle.properties`. It is normal that tests that pass are not logged. +This uses [Gradle managed virtual devices](https://developer.android.com/studio/preview/features#gmd). This experimental +feature is enabled in `gradle.properties`. It is normal that tests that pass are not logged. Run Android instrumented tests on an already running emulator: diff --git a/wrappers/php/Makefile b/wrappers/php/Makefile index f24eee7..758cfe3 100644 --- a/wrappers/php/Makefile +++ b/wrappers/php/Makefile @@ -9,7 +9,7 @@ export PATH := $(abspath vendor/bin):$(PATH) ifeq ($(COPY_LIB),1) COPY_LIB_DIR ?= lib endif -ifneq ($(COPY_LIB_DIR),) +ifdef COPY_LIB_DIR override COPY_LIB_DIR := $(COPY_LIB_DIR)/ endif @@ -27,7 +27,7 @@ install-header: .try-build-lib -e 's/^/#define FFI_LIB "$(subst /,\/,$(COPY_LIB_DIR))$(LIB_FILE)"\n\n/' \ \ "$(EXPORTS_LIB_SUBFOLDER_PATH)/$(LIB_NAME).h" >src/headers/$(LIB_NAME)_php.h -ifneq ($(COPY_LIB_DIR),) +ifdef COPY_LIB_DIR install "$(EXPORTS_LIB_SUBFOLDER_PATH)/$(LIB_FILE)" -Dt "$(COPY_LIB_DIR)" endif diff --git a/wrappers/swift/README.md b/wrappers/swift/README.md index 9b0fdfe..30642c4 100644 --- a/wrappers/swift/README.md +++ b/wrappers/swift/README.md @@ -19,7 +19,10 @@ Build `EduVpnCommon` using shared Go library for specified platform, e.g.: make GOOS=linux GOARCH=amd64 ``` -When using this library, you will need to make sure that the linker can find the shared Go library. +When using this library, you will need to make sure that the dynamic linker can find the shared Go library. + +Currently, `.dylib`s for multiple architectures generated by cgo are not merged into one. For a pointer on how to do +this, see [this](https://stackoverflow.com/q/22783453). <details><summary>Windows</summary><small> On Windows, you will also need to generate a .lib import library for the .dll. You can |
