summaryrefslogtreecommitdiffhomepage
path: root/tunnel/tools/libwg-go
diff options
context:
space:
mode:
Diffstat (limited to 'tunnel/tools/libwg-go')
-rw-r--r--tunnel/tools/libwg-go/api-android.go13
-rw-r--r--tunnel/tools/libwg-go/jni.c13
2 files changed, 26 insertions, 0 deletions
diff --git a/tunnel/tools/libwg-go/api-android.go b/tunnel/tools/libwg-go/api-android.go
index 78ee7f54..ff611e04 100644
--- a/tunnel/tools/libwg-go/api-android.go
+++ b/tunnel/tools/libwg-go/api-android.go
@@ -237,6 +237,19 @@ func wgVersion() *C.char {
return C.CString(Version())
}
+//export wgSetConfig
+func wgSetConfig(tunnelHandle int32, settings string) int32 {
+ handle, ok := tunnelHandles[tunnelHandle]
+ if !ok {
+ return -1
+ }
+ err := handle.device.IpcSet(settings)
+ if err != nil {
+ return -1
+ }
+ return 0
+}
+
func Version() string {
info, ok := debug.ReadBuildInfo()
if !ok {
diff --git a/tunnel/tools/libwg-go/jni.c b/tunnel/tools/libwg-go/jni.c
index 20bfb332..7d6ee8a8 100644
--- a/tunnel/tools/libwg-go/jni.c
+++ b/tunnel/tools/libwg-go/jni.c
@@ -14,6 +14,7 @@ extern int wgGetSocketV4(int handle);
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();
extern int wgSetFd(int handle, int tun_fd);
@@ -72,6 +73,18 @@ JNIEXPORT jstring JNICALL Java_com_wireguard_android_backend_GoBackend_wgVersion
return ret;
}
+JNIEXPORT jint JNICALL Java_com_wireguard_android_backend_GoBackend_wgSetConfig(JNIEnv *env, jclass c, jstring handle, jstring settings)
+{
+ const char *settings_str = (*env)->GetStringUTFChars(env, settings, 0);
+ size_t settings_len = (*env)->GetStringUTFLength(env, settings);
+ int ret = wgSetConfig(handle, (struct go_string){
+ .str = settings_str,
+ .n = settings_len
+ });
+ (*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);