(file string)
| 74 | ) |
| 75 | |
| 76 | func newNetIPSocket(file string) (NetIPSocket, error) { |
| 77 | f, err := os.Open(file) |
| 78 | if err != nil { |
| 79 | return nil, err |
| 80 | } |
| 81 | defer f.Close() |
| 82 | |
| 83 | var netIPSocket NetIPSocket |
| 84 | isUDP := strings.Contains(file, "udp") |
| 85 | |
| 86 | lr := io.LimitReader(f, readLimit) |
| 87 | s := bufio.NewScanner(lr) |
| 88 | s.Scan() // skip first line with headers |
| 89 | for s.Scan() { |
| 90 | fields := strings.Fields(s.Text()) |
| 91 | line, err := parseNetIPSocketLine(fields, isUDP) |
| 92 | if err != nil { |
| 93 | return nil, err |
| 94 | } |
| 95 | netIPSocket = append(netIPSocket, line) |
| 96 | } |
| 97 | if err := s.Err(); err != nil { |
| 98 | return nil, err |
| 99 | } |
| 100 | return netIPSocket, nil |
| 101 | } |
| 102 | |
| 103 | // newNetIPSocketSummary creates a new NetIPSocket{,6} from the contents of the given file. |
| 104 | func newNetIPSocketSummary(file string) (*NetIPSocketSummary, error) { |
no test coverage detected