diff options
Diffstat (limited to 'tun_darwin.go')
-rw-r--r-- | tun_darwin.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/tun_darwin.go b/tun_darwin.go index b212e57..ac8bffd 100644 --- a/tun_darwin.go +++ b/tun_darwin.go @@ -125,12 +125,6 @@ func CreateTUNFromFile(file *os.File) (TUNDevice, error) { return nil, err } - // set default MTU - err = tun.setMTU(DefaultMTU) - if err != nil { - return nil, err - } - tun.rwcancel, err = rwcancel.NewRWCancel(int(file.Fd())) if err != nil { return nil, err @@ -174,6 +168,13 @@ func CreateTUNFromFile(file *os.File) (TUNDevice, error) { } }(tun) + // set default MTU + err = tun.setMTU(DefaultMTU) + if err != nil { + tun.Close() + return nil, err + } + return tun, nil } |