From c281df146211236bc5d43ac58e9a7bd225ae71fb Mon Sep 17 00:00:00 2001 From: cpu100 <42709228+cpu100@users.noreply.github.com> Date: Mon, 18 May 2020 03:26:24 +0800 Subject: [PATCH] fix setTUN order SetTUN should be called before bringing up the device. Order is important, otherwise, an error may occur on the first read. Windows 10. --- syscalls_windows.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/syscalls_windows.go b/syscalls_windows.go index f38a9cb..7c2dc37 100644 --- a/syscalls_windows.go +++ b/syscalls_windows.go @@ -281,17 +281,17 @@ func openDev(config Config) (ifce *Interface, err error) { fd := &wfile{fd: file, ro: ro, wo: wo} ifce = &Interface{isTAP: (config.DeviceType == TAP), ReadWriteCloser: fd} - // bring up device. - if err := setStatus(file, true); err != nil { - return nil, err - } - //TUN if config.DeviceType == TUN { if err := setTUN(file, config.PlatformSpecificParams.Network); err != nil { return nil, err } } + + // bring up device. + if err := setStatus(file, true); err != nil { + return nil, err + } // find the name of tap interface(u need it to set the ip or other command) ifces, err := net.Interfaces()