Skip to content

Commit

Permalink
all: drop support for Windows Vista or below (Windows XP)
Browse files Browse the repository at this point in the history
Per the notice in the Go 1.10 release notes, this change drops the
support for Windows Vista or below (including Windows XP) and
simplifies the code for the sake of maintenance.

There is one exception to the above. The code related to DLL and
system calls still remains in the runtime package. The remaining code
will be refined and used for supporting upcoming Windows versions in
future.

Updates #17245
Fixes #23072

Change-Id: I9e2821721f25ef9b83dfbf85be2b7ee5d9023aa5
Reviewed-on: https://go-review.googlesource.com/94255
Run-TryBot: Brad Fitzpatrick <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
cixtor authored and bradfitz committed Feb 15, 2018
1 parent 9542ba6 commit d50bb8d
Show file tree
Hide file tree
Showing 11 changed files with 7 additions and 307 deletions.
14 changes: 0 additions & 14 deletions src/cmd/go/go_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"os/exec"
"path/filepath"
"strings"
"syscall"
"testing"
)

Expand Down Expand Up @@ -57,15 +56,6 @@ func TestAbsolutePath(t *testing.T) {
}
}

func isWindowsXP(t *testing.T) bool {
v, err := syscall.GetVersion()
if err != nil {
t.Fatalf("GetVersion failed: %v", err)
}
major := byte(v)
return major < 6
}

