tun: use sysconn instead of .Fd with Go 1.12

This commit is contained in:
Jason A. Donenfeld
2019-02-27 01:06:43 +01:00
parent 66524c1f7e
commit ab0f442daf
6 changed files with 80 additions and 55 deletions

View File

@@ -8,9 +8,9 @@ package tun
import (
"errors"
"fmt"
"golang.zx2c4.com/wireguard/rwcancel"
"golang.org/x/net/ipv6"
"golang.org/x/sys/unix"
"golang.zx2c4.com/wireguard/rwcancel"
"io/ioutil"
"net"
"os"
@@ -167,7 +167,9 @@ func CreateTUNFromFile(file *os.File, mtu int) (TUNDevice, error) {
return nil, err
}
tun.rwcancel, err = rwcancel.NewRWCancel(int(file.Fd()))
tun.operateOnFd(func(fd uintptr) {
tun.rwcancel, err = rwcancel.NewRWCancel(int(fd))
})
if err != nil {
tun.tunFile.Close()
return nil, err