aboutsummaryrefslogtreecommitdiffstats
path: root/tun/wintun/wintun_windows.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-10-08 09:58:58 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-10-08 09:58:58 +0200
commit1f146a5e7ad9081c79026339c2ad82f357743d66 (patch)
tree4d9ed3142e1dfe4bfd52afb13cb6d54f02144563 /tun/wintun/wintun_windows.go
parentuapi: allow preventing creation of new peers when updating (diff)
downloadwireguard-go-1f146a5e7ad9081c79026339c2ad82f357743d66.tar.xz
wireguard-go-1f146a5e7ad9081c79026339c2ad82f357743d66.zip
wintun: expose version
Diffstat (limited to 'tun/wintun/wintun_windows.go')
-rw-r--r--tun/wintun/wintun_windows.go30
1 files changed, 29 insertions, 1 deletions
diff --git a/tun/wintun/wintun_windows.go b/tun/wintun/wintun_windows.go
index e2348c0..e6dc141 100644
--- a/tun/wintun/wintun_windows.go
+++ b/tun/wintun/wintun_windows.go
@@ -671,11 +671,39 @@ func (wintun *Interface) tcpipAdapterRegKeyName() string {
return fmt.Sprintf("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Adapters\\%v", wintun.cfgInstanceID)
}
-// deviceRegKeyName returns the device-level registry key name
+// deviceRegKeyName returns the device-level registry key name.
func (wintun *Interface) deviceRegKeyName() string {
return fmt.Sprintf("SYSTEM\\CurrentControlSet\\Enum\\%v", wintun.devInstanceID)
}
+// Version returns the version of the Wintun driver and NDIS system currently loaded.
+func (wintun *Interface) Version() (driverVersion string, ndisVersion string, err error) {
+ key, err := registry.OpenKey(registry.LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Wintun", registry.QUERY_VALUE)
+ if err != nil {
+ return
+ }
+ defer key.Close()
+ driverMajor, _, err := key.GetIntegerValue("DriverMajorVersion")
+ if err != nil {
+ return
+ }
+ driverMinor, _, err := key.GetIntegerValue("DriverMinorVersion")
+ if err != nil {
+ return
+ }
+ ndisMajor, _, err := key.GetIntegerValue("NdisMajorVersion")
+ if err != nil {
+ return
+ }
+ ndisMinor, _, err := key.GetIntegerValue("NdisMinorVersion")
+ if err != nil {
+ return
+ }
+ driverVersion = fmt.Sprintf("%d.%d", driverMajor, driverMinor)
+ ndisVersion = fmt.Sprintf("%d.%d", ndisMajor, ndisMinor)
+ return
+}
+
// tcpipInterfaceRegKeyName returns the interface-specific TCP/IP network registry key name.
func (wintun *Interface) tcpipInterfaceRegKeyName() (path string, err error) {
key, err := registry.OpenKey(registry.LOCAL_MACHINE, wintun.tcpipAdapterRegKeyName(), registry.QUERY_VALUE)