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