This commit is contained in:
Jason A. Donenfeld 2018-05-05 02:48:21 +02:00
parent 4a177de09c
commit 142e53f698
4 changed files with 4 additions and 5 deletions

View file

@ -148,7 +148,6 @@ func main() {
logger.Debug.Println("Debug log enabled")
if err != nil {
logger.Error.Println("Failed to create TUN device:", err)
os.Exit(ExitSetupFailed)

View file

@ -46,7 +46,7 @@ var sockaddrCtlSize uintptr = 32
func CreateTUN(name string) (TUNDevice, error) {
ifIndex := -1
if (name != "utun") {
if name != "utun" {
fmt.Sscanf(name, "utun%d", &ifIndex)
if ifIndex < 0 {
return nil, fmt.Errorf("Interface name must be utun[0-9]*")

View file

@ -11,6 +11,7 @@ package main
*/
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
@ -19,7 +20,6 @@ import (
"net"
"os"
"strconv"
"bytes"
"strings"
"syscall"
"time"

View file

@ -94,9 +94,9 @@ func UAPIListen(name string, file *os.File) (net.Listener, error) {
go func(l *UAPIListener) {
event := unix.Kevent_t{
Ident: uint64(uapi.keventFd),
Ident: uint64(uapi.keventFd),
Filter: unix.EVFILT_VNODE,
Flags: unix.EV_ADD | unix.EV_ENABLE | unix.EV_ONESHOT,
Flags: unix.EV_ADD | unix.EV_ENABLE | unix.EV_ONESHOT,
Fflags: unix.NOTE_WRITE,
}
events := make([]unix.Kevent_t, 1)