github.com/yanndegat/hiera@v0.6.8/session/plugintransport_windows.go (about) 1 //go:build windows 2 // +build windows 3 4 package session 5 6 import ( 7 "golang.org/x/sys/windows/registry" 8 "strconv" 9 ) 10 11 // getDefaultPluginTransport returns the plugin transport method to use. 12 // For Windows this can be unix if the OS build is 17063 or above, 13 // otherwise tcp is used 14 // https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/ 15 func getDefaultPluginTransport() string { 16 if isBuild17063() { 17 return pluginTransportUnix 18 } 19 return pluginTransportTCP 20 } 21 22 // isBuild17063 gets the Windows build number from the registry 23 func isBuild17063() bool { 24 k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.READ) 25 if err != nil { 26 return false 27 } 28 defer k.Close() 29 s, _, err := k.GetStringValue("CurrentBuild") 30 if err != nil { 31 return false 32 } 33 ver, err := strconv.Atoi(s) 34 if err != nil { 35 return false 36 } 37 return ver >= 17063 38 }