diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-06-01 16:06:56 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-06-01 16:06:56 +0200 |
commit | 1e45898d7035b5d617a3181cf1b6dfab8a10eae9 (patch) | |
tree | 6d4574252ab2a07ea51e6b836c92a9ee82f57756 /app/tools/libwg-go | |
parent | 61431fb57946ce92f6fa613c4683ac95b75f02de (diff) |
Settings: add version
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/tools/libwg-go')
-rw-r--r-- | app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/api-android.go | 5 | ||||
-rw-r--r-- | app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/jni.c | 17 |
2 files changed, 22 insertions, 0 deletions
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 <jni.h> +#include <stdlib.h> +#include <string.h> 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; +} |