diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2021-11-20 20:03:12 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-10-19 22:54:23 +0200 |
commit | 0e848735f473e58b1428ff42c5d1e5a27335b1c9 (patch) | |
tree | 770c9ae3c2db263d4a200933bcb6bd048dcb787c /tunnel/tools/libwg-go/jni.c | |
parent | 119b8d362bfb12eb3cb2198b4a7d8d67e7b67a52 (diff) |
tunnel: add gRPC over unix domain socket to the go backend
With gRPC it will be easier to extend the go backend API.
In this commit the Version function is reimplemented in gRPC.
Gitignore generated protobuf files.
Diffstat (limited to 'tunnel/tools/libwg-go/jni.c')
-rw-r--r-- | tunnel/tools/libwg-go/jni.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tunnel/tools/libwg-go/jni.c b/tunnel/tools/libwg-go/jni.c index e47b0be5..b386579c 100644 --- a/tunnel/tools/libwg-go/jni.c +++ b/tunnel/tools/libwg-go/jni.c @@ -15,6 +15,7 @@ extern int wgGetSocketV6(int handle); extern char *wgGetConfig(int handle); extern char *wgVersion(); extern int wgSetConfig(int handle, struct go_string settings); +extern int wgStartGrpc(); JNIEXPORT jint JNICALL Java_com_wireguard_android_backend_GoBackend_wgTurnOn(JNIEnv *env, jclass c, jstring ifname, jint tun_fd, jstring settings) { @@ -82,3 +83,15 @@ JNIEXPORT jint JNICALL Java_com_wireguard_android_backend_GoBackend_wgSetConfig( (*env)->ReleaseStringUTFChars(env, settings, settings_str); return ret; } + +JNIEXPORT jint JNICALL Java_com_wireguard_android_backend_GoBackend_wgStartGrpc(JNIEnv *env, jclass c, jstring sockname) +{ + const char *sockname_str = (*env)->GetStringUTFChars(env, sockname, 0); + size_t sockname_len = (*env)->GetStringUTFLength(env, sockname); + jint res = wgStartGrpc((struct go_string){ + .str = sockname_str, + .n = sockname_len + }); + (*env)->ReleaseStringUTFChars(env, sockname, sockname_str); + return res; +} |