Skip to content

Commit

Permalink
Merge pull request #286 from ivpn/task/upgrade-wireguard-kotlin1.8.0-…
Browse files Browse the repository at this point in the history
…agp8.0.2-tools

Upgrade WireGuard
  • Loading branch information
jurajhilje authored Nov 23, 2023
2 parents 7d80972 + 0a74890 commit 398b6b3
Show file tree
Hide file tree
Showing 29 changed files with 132 additions and 268 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
- name: Install liboqs dependencies
run: sudo apt-get update && sudo apt-get install -y astyle cmake gcc ninja-build libssl-dev python3-pytest python3-pytest-xdist unzip xsltproc doxygen graphviz python3-yaml valgrind

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: gradle

Expand Down
33 changes: 2 additions & 31 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ jobs:
- name: Checkout submodules
run: git submodule update --init --recursive

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: gradle

Expand All @@ -53,32 +53,3 @@ jobs:
uses: github/codeql-action/analyze@v2
with:
category: "/language:Java"

analyze_go:
name: Analyze Go
runs-on: ubuntu-latest

permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: go

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:Go"
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.6.20'
ext.kotlin_version = '1.8.0'
ext.kotlin_coroutines_version = '1.2.1'
ext.nav_version = '2.3.5'
ext.compose_version = '1.2.0-alpha08'
ext.dagger_version = '2.42'
ext.nav_version = '2.5.0'
ext.compose_version = '1.4.1'
ext.dagger_version = '2.44'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.3'
classpath 'com.android.tools.build:gradle:8.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
}
Expand Down Expand Up @@ -40,6 +40,6 @@ ext {
powerMockito = '1.6.2'
hamcrestVersion = '2.1'
espressoCore = '3.0.1'
lifecycleVersion = '2.3.1'
lifecycleVersion = '2.4.1'
coroutenes = '1.5.2'
}
43 changes: 20 additions & 23 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apply plugin: 'com.android.library'

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'

apply plugin: "androidx.navigation.safeargs.kotlin"

Expand All @@ -14,6 +13,8 @@ if (new File("keystore.properties").exists()) {
}

