]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
tun: windows: registration of write buffer no longer required
authorJason A. Donenfeld <Jason@zx2c4.com>
Fri, 5 Jul 2019 05:54:25 +0000 (07:54 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 5 Jul 2019 12:17:48 +0000 (14:17 +0200)
README.md
tun/tun_windows.go

index b6a9f39c5879ed03da65f74aa9e414978a0e58c5..0a542e4deb4228ce79e31f44ce24c235d1267ce7 100644 (file)
--- a/README.md
+++ b/README.md
@@ -2,8 +2,6 @@
 
 This is an implementation of WireGuard in Go.
 
-***WARNING:*** This is a work in progress and not ready for prime time, with no official "releases" yet. It is extremely rough around the edges and leaves much to be desired. There are bugs and we are not yet in a position to make claims about its security. Beware.
-
 ## Usage
 
 Most Linux kernel WireGuard users are used to adding an interface with `ip link add wg0 type wireguard`. With wireguard-go, instead simply run:
index f0acc09f3d8f760bbb743a93391228079df836a8..4ae5cf05ff82533d083e066ddeea87dd347d518f 100644 (file)
@@ -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 {