libwg-go: try no stickiness and no roaming
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
75f4478fb5
commit
7120ef9ffd
@ -51,10 +51,6 @@ public final class GoBackend implements Backend {
|
|||||||
|
|
||||||
private static native int wgGetSocketV6(int handle);
|
private static native int wgGetSocketV6(int handle);
|
||||||
|
|
||||||
private static native void wgPutSocketV4(int handle);
|
|
||||||
|
|
||||||
private static native void wgPutSocketV6(int handle);
|
|
||||||
|
|
||||||
private static native void wgTurnOff(int handle);
|
private static native void wgTurnOff(int handle);
|
||||||
|
|
||||||
private static native int wgTurnOn(String ifName, int tunFd, String settings);
|
private static native int wgTurnOn(String ifName, int tunFd, String settings);
|
||||||
@ -190,9 +186,7 @@ public final class GoBackend implements Backend {
|
|||||||
currentTunnel = tunnel;
|
currentTunnel = tunnel;
|
||||||
|
|
||||||
service.protect(wgGetSocketV4(currentTunnelHandle));
|
service.protect(wgGetSocketV4(currentTunnelHandle));
|
||||||
wgPutSocketV4(currentTunnelHandle);
|
|
||||||
service.protect(wgGetSocketV6(currentTunnelHandle));
|
service.protect(wgGetSocketV6(currentTunnelHandle));
|
||||||
wgPutSocketV6(currentTunnelHandle);
|
|
||||||
} else {
|
} else {
|
||||||
Log.i(TAG, "Bringing tunnel down");
|
Log.i(TAG, "Bringing tunnel down");
|
||||||
|
|
||||||
|
@ -85,7 +85,6 @@ func wgTurnOn(ifnameRef string, tun_fd int32, settings string) int32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
device.Up()
|
device.Up()
|
||||||
device.net.bind.(*NativeBind).clearSourceOnAllRouteChanges = true
|
|
||||||
logger.Info.Println("Device started")
|
logger.Info.Println("Device started")
|
||||||
|
|
||||||
var i int32
|
var i int32
|
||||||
@ -122,7 +121,18 @@ func wgGetSocketV4(tunnelHandle int32) int32 {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return -1
|
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
|
//export wgGetSocketV6
|
||||||
@ -135,41 +145,18 @@ func wgGetSocketV6(tunnelHandle int32) int32 {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return -1
|
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) {
|
||||||
//export wgPutSocketV4
|
fd = int32(f)
|
||||||
func wgPutSocketV4(tunnelHandle int32) {
|
})
|
||||||
device, ok := tunnelHandles[tunnelHandle]
|
if err != nil {
|
||||||
if !ok {
|
return -1
|
||||||
return
|
|
||||||
}
|
|
||||||
native, ok := device.net.bind.(*NativeBind)
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fwmark, err := unix.GetsockoptInt(native.sock6, unix.SOL_SOCKET, unix.SO_MARK)
|
|
||||||
if err == nil {
|
|
||||||
native.lastMark = uint32(fwmark)
|
|
||||||
device.net.fwmark = uint32(fwmark)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//export wgPutSocketV6
|
|
||||||
func wgPutSocketV6(tunnelHandle int32) {
|
|
||||||
device, ok := tunnelHandles[tunnelHandle]
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
native, ok := device.net.bind.(*NativeBind)
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fwmark, err := unix.GetsockoptInt(native.sock6, unix.SOL_SOCKET, unix.SO_MARK)
|
|
||||||
if err == nil {
|
|
||||||
native.lastMark = uint32(fwmark)
|
|
||||||
device.net.fwmark = uint32(fwmark)
|
|
||||||
}
|
}
|
||||||
|
return fd
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {}
|
func main() {}
|
||||||
|
@ -10,8 +10,6 @@ extern int wgTurnOn(struct go_string ifname, int tun_fd, struct go_string settin
|
|||||||
extern void wgTurnOff(int handle);
|
extern void wgTurnOff(int handle);
|
||||||
extern int wgGetSocketV4(int handle);
|
extern int wgGetSocketV4(int handle);
|
||||||
extern int wgGetSocketV6(int handle);
|
extern int wgGetSocketV6(int handle);
|
||||||
extern void wgPutSocketV4(int handle);
|
|
||||||
extern void wgPutSocketV6(int handle);
|
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_com_wireguard_android_backend_GoBackend_wgTurnOn(JNIEnv *env, jclass c, jstring ifname, jint tun_fd, jstring settings)
|
JNIEXPORT jint JNICALL Java_com_wireguard_android_backend_GoBackend_wgTurnOn(JNIEnv *env, jclass c, jstring ifname, jint tun_fd, jstring settings)
|
||||||
{
|
{
|
||||||
@ -45,13 +43,3 @@ JNIEXPORT jint JNICALL Java_com_wireguard_android_backend_GoBackend_wgGetSocketV
|
|||||||
{
|
{
|
||||||
return wgGetSocketV6(handle);
|
return wgGetSocketV6(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_com_wireguard_android_backend_GoBackend_wgPutSocketV4(JNIEnv *env, jclass c, jint handle)
|
|
||||||
{
|
|
||||||
wgPutSocketV4(handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_com_wireguard_android_backend_GoBackend_wgPutSocketV6(JNIEnv *env, jclass c, jint handle)
|
|
||||||
{
|
|
||||||
wgPutSocketV6(handle);
|
|
||||||
}
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 4365b4583fa32b1b77d33f5074da9c165a28f824
|
Subproject commit 1dab5b94dd4e87a278c5cbbabe7d045ebab8283a
|
Loading…
Reference in New Issue
Block a user