mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2025-08-17 04:08:06 +02:00
tun: windows: registration of write buffer no longer required
This commit is contained in:
@ -11,11 +11,11 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
|
||||
"golang.zx2c4.com/wireguard/tun/wintun"
|
||||
)
|
||||
|
||||
@ -42,7 +42,6 @@ type NativeTun struct {
|
||||
wt *wintun.Wintun
|
||||
tunFileRead *os.File
|
||||
tunFileWrite *os.File
|
||||
haveRegisteredWriteBuffer int32
|
||||
tunLock sync.Mutex
|
||||
close bool
|
||||
rdBuff *exchgBufRead
|
||||
@ -142,7 +141,6 @@ func (tun *NativeTun) openTUN() error {
|
||||
}
|
||||
return err
|
||||
}
|
||||
atomic.StoreInt32(&tun.haveRegisteredWriteBuffer, 0)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -321,15 +319,6 @@ func (tun *NativeTun) Flush() error {
|
||||
return err
|
||||
}
|
||||
|
||||
if atomic.CompareAndSwapInt32(&tun.haveRegisteredWriteBuffer, 0, 1) {
|
||||
firstSize := (*uint32)(unsafe.Pointer(&tun.wrBuff.data[0]))
|
||||
saved := *firstSize
|
||||
*firstSize = 0
|
||||
// Set the maximum buffer length with an invalid write.
|
||||
tun.tunFileWrite.Write(tun.wrBuff.data[:])
|
||||
*firstSize = saved
|
||||
}
|
||||
|
||||
for {
|
||||
_, err = file.Write(tun.wrBuff.data[:tun.wrBuff.offset])
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user