summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-07-31 14:27:29 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-07-31 14:27:29 +0200
commit09cf73cd3c0f37d178aa681023507b41ccb7f61f (patch)
tree0920dc98c7f4315f936bfe013b07a002db951024 /app
parentffa3cefa6741184e159b698ae034ab19a55be9af (diff)
GoBackend: make socket IPC optional
This fixes the multi-user case, which cannot be determined at compile time and probably isn't reasonable to consider anyway in a global manner. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app')
-rw-r--r--app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/api-android.go40
1 files changed, 21 insertions, 19 deletions
diff --git a/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/api-android.go b/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/api-android.go
index 4d87acc8..e57da84f 100644
--- a/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/api-android.go
+++ b/app/tools/libwg-go/src/git.zx2c4.com/wireguard-go/api-android.go
@@ -91,28 +91,28 @@ func wgTurnOn(ifnameRef string, tun_fd int32, settings string) int32 {
return -1
}
+ var uapi net.Listener;
+
uapiFile, err := UAPIOpen(name)
if err != nil {
- unix.Close(int(tun_fd))
- logger.Error.Println(err)
- return -1
- }
- uapi, err := UAPIListen(name, uapiFile)
- if err != nil {
- uapiFile.Close()
- unix.Close(int(tun_fd))
logger.Error.Println(err)
- return -1
- }
- go func() {
- for {
- conn, err := uapi.Accept()
- if err != nil {
- return
- }
- go ipcHandle(device, conn)
+ } else {
+ uapi, err = UAPIListen(name, uapiFile)
+ if err != nil {
+ uapiFile.Close()
+ logger.Error.Println(err)
+ } else {
+ go func() {
+ for {
+ conn, err := uapi.Accept()
+ if err != nil {
+ return
+ }
+ go ipcHandle(device, conn)
+ }
+ }()
}
- }()
+ }
device.Up()
logger.Info.Println("Device started")
@@ -138,7 +138,9 @@ func wgTurnOff(tunnelHandle int32) {
return
}
delete(tunnelHandles, tunnelHandle)
- handle.uapi.Close()
+ if handle.uapi != nil {
+ handle.uapi.Close()
+ }
handle.device.Close()
}