Fix darwin write

This commit is contained in:
世界 2022-08-19 08:34:11 +08:00
parent 9c905191f6
commit 1cc817596b
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
3 changed files with 8 additions and 3 deletions

View file

@ -50,7 +50,11 @@ func Open(options Options) (Tun, error) {
inet4Address: string(options.Inet4Address.Addr().AsSlice()),
inet6Address: string(options.Inet6Address.Addr().AsSlice()),
}
nativeTun.tunWriter, _ = bufio.CreateVectorisedWriter(nativeTun.tunFile)
var ok bool
nativeTun.tunWriter, ok = bufio.CreateVectorisedWriter(nativeTun.tunFile)
if !ok {
panic("create vectorised writer")
}
runtime.SetFinalizer(nativeTun.tunFile, nil)
return nativeTun, nil
}