You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

30 lines
627 B

  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. // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
  5. package nettest
  6. import (
  7. "fmt"
  8. "os"
  9. "runtime"
  10. "syscall"
  11. )
  12. func maxOpenFiles() int {
  13. var rlim syscall.Rlimit
  14. if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlim); err != nil {
  15. return defaultMaxOpenFiles
  16. }
  17. return int(rlim.Cur)
  18. }
  19. func supportsRawIPSocket() (string, bool) {
  20. if os.Getuid() != 0 {
  21. return fmt.Sprintf("must be root on %s", runtime.GOOS), false
  22. }
  23. return "", true
  24. }