diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-11-20 11:44:34 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-11-20 12:44:54 +0100 |
commit | 8b0123042f54d843301fbef458b249fcf12466d2 (patch) | |
tree | b3e7bd9f143568666d21014eafe544affb0a89b7 /app/tools | |
parent | 16890a659e6d7877b86e870fe4f0ef9cc19aee5b (diff) |
Implement statistics
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/tools')
-rw-r--r-- | app/tools/libwg-go/api-android.go | 17 | ||||
-rw-r--r-- | app/tools/libwg-go/jni.c | 12 |
2 files changed, 29 insertions, 0 deletions
diff --git a/app/tools/libwg-go/api-android.go b/app/tools/libwg-go/api-android.go index 7e951b9c..7a393cae 100644 --- a/app/tools/libwg-go/api-android.go +++ b/app/tools/libwg-go/api-android.go @@ -15,6 +15,7 @@ import ( "golang.zx2c4.com/wireguard/device" "golang.zx2c4.com/wireguard/ipc" "golang.zx2c4.com/wireguard/tun" + "bytes" "log" "math" "net" @@ -168,6 +169,22 @@ func wgGetSocketV6(tunnelHandle int32) int32 { return int32(fd) } +//export wgGetConfig +func wgGetConfig(tunnelHandle int32) *C.char { + handle, ok := tunnelHandles[tunnelHandle] + if !ok { + return nil + } + settings := new(bytes.Buffer) + writer := bufio.NewWriter(settings) + err := handle.device.IpcGetOperation(writer) + if err != nil { + return nil + } + writer.Flush() + return C.CString(settings.String()) +} + //export wgVersion func wgVersion() *C.char { return C.CString(device.WireGuardGoVersion) diff --git a/app/tools/libwg-go/jni.c b/app/tools/libwg-go/jni.c index f6229a49..3f877d47 100644 --- a/app/tools/libwg-go/jni.c +++ b/app/tools/libwg-go/jni.c @@ -12,6 +12,7 @@ extern int wgTurnOn(struct go_string ifname, int tun_fd, struct go_string settin extern void wgTurnOff(int handle); extern int wgGetSocketV4(int handle); extern int wgGetSocketV6(int handle); +extern char *wgGetConfig(int handle); extern char *wgVersion(); JNIEXPORT jint JNICALL Java_com_wireguard_android_backend_GoBackend_wgTurnOn(JNIEnv *env, jclass c, jstring ifname, jint tun_fd, jstring settings) @@ -47,6 +48,17 @@ JNIEXPORT jint JNICALL Java_com_wireguard_android_backend_GoBackend_wgGetSocketV return wgGetSocketV6(handle); } +JNIEXPORT jstring JNICALL Java_com_wireguard_android_backend_GoBackend_wgGetConfig(JNIEnv *env, jclass c, jint handle) +{ + jstring ret; + char *config = wgGetConfig(handle); + if (!config) + return NULL; + ret = (*env)->NewStringUTF(env, config); + free(config); + return ret; +} + JNIEXPORT jstring JNICALL Java_com_wireguard_android_backend_GoBackend_wgVersion(JNIEnv *env, jclass c) { jstring ret; |