diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-02-11 22:24:31 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-10-26 00:14:13 +0200 |
commit | b8787d1684c5f6eb7ff074c9251d5631cd8abd31 (patch) | |
tree | 1a92ce137ec080a88dbaffac53c7df0be29b03a2 /tunnel/tools/libwg-go/api-android.go | |
parent | 892eaa852ddafba59ae4125650a6f4651a9fecff (diff) |
tunnel: request DHCPv6 leases
Diffstat (limited to 'tunnel/tools/libwg-go/api-android.go')
-rw-r--r-- | tunnel/tools/libwg-go/api-android.go | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tunnel/tools/libwg-go/api-android.go b/tunnel/tools/libwg-go/api-android.go index 484a89b0..943ba628 100644 --- a/tunnel/tools/libwg-go/api-android.go +++ b/tunnel/tools/libwg-go/api-android.go @@ -49,6 +49,7 @@ type TunnelHandle struct { device *device.Device uapi net.Listener logger *device.Logger + tun *tun.NativeTun } var tunnelHandles map[int32]TunnelHandle @@ -143,10 +144,29 @@ func wgTurnOn(interfaceName string, tunFd int32, settings string) int32 { device.Close() return -1 } - tunnelHandles[i] = TunnelHandle{device: device, uapi: uapi} + tunnelHandles[i] = TunnelHandle{device: device, uapi: uapi, tun: tun} return i } +//export wgSetFd +func wgSetFd(tunnelHandle int32, tunFd int32) { + tag := cstring(fmt.Sprintf("WireGuard/GoBackend/%x", tunnelHandle)) + logger := &device.Logger{ + Verbosef: AndroidLogger{level: C.ANDROID_LOG_DEBUG, tag: tag}.Printf, + Errorf: AndroidLogger{level: C.ANDROID_LOG_ERROR, tag: tag}.Printf, + } + + handle, ok := tunnelHandles[tunnelHandle] + if !ok { + unix.Close(int(tunFd)) + logger.Errorf("Tunnel not found") + return + } + + handle.tun.SetFd(int(tunFd)) + logger.Verbosef("wgSetFd: %v", tunFd) +} + //export wgTurnOff func wgTurnOff(tunnelHandle int32) { handle, ok := tunnelHandles[tunnelHandle] |