Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.kapt) apply false
}

tasks {
wrapper {
gradleVersion = "8.14"
distributionSha256Sum = "61ad310d3c7d3e5da131b76bbf22b5a4c0786e9d892dae8c1658d4b484de3caa"
}
}
// Empty root project - modules are configured individually
17 changes: 10 additions & 7 deletions tunnel/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import org.gradle.api.tasks.testing.logging.TestLogEvent

val pkg: String = providers.gradleProperty("wireguardPackageName").get()
val pkg: String = providers.gradleProperty("wireguardPackageName").getOrElse("com.wireguard.android")

plugins {
alias(libs.plugins.android.library)
id("com.android.library")
`maven-publish`
signing
}
Expand All @@ -15,10 +15,11 @@ android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
isCoreLibraryDesugaringEnabled = true
}
namespace = "${pkg}.tunnel"
defaultConfig {
minSdk = 21
minSdk = 28
}
externalNativeBuild {
cmake {
Expand Down Expand Up @@ -66,18 +67,20 @@ android {
}

dependencies {
implementation(libs.androidx.annotation)
implementation(libs.androidx.collection)
implementation(libs.annotation)
implementation(libs.androidx.core)
compileOnly(libs.javax.annotation.api)
compileOnly(libs.jsr305)
testImplementation(libs.junit)
testImplementation(libs.junit4)
coreLibraryDesugaring(libs.desugar.jdk.libs)
}

publishing {
publications {
register<MavenPublication>("release") {
groupId = pkg
artifactId = "tunnel"
version = providers.gradleProperty("wireguardVersionName").get()
version = providers.gradleProperty("wireguardVersionName").getOrElse("1.0.0")
afterEvaluate {
from(components["release"])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,41 @@
*/
@NonNullForAll
public class Statistics {
public record PeerStats(long rxBytes, long txBytes, long latestHandshakeEpochMillis) { }
public static class PeerStats {
public final long rxBytes;
public final long txBytes;
public final long latestHandshakeEpochMillis;

public PeerStats(long rxBytes, long txBytes, long latestHandshakeEpochMillis) {
this.rxBytes = rxBytes;
this.txBytes = txBytes;
this.latestHandshakeEpochMillis = latestHandshakeEpochMillis;
}

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
PeerStats peerStats = (PeerStats) obj;
return rxBytes == peerStats.rxBytes &&
txBytes == peerStats.txBytes &&
latestHandshakeEpochMillis == peerStats.latestHandshakeEpochMillis;
}

@Override
public int hashCode() {
return Objects.hash(rxBytes, txBytes, latestHandshakeEpochMillis);
}

@Override
public String toString() {
return "PeerStats{" +
"rxBytes=" + rxBytes +
", txBytes=" + txBytes +
", latestHandshakeEpochMillis=" + latestHandshakeEpochMillis +
'}';
}
}
private final Map<Key, PeerStats> stats = new HashMap<>();
private long lastTouched = SystemClock.elapsedRealtime();

Expand Down
2 changes: 2 additions & 0 deletions tunnel/tools/libwg-go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ $(BUILDDIR)/go-$(GO_VERSION)/.prepared: $(GRADLE_USER_HOME)/caches/golang/$(GO_T
touch "$@"'

$(DESTDIR)/libwg-go.so: export PATH := $(BUILDDIR)/go-$(GO_VERSION)/bin/:$(PATH)
$(DESTDIR)/libwg-go.so: export GOPROXY := direct
$(DESTDIR)/libwg-go.so: export GOSUMDB := off
$(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 -buildid=" -v -trimpath -buildvcs=false -o "$@" -buildmode c-shared

Expand Down