mirror of
https://github.com/fumiama/water.git
synced 2026-06-26 06:50:24 +08:00
use blocking mode pre-go1.11
This commit is contained in:
@@ -59,7 +59,10 @@ type sockaddrCtl struct {
|
||||
|
||||
var sockaddrCtlSize uintptr = 32
|
||||
|
||||
func newTUN(config Config) (ifce *Interface, err error) {
|
||||
func openDev(config Config) (ifce *Interface, err error) {
|
||||
if config.DeviceType != TUN {
|
||||
return nil, errors.New("only tun is implemented on this platform")
|
||||
}
|
||||
var fd int
|
||||
// Supposed to be socket(PF_SYSTEM, SOCK_DGRAM, SYSPROTO_CONTROL), but ...
|
||||
//
|
||||
@@ -111,7 +114,7 @@ func newTUN(config Config) (ifce *Interface, err error) {
|
||||
return nil, fmt.Errorf("error in syscall.Syscall6(syscall.SYS_GETSOCKOPT, ...): %v", err)
|
||||
}
|
||||
|
||||
if err = syscall.SetNonblock(fd, true); err != nil {
|
||||
if err = setNonBlock(fd); err != nil {
|
||||
return nil, fmt.Errorf("setting non-blocking error")
|
||||
}
|
||||
|
||||
@@ -124,10 +127,6 @@ func newTUN(config Config) (ifce *Interface, err error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func newTAP(config Config) (ifce *Interface, err error) {
|
||||
return nil, errors.New("tap interface not implemented on this platform")
|
||||
}
|
||||
|
||||
// tunReadCloser is a hack to work around the first 4 bytes "packet
|
||||
// information" because there doesn't seem to be an IFF_NO_PI for darwin.
|
||||
type tunReadCloser struct {
|
||||
|
||||
Reference in New Issue
Block a user