func runIcacls(t *testing.T, args ...string) string {
t.Helper()
out, err := exec.Command("icacls", args...).CombinedOutput()
Expand All @@ -89,10 +79,6 @@ func runGetACL(t *testing.T, path string) string {
// has discretionary access control list (DACL) set as if the file
// was created in the destination directory.
func TestACL(t *testing.T) {
if isWindowsXP(t) {
t.Skip("Windows XP does not have powershell command")
}

tmpdir, err := ioutil.TempDir("", "TestACL")
if err != nil {
t.Fatal(err)
Expand Down
13 changes: 0 additions & 13 deletions src/internal/syscall/windows/exec_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ import (
)

func TestRunAtLowIntegrity(t *testing.T) {
if isWindowsXP(t) {
t.Skip("Windows XP does not support windows integrity levels")
}

if os.Getenv("GO_WANT_HELPER_PROCESS") == "1" {
wil, err := getProcessIntegrityLevel()
if err != nil {
Expand Down Expand Up @@ -56,15 +52,6 @@ func TestRunAtLowIntegrity(t *testing.T) {
}
}

func isWindowsXP(t *testing.T) bool {
v, err := syscall.GetVersion()
if err != nil {
t.Fatalf("GetVersion failed: %v", err)
}
major := byte(v)
return major < 6
}

const (
sidWilLow = `S-1-16-4096`
)
Expand Down
4 changes: 0 additions & 4 deletions src/internal/testenv/testenv_notwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,3 @@ func hasSymlink() (ok bool, reason string) {

return true, ""
}

func IsWindowsXP() bool {
return false
}
9 changes: 0 additions & 9 deletions src/internal/testenv/testenv_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,3 @@ func hasSymlink() (ok bool, reason string) {

return false, ""
}

func IsWindowsXP() bool {
v, err := syscall.GetVersion()
if err != nil {
panic("GetVersion failed: " + err.Error())
}
major := byte(v)
return major < 6
}
91 changes: 2 additions & 89 deletions src/net/interface_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,6 @@ import (
"unsafe"
)

// supportsVistaIP reports whether the platform implements new IP
// stack and ABIs supported on Windows Vista and above.
var supportsVistaIP bool

func init() {
supportsVistaIP = probeWindowsIPStack()
}

func probeWindowsIPStack() (supportsVistaIP bool) {
v, err := syscall.GetVersion()
if err != nil {
return true // Windows 10 and above will deprecate this API
}
return byte(v) >= 6 // major version of Windows Vista is 6
}

// adapterAddresses returns a list of IP adapter and address
// structures. The structure contains an IP adapter and flattened
// multiple IP addresses including unicast, anycast and multicast
Expand Down Expand Up @@ -126,35 +110,17 @@ func interfaceAddrTable(ifi *Interface) ([]Addr, error) {
if index == 0 { // ipv6IfIndex is a substitute for ifIndex
index = aa.Ipv6IfIndex
}
var pfx4, pfx6 []IPNet
if !supportsVistaIP {
pfx4, pfx6, err = addrPrefixTable(aa)
if err != nil {
return nil, err
}
}
if ifi == nil || ifi.Index == int(index) {
for puni := aa.FirstUnicastAddress; puni != nil; puni = puni.Next {
sa, err := puni.Address.Sockaddr.Sockaddr()
if err != nil {
return nil, os.NewSyscallError("sockaddr", err)
}
var l int
switch sa := sa.(type) {
case *syscall.SockaddrInet4:
if supportsVistaIP {
l = int(puni.OnLinkPrefixLength)
} else {
l = addrPrefixLen(pfx4, IP(sa.Addr[:]))
}
ifat = append(ifat, &IPNet{IP: IPv4(sa.Addr[0], sa.Addr[1], sa.Addr[2], sa.Addr[3]), Mask: CIDRMask(l, 8*IPv4len)})
ifat = append(ifat, &IPNet{IP: IPv4(sa.Addr[0], sa.Addr[1], sa.Addr[2], sa.Addr[3]), Mask: CIDRMask(int(puni.OnLinkPrefixLength), 8*IPv4len)})
case *syscall.SockaddrInet6:
if supportsVistaIP {
l = int(puni.OnLinkPrefixLength)
} else {
l = addrPrefixLen(pfx6, IP(sa.Addr[:]))
}
ifa := &IPNet{IP: make(IP, IPv6len), Mask: CIDRMask(l, 8*IPv6len)}
ifa := &IPNet{IP: make(IP, IPv6len), Mask: CIDRMask(int(puni.OnLinkPrefixLength), 8*IPv6len)}
copy(ifa.IP, sa.Addr[:])
ifat = append(ifat, ifa)
}
Expand All @@ -178,59 +144,6 @@ func interfaceAddrTable(ifi *Interface) ([]Addr, error) {
return ifat, nil
}

func addrPrefixTable(aa *windows.IpAdapterAddresses) (pfx4, pfx6 []IPNet, err error) {
for p := aa.FirstPrefix; p != nil; p = p.Next {
sa, err := p.Address.Sockaddr.Sockaddr()
if err != nil {
return nil, nil, os.NewSyscallError("sockaddr", err)
}
switch sa := sa.(type) {
case *syscall.SockaddrInet4:
pfx := IPNet{IP: IP(sa.Addr[:]), Mask: CIDRMask(int(p.PrefixLength), 8*IPv4len)}
pfx4 = append(pfx4, pfx)
case *syscall.SockaddrInet6:
pfx := IPNet{IP: IP(sa.Addr[:]), Mask: CIDRMask(int(p.PrefixLength), 8*IPv6len)}
pfx6 = append(pfx6, pfx)
}
}
return
}

// addrPrefixLen returns an appropriate prefix length in bits for ip
// from pfxs. It returns 32 or 128 when no appropriate on-link address
// prefix found.
//
// NOTE: This is pretty naive implementation that contains many
// allocations and non-effective linear search, and should not be used
// freely.
func addrPrefixLen(pfxs []IPNet, ip IP) int {
var l int
var cand *IPNet
for i := range pfxs {
if !pfxs[i].Contains(ip) {
continue
}
if cand == nil {
l, _ = pfxs[i].Mask.Size()
cand = &pfxs[i]
continue
}
m, _ := pfxs[i].Mask.Size()
if m > l {
l = m
cand = &pfxs[i]
continue
}
}
if l > 0 {
return l
}
if ip.To4() != nil {
return 8 * IPv4len
}
return 8 * IPv6len
}

// interfaceMulticastAddrTable returns addresses for a specific
// interface.
func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error) {
Expand Down
132 changes: 0 additions & 132 deletions src/net/interface_windows_test.go

This file was deleted.

18 changes: 0 additions & 18 deletions src/net/net_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,6 @@ func TestAcceptIgnoreSomeErrors(t *testing.T) {
}
}

func isWindowsXP(t *testing.T) bool {
v, err := syscall.GetVersion()
if err != nil {
t.Fatalf("GetVersion failed: %v", err)
}
major := byte(v)
return major < 6
}

func runCmd(args ...string) ([]byte, error) {
removeUTF8BOM := func(b []byte) []byte {
if len(b) >= 3 && b[0] == 0xEF && b[1] == 0xBB && b[2] == 0xBF {
Expand Down Expand Up @@ -266,9 +257,6 @@ func netshInterfaceIPShowInterface(ipver string, ifaces map[string]bool) error {
}

func TestInterfacesWithNetsh(t *testing.T) {
if isWindowsXP(t) {
t.Skip("Windows XP netsh command does not provide required functionality")
}
if !netshSpeaksEnglish(t) {
t.Skip("English version of netsh required for this test")
}
Expand Down Expand Up @@ -440,9 +428,6 @@ func netshInterfaceIPv6ShowAddress(name string, netshOutput []byte) []string {
}

func TestInterfaceAddrsWithNetsh(t *testing.T) {
if isWindowsXP(t) {
t.Skip("Windows XP netsh command does not provide required functionality")
}
if !netshSpeaksEnglish(t) {
t.Skip("English version of netsh required for this test")
}
Expand Down Expand Up @@ -519,9 +504,6 @@ func checkGetmac(t *testing.T) {
}

func TestInterfaceHardwareAddrWithGetmac(t *testing.T) {
if isWindowsXP(t) {
t.Skip("Windows XP does not have powershell command")
}
checkGetmac(t)

ift, err := Interfaces()
Expand Down
Loading

0 comments on commit d50bb8d

Please sign in to comment.