From 1e45898d7035b5d617a3181cf1b6dfab8a10eae9 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 1 Jun 2018 16:06:56 +0200 Subject: Settings: add version Signed-off-by: Jason A. Donenfeld --- .../src/git.zx2c4.com/wireguard-go/api-android.go | 5 +++++ app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/jni.c | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'app/tools/libwg-go/src') diff --git a/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/api-android.go b/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/api-android.go index f5dae966..19063eec 100644 --- a/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/api-android.go +++ b/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/api-android.go @@ -160,4 +160,9 @@ func wgGetSocketV6(tunnelHandle int32) int32 { return fd } +//export wgVersion +func wgVersion() string { + return WireGuardGoVersion +} + func main() {} diff --git a/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/jni.c b/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/jni.c index a0f3d0ba..acb2d728 100644 --- a/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/jni.c +++ b/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/jni.c @@ -4,12 +4,15 @@ */ #include +#include +#include struct go_string { const char *str; long n; }; extern int wgTurnOn(struct go_string ifname, int tun_fd, struct go_string settings); extern void wgTurnOff(int handle); extern int wgGetSocketV4(int handle); extern int wgGetSocketV6(int handle); +extern struct go_string wgVersion(); JNIEXPORT jint JNICALL Java_com_wireguard_android_backend_GoBackend_wgTurnOn(JNIEnv *env, jclass c, jstring ifname, jint tun_fd, jstring settings) { @@ -43,3 +46,17 @@ JNIEXPORT jint JNICALL Java_com_wireguard_android_backend_GoBackend_wgGetSocketV { return wgGetSocketV6(handle); } + +JNIEXPORT jstring JNICALL Java_com_wireguard_android_backend_GoBackend_wgVersion(JNIEnv *env, jclass c) +{ + struct go_string s = wgVersion(); + char *cstr = malloc(s.n + 1); + if (!cstr) + return NULL; + jstring ret; + memcpy(cstr, s.str, s.n); + cstr[s.n] = '\0'; + ret = (*env)->NewStringUTF(env, cstr); + free(cstr); + return ret; +} -- cgit v1.2.3