libwg-go: make changes for recent go code
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
34422e57a9
commit
e1ac4247ff
@ -2,9 +2,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright © 2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
|
# Copyright © 2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
|
||||||
|
|
||||||
containing = $(foreach v,$2,$(if $(findstring $1,$v),$v))
|
FILES := $(filter-out %/main.go,$(wildcard ../wireguard-go/*/*.go) $(wildcard ../wireguard-go/*.go))
|
||||||
FILES := $(wildcard ../wireguard-go/*/*.go) $(wildcard ../wireguard-go/*.go)
|
|
||||||
FILES := $(filter-out %/main.go $(filter-out %_linux.go,$(call containing,_,$(FILES))),$(FILES))
|
|
||||||
|
|
||||||
NDK_GO_ARCH_MAP_x86 := 386
|
NDK_GO_ARCH_MAP_x86 := 386
|
||||||
NDK_GO_ARCH_MAP_x86_64 := amd64
|
NDK_GO_ARCH_MAP_x86_64 := amd64
|
||||||
|
@ -10,13 +10,14 @@ package main
|
|||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"./rwcancel"
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AndroidLogger struct {
|
type AndroidLogger struct {
|
||||||
@ -52,21 +53,19 @@ func wgTurnOn(ifnameRef string, tun_fd int32, settings string) int32 {
|
|||||||
events: make(chan TUNEvent, 5),
|
events: make(chan TUNEvent, 5),
|
||||||
errors: make(chan error, 5),
|
errors: make(chan error, 5),
|
||||||
nopi: true,
|
nopi: true,
|
||||||
|
statusListenersShutdown: make(chan struct{}),
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
err = syscall.SetNonblock(int(tun_fd), true)
|
tun.fdCancel, err = rwcancel.NewRWCancel(int(tun_fd))
|
||||||
if err != nil {
|
|
||||||
logger.Error.Println(err)
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
tun.closingReader, tun.closingWriter, err = os.Pipe()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
unix.Close(int(tun_fd))
|
||||||
logger.Error.Println(err)
|
logger.Error.Println(err)
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
name, err := tun.Name()
|
name, err := tun.Name()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
unix.Close(int(tun_fd))
|
||||||
logger.Error.Println(err)
|
logger.Error.Println(err)
|
||||||
return -1
|
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))
|
bufferedSettings := bufio.NewReadWriter(bufio.NewReader(strings.NewReader(settings)), bufio.NewWriter(ioutil.Discard))
|
||||||
setError := ipcSetOperation(device, bufferedSettings)
|
setError := ipcSetOperation(device, bufferedSettings)
|
||||||
if setError != nil {
|
if setError != nil {
|
||||||
|
unix.Close(int(tun_fd))
|
||||||
logger.Error.Println(setError)
|
logger.Error.Println(setError)
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
@ -91,6 +91,7 @@ func wgTurnOn(ifnameRef string, tun_fd int32, settings string) int32 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if i == math.MaxInt32 {
|
if i == math.MaxInt32 {
|
||||||
|
unix.Close(int(tun_fd))
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
tunnelHandles[i] = device
|
tunnelHandles[i] = device
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 7cc2668355519ca78c6585197ed15f93b12891f1
|
Subproject commit 6b4a340f027d7978bb29cd7da672a20a0a070169
|
@ -1 +1 @@
|
|||||||
Subproject commit 233f079a9479279d2aab68f4accb139ee87ad664
|
Subproject commit a62c770a99e830f220314d1bc779e8818d4ecc7f
|
Loading…
Reference in New Issue
Block a user