helper_windows.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2015 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package nettest
  5. import (
  6. "fmt"
  7. "runtime"
  8. "syscall"
  9. )
  10. func maxOpenFiles() int {
  11. return 4 * defaultMaxOpenFiles /* actually it's 16581375 */
  12. }
  13. func supportsRawIPSocket() (string, bool) {
  14. // From http://msdn.microsoft.com/en-us/library/windows/desktop/ms740548.aspx:
  15. // Note: To use a socket of type SOCK_RAW requires administrative privileges.
  16. // Users running Winsock applications that use raw sockets must be a member of
  17. // the Administrators group on the local computer, otherwise raw socket calls
  18. // will fail with an error code of WSAEACCES. On Windows Vista and later, access
  19. // for raw sockets is enforced at socket creation. In earlier versions of Windows,
  20. // access for raw sockets is enforced during other socket operations.
  21. s, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_RAW, 0)
  22. if err == syscall.WSAEACCES {
  23. return fmt.Sprintf("no access to raw socket allowed on %s", runtime.GOOS), false
  24. }
  25. if err != nil {
  26. return err.Error(), false
  27. }
  28. syscall.Closesocket(s)
  29. return "", true
  30. }
  31. func supportsIPv6MulticastDeliveryOnLoopback() bool {
  32. return true
  33. }
  34. func causesIPv6Crash() bool {
  35. return false
  36. }