From a533be82e8d889216bcc25b2aad35ca55f2822ff Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 22 May 2018 19:42:12 +0200 Subject: libwg-go: No sticky sockets with VPNService.java Signed-off-by: Jason A. Donenfeld --- app/tools/libwg-go/api-android.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'app/tools/libwg-go') diff --git a/app/tools/libwg-go/api-android.go b/app/tools/libwg-go/api-android.go index a609ec44..faf718ab 100644 --- a/app/tools/libwg-go/api-android.go +++ b/app/tools/libwg-go/api-android.go @@ -133,7 +133,18 @@ func wgGetSocketV4(tunnelHandle int32) int32 { if !ok { return -1 } - return int32(native.sock4) + fd := int32(-1) + conn, err := native.ipv4.SyscallConn() + if err != nil { + return -1 + } + err = conn.Control(func(f uintptr) { + fd = int32(f) + }) + if err != nil { + return -1 + } + return fd } //export wgGetSocketV6 @@ -146,7 +157,18 @@ func wgGetSocketV6(tunnelHandle int32) int32 { if !ok { return -1 } - return int32(native.sock6) + fd := int32(-1) + conn, err := native.ipv6.SyscallConn() + if err != nil { + return -1 + } + err = conn.Control(func(f uintptr) { + fd = int32(f) + }) + if err != nil { + return -1 + } + return fd } func main() {} -- cgit v1.2.3