Skip to content

Commit

Permalink
tun: make customization of WintunPool and requested GUID more obvious
Browse files Browse the repository at this point in the history
Persnickety consumers can now do:

    func init() {
        tun.WintunPool, _ = wintun.MakePool("Flurp")
        tun.WintunStaticRequestedGUID, _ = windows.GUIDFromString("{5ae2716f-0b3e-4dc4-a8b5-48eba11a6e16}")
    }

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
  • Loading branch information
zx2c4 committed Dec 23, 2020
1 parent 3735a65 commit 2a607d1
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions tun/tun_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,8 @@ type NativeTun struct {
readWait windows.Handle
}

var WintunPool *wintun.Pool

func init() {
var err error
WintunPool, err = wintun.MakePool("WireGuard")
if err != nil {
panic(fmt.Errorf("Failed to make pool: %w", err))
}
}
var WintunPool, _ = wintun.MakePool("WireGuard")
var WintunStaticRequestedGUID *windows.GUID

//go:linkname procyield runtime.procyield
func procyield(cycles uint32)
Expand All @@ -65,7 +58,7 @@ func nanotime() int64
// interface with the same name exist, it is reused.
//
func CreateTUN(ifname string, mtu int) (Device, error) {
return CreateTUNWithRequestedGUID(ifname, nil, mtu)
return CreateTUNWithRequestedGUID(ifname, WintunStaticRequestedGUID, mtu)
}

//
Expand Down

0 comments on commit 2a607d1

Please sign in to comment.