diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-05-14 04:21:20 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-05-14 17:10:59 +0200 |
commit | e1ac4247ff30e68e7f9aa820fe4d1f5623bf54ee (patch) | |
tree | dbd691eedfa456f0e599eed745d8218ef4d572cc /app/tools/libwg-go/api-android.go | |
parent | 34422e57a906f3806626bc2a87a290688404224e (diff) |
libwg-go: make changes for recent go code
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/tools/libwg-go/api-android.go')
-rw-r--r-- | app/tools/libwg-go/api-android.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/app/tools/libwg-go/api-android.go b/app/tools/libwg-go/api-android.go index 63551512..5ea57a9d 100644 --- a/app/tools/libwg-go/api-android.go +++ b/app/tools/libwg-go/api-android.go @@ -10,13 +10,14 @@ package main import "C" import ( + "./rwcancel" "bufio" + "golang.org/x/sys/unix" "io/ioutil" "log" "math" "os" "strings" - "syscall" ) type AndroidLogger struct { @@ -52,21 +53,19 @@ func wgTurnOn(ifnameRef string, tun_fd int32, settings string) int32 { events: make(chan TUNEvent, 5), errors: make(chan error, 5), nopi: true, + statusListenersShutdown: make(chan struct{}), } var err error - err = syscall.SetNonblock(int(tun_fd), true) - if err != nil { - logger.Error.Println(err) - return -1 - } - tun.closingReader, tun.closingWriter, err = os.Pipe() + tun.fdCancel, err = rwcancel.NewRWCancel(int(tun_fd)) if err != nil { + unix.Close(int(tun_fd)) logger.Error.Println(err) return -1 } name, err := tun.Name() if err != nil { + unix.Close(int(tun_fd)) logger.Error.Println(err) return -1 } @@ -77,6 +76,7 @@ func wgTurnOn(ifnameRef string, tun_fd int32, settings string) int32 { bufferedSettings := bufio.NewReadWriter(bufio.NewReader(strings.NewReader(settings)), bufio.NewWriter(ioutil.Discard)) setError := ipcSetOperation(device, bufferedSettings) if setError != nil { + unix.Close(int(tun_fd)) logger.Error.Println(setError) return -1 } @@ -91,6 +91,7 @@ func wgTurnOn(ifnameRef string, tun_fd int32, settings string) int32 { } } if i == math.MaxInt32 { + unix.Close(int(tun_fd)) return -1 } tunnelHandles[i] = device |