android {
namespace "net.ivpn.core"

signingConfigs {
release {
keyAlias keystoreProperties['release.key.alias']
Expand Down Expand Up @@ -81,11 +82,11 @@ android {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
jvmTarget = JavaVersion.VERSION_17
}
testOptions {
execution 'ANDROIDX_TEST_ORCHESTRATOR'
Expand All @@ -97,14 +98,6 @@ android {
path 'CMakeLists.txt'
}
}
androidExtensions {
experimental = true
}

dexOptions {
incremental true
javaMaxHeapSize "4g"
}

splits {
abi {
Expand Down Expand Up @@ -228,37 +221,37 @@ dependencies {
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'

//Used to support stream API from JAVA8 and JAVA9
//ToDo remove it in future
// Used to support stream API from JAVA8 and JAVA9
// ToDo remove it in future
implementation "net.sourceforge.streamsupport:android-retrofuture:$streamsupportVersion"
implementation "net.sourceforge.streamsupport:android-retrostreams:$streamsupportVersion"

//Sliding up panel
// Sliding up panel
implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0"

//Constraint layout
// Constraint layout
implementation "androidx.constraintlayout:constraintlayout:2.0.4"

// QR support
// QR support
implementation 'com.google.zxing:core:3.3.0'
implementation 'com.journeyapps:zxing-android-embedded:4.1.0@aar'

//Encrypted shared preference
// Encrypted shared preference
implementation "androidx.security:security-crypto:1.1.0-alpha03"

//Powerful library for logging
// Powerful library for logging
implementation 'org.slf4j:slf4j-api:1.7.24'
implementation 'org.slf4j:jul-to-slf4j:1.7.0'
implementation 'com.github.tony19:logback-android:2.0.0'

//Navigation component
// Navigation component
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"

//LiveData component
// LiveData component
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$rootProject.lifecycleVersion"

//Coroutines
// Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutenes"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutenes"

Expand All @@ -272,7 +265,7 @@ dependencies {
testImplementation 'org.powermock:powermock-module-junit4-rule:1.6.2'
testImplementation 'org.powermock:powermock-module-junit4:1.6.2'

//Dagger
// Dagger
kapt "com.google.dagger:dagger-compiler:$dagger_version"
implementation "com.google.dagger:dagger:$dagger_version"
annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
Expand All @@ -284,6 +277,10 @@ dependencies {

// liboqs
implementation project(path: ':liboqs-android')

// For crash logging.
implementation 'io.sentry:sentry-android:4.3.0'
implementation "androidx.multidex:multidex:2.0.1"
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import androidx.databinding.BindingAdapter
import net.ivpn.core.common.views.IPSelectorView
import net.ivpn.core.v2.viewmodel.LocationViewModel

@BindingAdapter("app:ipstate")
@BindingAdapter("ipstate")
fun setState(view: IPSelectorView, state: LocationViewModel.IPState) {
view.setState(state)
}

@BindingAdapter("app:ipStateListener")
@BindingAdapter("ipStateListener")
fun setStateListener(view: IPSelectorView, listener: LocationViewModel.OnIPStateChangedListener?) {
view.setStateListener(listener)
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,6 @@ import net.ivpn.core.v2.splittunneling.items.ApplicationItem
import java.io.File
import java.io.IOException

@BindingAdapter("android:src")
fun setImageUri(view: ImageView, imageUri: String?) {
if (imageUri == null) {
view.setImageURI(null)
} else {
view.setImageURI(Uri.parse(imageUri))
}
}

@BindingAdapter("android:src")
fun setImageUri(view: ImageView, imageUri: Uri?) {
view.setImageURI(imageUri)
}

@BindingAdapter("android:src")
fun setImageDrawable(view: ImageView, drawable: Drawable?) {
view.setImageDrawable(drawable)
Expand Down
6 changes: 2 additions & 4 deletions core/src/main/java/net/ivpn/core/common/pinger/PingDataSet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package net.ivpn.core.common.pinger
*/

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.map
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand All @@ -40,9 +40,7 @@ class PingDataSet @Inject constructor(
) {

val pings: MutableLiveData<MutableMap<Server, PingResultFormatter?>> = MutableLiveData()
val fastestServer = Transformations.map(pings) {
calculateFastestServer(it)
}
val fastestServer = pings.map { calculateFastestServer(it) }

private var _pings: MutableMap<Server, PingResultFormatter?> = mutableMapOf()

Expand Down
25 changes: 13 additions & 12 deletions core/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ add_executable(libwg.so ${WG_SOURCES})
target_include_directories(libwg.so PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/wireguard-tools/src/uapi/linux/" "${CMAKE_CURRENT_SOURCE_DIR}/wireguard-tools/src/")
target_compile_options(libwg.so PUBLIC -O3 -std=gnu11 -D_GNU_SOURCE -include ${CMAKE_CURRENT_SOURCE_DIR}/ndk-compat/compat.h -DHAVE_VISIBILITY_HIDDEN -DRUNSTATEDIR=\"/data/data/${ANDROID_PACKAGE_NAME}/cache\")

add_custom_target(libwg-go.so WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/libwg-go" COMMENT "Building wireguard-go" VERBATIM COMMAND make
ANDROID_ARCH_NAME=${ANDROID_ARCH_NAME}
ANDROID_C_COMPILER=${ANDROID_C_COMPILER}
ANDROID_TOOLCHAIN_ROOT=${ANDROID_TOOLCHAIN_ROOT}
ANDROID_LLVM_TRIPLE=${ANDROID_LLVM_TRIPLE}
ANDROID_SYSROOT=${ANDROID_SYSROOT}
ANDROID_PACKAGE_NAME=${ANDROID_PACKAGE_NAME}
GRADLE_USER_HOME=${GRADLE_USER_HOME}
CFLAGS=${CMAKE_C_FLAGS}\ -Wno-unused-command-line-argument
DESTDIR=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
BUILDDIR=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/../generated-src
)
add_custom_target(libwg-go.so WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/libwg-go" COMMENT "Building wireguard-go" VERBATIM COMMAND "${ANDROID_HOST_PREBUILTS}/bin/make"
ANDROID_ARCH_NAME=${ANDROID_ARCH_NAME}
ANDROID_PACKAGE_NAME=${ANDROID_PACKAGE_NAME}
GRADLE_USER_HOME=${GRADLE_USER_HOME}
CC=${CMAKE_C_COMPILER}
CFLAGS=${CMAKE_C_FLAGS}
LDFLAGS=${CMAKE_SHARED_LINKER_FLAGS}
SYSROOT=${CMAKE_SYSROOT}
TARGET=${CMAKE_C_COMPILER_TARGET}
DESTDIR=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
BUILDDIR=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/../generated-src
)

# Hack to make it actually build as part of the default target
add_dependencies(libwg.so libwg-go.so)
21 changes: 10 additions & 11 deletions core/tools/libwg-go/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
#
# Copyright © 2017-2019 WireGuard LLC. All Rights Reserved.
# Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.

BUILDDIR ?= $(CURDIR)/build
DESTDIR ?= $(CURDIR)/out
Expand All @@ -12,20 +12,20 @@ NDK_GO_ARCH_MAP_arm64 := arm64
NDK_GO_ARCH_MAP_mips := mipsx
NDK_GO_ARCH_MAP_mips64 := mips64x

CLANG_FLAGS := --target=$(ANDROID_LLVM_TRIPLE) --gcc-toolchain=$(ANDROID_TOOLCHAIN_ROOT) --sysroot=$(ANDROID_SYSROOT)
export CGO_CFLAGS := $(CLANG_FLAGS) $(CFLAGS)
export CGO_LDFLAGS := $(CLANG_FLAGS) $(LDFLAGS) -Wl,-soname=libwg-go.so
export CC := $(ANDROID_C_COMPILER)
comma := ,
CLANG_FLAGS := --target=$(TARGET) --sysroot=$(SYSROOT)
export CGO_CFLAGS := $(CLANG_FLAGS) $(subst -mthumb,-marm,$(CFLAGS))
export CGO_LDFLAGS := $(CLANG_FLAGS) $(patsubst -Wl$(comma)--build-id=%,-Wl$(comma)--build-id=none,$(LDFLAGS)) -Wl,-soname=libwg-go.so
export GOARCH := $(NDK_GO_ARCH_MAP_$(ANDROID_ARCH_NAME))
export GOOS := android
export CGO_ENABLED := 1

GO_VERSION := 1.16
GO_VERSION := 1.20.3
GO_PLATFORM := $(shell uname -s | tr '[:upper:]' '[:lower:]')-$(NDK_GO_ARCH_MAP_$(shell uname -m))
GO_TARBALL := go$(GO_VERSION).$(GO_PLATFORM).tar.gz
GO_HASH_darwin-amd64 := 6000a9522975d116bf76044967d7e69e04e982e9625330d9a539a8b45395f9a8
GO_HASH_darwin-arm64 := 4dac57c00168d30bbd02d95131d5de9ca88e04f2c5a29a404576f30ae9b54810
GO_HASH_linux-amd64 := 013a489ebb3e24ef3d915abe5b94c3286c070dfe0818d5bca8108f1d6e8440d2
GO_HASH_darwin-amd64 := c1e1161d6d859deb576e6cfabeb40e3d042ceb1c6f444f617c3c9d76269c3565
GO_HASH_darwin-arm64 := 86b0ed0f2b2df50fa8036eea875d1cf2d76cefdacf247c44639a1464b7e36b95
GO_HASH_linux-amd64 := 979694c2c25c735755bf26f4f45e19e64e4811d661dd07b8c010f7a8e18adfca

default: $(DESTDIR)/libwg-go.so

Expand All @@ -42,11 +42,10 @@ $(BUILDDIR)/go-$(GO_VERSION)/.prepared: $(GRADLE_USER_HOME)/caches/golang/$(GO_T
flock "$@.lock" -c ' \
[ -f "$@" ] && exit 0; \
tar -C "$(dir $@)" --strip-components=1 -xzf "$^" && \
patch -p1 -f -N -r- -d "$(dir $@)" < goruntime-boottime-over-monotonic.diff && \
touch "$@"'

$(DESTDIR)/libwg-go.so: export PATH := $(BUILDDIR)/go-$(GO_VERSION)/bin/:$(PATH)
$(DESTDIR)/libwg-go.so: $(BUILDDIR)/go-$(GO_VERSION)/.prepared go.mod
go build -tags linux -ldflags="-X golang.zx2c4.com/wireguard/ipc.socketDirectory=/data/data/$(ANDROID_PACKAGE_NAME)/cache/wireguard" -v -trimpath -o "$@" -buildmode c-shared
go build -tags linux -ldflags="-X golang.zx2c4.com/wireguard/ipc.socketDirectory=/data/data/$(ANDROID_PACKAGE_NAME)/cache/wireguard -buildid=" -v -trimpath -buildvcs=false -o "$@" -buildmode c-shared

.DELETE_ON_ERROR:
2 changes: 1 addition & 1 deletion core/tools/libwg-go/api-android.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: Apache-2.0
*
* Copyright (C) 2017-2019 Jason A. Donenfeld <[email protected]>. All Rights Reserved.
* Copyright © 2017-2022 Jason A. Donenfeld <[email protected]>. All Rights Reserved.
*/

package main
Expand Down
14 changes: 9 additions & 5 deletions core/tools/libwg-go/go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
module golang.zx2c4.com/wireguard/android

go 1.16
go 1.19

require (
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 // indirect
golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d // indirect
golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43
golang.zx2c4.com/wireguard v0.0.0-20210222142647-219296a1e787
golang.org/x/sys v0.6.0
golang.zx2c4.com/wireguard v0.0.0-20230223181233-21636207a675
)

require (
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
)
Loading

0 comments on commit 398b6b3

Please sign in to comment.